On Thu, Jun 15, 2006 at 10:03:16PM +1000, Graham Smith wrote:
> STDIN is the constant for the predefined variable $stdin although you could 
> use $< but I believe it is not very descriptive and difficult to read in a 
> whole lot of code, unless you know all the symbols and their meanings off by 
> heart..

Amen.  The symbolic variables, so beloved of Perl programmers, belies Ruby's
origins as a "different Perl" (hence the name, even).  Over time, though,
those symbolic variables have lost popularity (for the very good reasons
that Graham mentions), to the point that I think I recall reading that Ruby
2.0 will remove them entirely.

As far as STDIN vs. $stdin, looking back over my code I see that I've been
using $stdin more, but I don't know why that is.  I'd say that either is
equally readable, but it's important to be consistent across a particular
program -- if you start using $stdin, keep using it.  Don't swap between the
two -- that *will* confuse people mightily (and possibly even break your
program, if you start doing silly buggers with one or the other of them).

- Matt
_______________________________________________
coders mailing list
[email protected]
http://lists.slug.org.au/listinfo/coders

Reply via email to