From: Angus McIntyre Date: 2001-05-16T02:15:58+09:00 Subject: [ruby-talk:15191] Re: Discussion on new Ruby features At 1:52 am +0900 16.05.2001, Christian Szegedy wrote: >Matz wrote: >> I'm interested in *optional* argument type specifier as in Guy > >Nice to know this!!! >Have you considered type (of course OPTIONAL) type restriction not just >for the arguments, but also for the variables? You might want to take a look at the way Common LISP does this stuff. LISP is largely an untyped language, but Common LISP allows you to specify types in a couple of ways, with a view to (a) checking the correctness of your program, and (b) allowing you to benefit from any compiler optimizations that may be going. The forms used are 'declare' (which is a general purpose means of letting the compiler know how it can optimize code, and covers more than just typing) and 'the'. For example, you can write: (declare (integer x)) at the start of a block to let the compiler know that the variable 'x' will always be an integer. Using 'the', you can also specify the results that you expect to get back from particular chunks of code, i.e. (the integer (+ x 3)) See: for more information. I'm not saying that Ruby should follow LISP syntax (eeek!!!), but simply that (a) this might be a source of interesting ideas and (b) there is precedent for this kind of thing. A -- angus@pobox.com http://pobox.com/~angus