From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2003-07-17T02:09:54+09:00 Subject: Re: Other languages' features in Ruby In article , Ben Giddings wrote: >Hrm, well I'm a Ruby/Java/C/C++/Python/Perl/Lisp/Javascript/PHP... >um... and others programmer. > >On Wednesday, July 16, 2003, at 09:36 AM, Peter Hickman wrote: >> We've had Java/C++/Whatever programmers ask for type checking, >> operator overloading, polymorphism and a whole host of compile time >> checking. > >Is there a good way to get what type checking does for you? Unit testing. >Maybe some >kind of ruby-lint program that looks through your source code and tries >to see if you're making odd assumptions about the type of your >variables? Or (much more useful in my opinion) something that will try >to catch the use of uninitialized variables? Well, that already happens: def foo(bar) puts a end foo(1) NameError: undefined local variable or method `a' for # from (irb):5:in `foo' from (irb):8 ....OK, admitedly, that's at runtime, but that's why you want unit tests. >This would be helpful in >catching typos, like calling the class variable @my_var, but ending up >using it as @myvar. > >> Lisp programmers have enquired about macros (occasionally). > >Are there good ways of doing what Lisp macros do for you? Perl has input filters (see the perlfilter docs) that sort of act like a pre-processor for yout source. This was originally intended for encrypting source-code, but now is used for lots of other purposes. Perl even has a command line argument (-p, I believe) that will pass the source through the c pre-processor before Perl interprets it. I wonder how difficult it would be to do input filters for Ruby? On the otherhand, it's probably not a feature needed in Ruby as much as it is in Perl. > >Maybe the fact people keep asking for this points to the need for a set >of FAQs that pick features from other languages and explain if they >exist in Ruby, how to use them, and if they're not there, why not. >Maybe such a FAQ already exists, I don't know. > >Ben > > Phil