> Whereas in Javascript that would compile. there is no such thing as compilation in javascript or ruby... wikipedia: A compiler is a computer program that translates a series of statements written in one computer language (called the source code) into a resulting output in another computer language (often called the object or target language). > --- Ursprgliche Nachricht --- > Von: ajmayo / my-deja.com > An: ruby-talk / ruby-lang.org (ruby-talk ML) > Betreff: Re: Assigning a block to a variable in Ruby > Datum: Fri, 16 Dec 2005 02:47:39 +0900 > > WRT forward references. My code was just > > foo(100) > > def foo(p) > puts p > end > > > this will not work unless the call to foo is placed after the function > definition. > > Whereas in Javascript that would compile. > > I can see that functions can forward reference, so I guess the logical > reason for this is, as you say, that Ruby wants to be able to resolve > as it executes, therefore > > p = proc {foo(100)} > > def foo(p) > puts p > end > > p.call > > > will also compile, although foo() is a forward reference, because we > don't attempt to execute the call to foo until after Ruby has parsed > the function > >