>>>>> "S" == Szymon Drejewicz <drejewic / wsisiz.edu.pl> writes:

S>         eval("name='Alice'", MAIN_BINDING)
S>         puts name

 Like have said matz the problem is with this

svg% cat b.rb
#!/usr/bin/ruby
def name
   "a nice method with a nice name"
end

eval("name='Alice'")
puts name
svg% 

svg% b.rb
a nice method with a nice name
svg%

 because at compile time, the local variable `name' was not defined ruby
 has compiled the script to make a call to the method #name
 
S> it just means "evaluate this command and execute it in main block..."

 yes, this is what do ruby but it do it at *runtime* when 

    puts name

 is interpreted at *compile* time.

 This is at compile time, that ruby resolve `name' as

   *) reference to a local variable (if it was previously found a variable
      with this name)

   *) *OR* a method call (if it don't exist a variable with this name)

 and in your example at *compile* time the variable `name' don't exist

S> I know that is not so easy, but what's wrong with that? Just want to write
S> self-writing code :-)

 Don't make the error of a P language : an hash is really appropriate in
 your case and it's perhaps the best solution


Guy Decoux