Chuck Esterbrook wrote: > On Jan 7, 2008 1:32 AM, Christopher Smith <[EMAIL PROTECTED]> wrote: > >> I'm not talking about getting rid of types. I'm talking about languages >> where the *variables* don't have types, which is a pretty common trait >> of dynamically typed languages. >> >> With a dynamically typed language, you tend not to focus on the types of >> your variables, but rather their roles (there is a difference), and of >> course the role can and should be adequately described by the variable >> name. Interestingly, knowing the roles involved in an algorithm is even >> more telling than the data types. >> > > While convenient when cranking out code, I've found typeless arguments > to be time consuming when inheriting someone else's code. If the > method is non-trivial, I have to study the implementation carefully to > figure out what the expectations are for the argument known as, for > example, "entity". Furthermore, if I then start to rework the Entity > class, I get no compile-time help about how I just broke 12 methods in > 4 files. Instead I have to run through all the test cases to find out. > And to the extent that the project's automated tests lack code > coverage, I end up producing some new bugs. > Type systems have lots of holes in them too, which is exactly why test cases exist. Running test cases in a dynamic language is roughly equivalent to compiling in a non-static language, only the validation process is more powerful and flexible. > So one feature I'm contemplating in Cobra is allowing contracts speak > about typeless arguments like so: > > def addEntity(entity) > require > entity responds to (get name as String) > entity responds to (def computeResults(factors)) > body > ... > > At which point the compiler is empowered to give you some errors when > you violate the expectations of a method you're calling. > Sounds like Eiffel.... or unit tests. :-)
Another way to go with this is just to make meta programming as easy as humanly possible and provide nice facilities for unit testing. --Chris -- [email protected] http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg
