[MacRuby-devel] eval() Behavior Difference Between Ruby and MacRuby

2012-03-08 Thread Braxton Sherouse
Hello, all. I'm new to the list (and to MacRuby!), so I give my
apologies in advance for any newbie indiscretions.

I was working today with MacRuby as a scripting language within a
Cocoa app, and found a difference between how Ruby and MacRuby's eval
functions relate to their calling context.

Here's a reduction:

% irb --version
irb 0.9.5(05/04/13)

% irb
>> eval("f = 12")
=> 12
>> f
=> 12

% macirb --version
DietRB (0.6.1)

% macirb
irb(main):001:0> eval("f = 12")
=> 12
irb(main):002:0> f
NameError: undefined local variable or method `f' for main:TopLevel


I'm sure I'm missing something super basic. I followed a number of
false leads in trying to figure this out before emailing the list,
including checking out the $SAFE global (0 in both cases), and
constructing Bindings to the calling context (same result).

Thanks in advance for your patience and your help!

Best,
Braxton Sherouse
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] eval() Behavior Difference Between Ruby and MacRuby

2012-03-08 Thread Matt Aimonetti
It's actually a difference between Ruby 1.8 and 1.9, see the same code with
1.9.3:

$ irb
1.9.3p125 :001 > eval "f=12"
 => 12
1.9.3p125 :002 > f
NameError: undefined local variable or method `f' for main:Object
from (irb):2
from /Users/mattetti/.rvm/rubies/ruby-1.9.3-p125/bin/irb:16:in `'

- Matt


On Thu, Mar 8, 2012 at 7:14 PM, Braxton Sherouse <
[email protected]> wrote:

> Hello, all. I'm new to the list (and to MacRuby!), so I give my
> apologies in advance for any newbie indiscretions.
>
> I was working today with MacRuby as a scripting language within a
> Cocoa app, and found a difference between how Ruby and MacRuby's eval
> functions relate to their calling context.
>
> Here's a reduction:
>
> % irb --version
> irb 0.9.5(05/04/13)
>
> % irb
> >> eval("f = 12")
> => 12
> >> f
> => 12
>
> % macirb --version
> DietRB (0.6.1)
>
> % macirb
> irb(main):001:0> eval("f = 12")
> => 12
> irb(main):002:0> f
> NameError: undefined local variable or method `f' for main:TopLevel
>
>
> I'm sure I'm missing something super basic. I followed a number of
> false leads in trying to figure this out before emailing the list,
> including checking out the $SAFE global (0 in both cases), and
> constructing Bindings to the calling context (same result).
>
> Thanks in advance for your patience and your help!
>
> Best,
> Braxton Sherouse
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] eval() Behavior Difference Between Ruby and MacRuby

2012-03-08 Thread Braxton Sherouse
Thanks; that's totally it.

That specific spec change is painfully clear in
https://github.com/rubyspec/rubyspec/blob/master/core/kernel/eval_spec.rb
(but, of course, I didn't think to look there!)

Best,
Braxton

On Thu, Mar 8, 2012 at 8:47 PM, Matt Aimonetti  wrote:
> It's actually a difference between Ruby 1.8 and 1.9, see the same code with
> 1.9.3:
>
> $ irb
> 1.9.3p125 :001 > eval "f=12"
>  => 12
> 1.9.3p125 :002 > f
> NameError: undefined local variable or method `f' for main:Object
> from (irb):2
> from /Users/mattetti/.rvm/rubies/ruby-1.9.3-p125/bin/irb:16:in `'
>
> - Matt
>
>
> On Thu, Mar 8, 2012 at 7:14 PM, Braxton Sherouse
>  wrote:
>>
>> Hello, all. I'm new to the list (and to MacRuby!), so I give my
>> apologies in advance for any newbie indiscretions.
>>
>> I was working today with MacRuby as a scripting language within a
>> Cocoa app, and found a difference between how Ruby and MacRuby's eval
>> functions relate to their calling context.
>>
>> Here's a reduction:
>>
>> % irb --version
>> irb 0.9.5(05/04/13)
>>
>> % irb
>> >> eval("f = 12")
>> => 12
>> >> f
>> => 12
>>
>> % macirb --version
>> DietRB (0.6.1)
>>
>> % macirb
>> irb(main):001:0> eval("f = 12")
>> => 12
>> irb(main):002:0> f
>> NameError: undefined local variable or method `f' for main:TopLevel
>>
>>
>> I'm sure I'm missing something super basic. I followed a number of
>> false leads in trying to figure this out before emailing the list,
>> including checking out the $SAFE global (0 in both cases), and
>> constructing Bindings to the calling context (same result).
>>
>> Thanks in advance for your patience and your help!
>>
>> Best,
>> Braxton Sherouse
>> ___
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
>
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] eval() Behavior Difference Between Ruby and MacRuby

2012-03-08 Thread Matt Aimonetti
No worries at all, thanks for using MacRuby.

- Matt

On Thu, Mar 8, 2012 at 8:08 PM, Braxton Sherouse <
[email protected]> wrote:

> Thanks; that's totally it.
>
> That specific spec change is painfully clear in
> https://github.com/rubyspec/rubyspec/blob/master/core/kernel/eval_spec.rb
> (but, of course, I didn't think to look there!)
>
> Best,
> Braxton
>
> On Thu, Mar 8, 2012 at 8:47 PM, Matt Aimonetti 
> wrote:
> > It's actually a difference between Ruby 1.8 and 1.9, see the same code
> with
> > 1.9.3:
> >
> > $ irb
> > 1.9.3p125 :001 > eval "f=12"
> >  => 12
> > 1.9.3p125 :002 > f
> > NameError: undefined local variable or method `f' for main:Object
> > from (irb):2
> > from /Users/mattetti/.rvm/rubies/ruby-1.9.3-p125/bin/irb:16:in `'
> >
> > - Matt
> >
> >
> > On Thu, Mar 8, 2012 at 7:14 PM, Braxton Sherouse
> >  wrote:
> >>
> >> Hello, all. I'm new to the list (and to MacRuby!), so I give my
> >> apologies in advance for any newbie indiscretions.
> >>
> >> I was working today with MacRuby as a scripting language within a
> >> Cocoa app, and found a difference between how Ruby and MacRuby's eval
> >> functions relate to their calling context.
> >>
> >> Here's a reduction:
> >>
> >> % irb --version
> >> irb 0.9.5(05/04/13)
> >>
> >> % irb
> >> >> eval("f = 12")
> >> => 12
> >> >> f
> >> => 12
> >>
> >> % macirb --version
> >> DietRB (0.6.1)
> >>
> >> % macirb
> >> irb(main):001:0> eval("f = 12")
> >> => 12
> >> irb(main):002:0> f
> >> NameError: undefined local variable or method `f' for main:TopLevel
> >>
> >>
> >> I'm sure I'm missing something super basic. I followed a number of
> >> false leads in trying to figure this out before emailing the list,
> >> including checking out the $SAFE global (0 in both cases), and
> >> constructing Bindings to the calling context (same result).
> >>
> >> Thanks in advance for your patience and your help!
> >>
> >> Best,
> >> Braxton Sherouse
> >> ___
> >> MacRuby-devel mailing list
> >> [email protected]
> >> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
> >
> >
> >
> > ___
> > MacRuby-devel mailing list
> > [email protected]
> > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
> >
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel