From: Just Another Victim of the Ambient Morality Date: 2007-12-07T23:15:10+09:00 Subject: Re: Newbie ruby wonderment. "MonkeeSage" wrote in message news:22168293-d632-4314-aa6c-45d50baa1a75@i29g2000prf.googlegroups.com... > On Dec 6, 10:16 pm, araminska wrote: >> > Ruby, like Perl, reads the code line by line, the same as you write >> > it.. >> >> Sorry, but I have to disagree. (That is, if you are saying that Perl has >> to have the subs first, also. Not sure you are.) >> >> With perl >> >> print_form() >> >> sub print_form { >> #... do stuff >> >> } >> >> works just fine. I have always put the subs at the bottom and the >> calling >> code at the top. >> >> But you are right and I was wrong about Ruby. Methods DO have to be >> defined before use. Not sure what I did before to think they don't. >> Perl >> and Ruby obviously have different compiling structures. >> >> No biggie. I just have to remember that till it becomes natural. >> >> Araminska > > Seems that perl parses the entire file first, before it runs any code. > In most interpreted languages (ruby, python, lua, javascript, php, > &c), the code is executed as soon as an expression is parsed, so it is > an error to call a function before you define it. This is interesting 'cause Python is "compiled at runtime" (as Lee Jarvis put it) and, yet, it shares the same limitation of needing definitions before use as Ruby...