Fwd: Prototype (the real thing from Ara) problem

Hi list

after my primitive research and my very slow implementation of
Prototypes I thought it would be a good idea to check out the real
thing and to link to it from my blog, turns out I cannot run it :(.
I got the same problem on Linux as on Windows with a Gem install 1.8.6
pl 0,
502/2 > irb
irb(main):001:0> require ‘rubygems’
=> true
irb(main):002:0> require ‘prototype’
=> true
irb(main):003:0> p = Prototype.new{
irb(main):004:1* @a = 42
irb(main):005:1> }
NameError: @==' is not allowed as an instance variable name from /usr/local/lib/ruby/gems/1.8/gems/prototype-2.0.0/lib/prototype.rb:122:ininstance_variable_set’
from
/usr/local/lib/ruby/gems/1.8/gems/prototype-2.0.0/lib/prototype.rb:122:in
call' from /usr/local/lib/ruby/gems/1.8/gems/prototype-2.0.0/lib/prototype.rb:122:incall
from
/usr/local/lib/ruby/gems/1.8/gems/prototype-2.0.0/lib/prototype.rb:151:in
method_missing' from /usr/local/lib/ruby/gems/1.8/gems/attributes-3.5.0/lib/attributes.rb:55:inattribute_list’
from
/usr/local/lib/ruby/gems/1.8/gems/attributes-3.5.0/lib/attributes.rb:58:in
__attribute_list__' from /usr/local/lib/ruby/gems/1.8/gems/attributes-3.5.0/lib/attributes.rb:58:inattributes’
from
/usr/local/lib/ruby/gems/1.8/gems/attributes-3.5.0/lib/attributes.rb:41:in
attributes' from /usr/local/lib/ruby/gems/1.8/gems/attributes-3.5.0/lib/attributes.rb:15:ineach’
from
/usr/local/lib/ruby/gems/1.8/gems/attributes-3.5.0/lib/attributes.rb:15:in
attributes' from /usr/local/lib/ruby/gems/1.8/gems/prototype-2.0.0/lib/prototype.rb:122:incall’
from
/usr/local/lib/ruby/gems/1.8/gems/prototype-2.0.0/lib/prototype.rb:122:in
__call__' from /usr/local/lib/ruby/gems/1.8/gems/prototype-2.0.0/lib/prototype.rb:169:incontext’
from
/usr/local/lib/ruby/gems/1.8/gems/prototype-2.0.0/lib/prototype.rb:164:in
each' from /usr/local/lib/ruby/gems/1.8/gems/prototype-2.0.0/lib/prototype.rb:164:incontext’
from
/usr/local/lib/ruby/gems/1.8/gems/prototype-2.0.0/lib/prototype.rb:122:in
module_eval' from /usr/local/lib/ruby/gems/1.8/gems/prototype-2.0.0/lib/prototype.rb:122:incall’
from
/usr/local/lib/ruby/gems/1.8/gems/prototype-2.0.0/lib/prototype.rb:122:in
__call__' from /usr/local/lib/ruby/gems/1.8/gems/prototype-2.0.0/lib/prototype.rb:161:incontext’
from
/usr/local/lib/ruby/gems/1.8/gems/prototype-2.0.0/lib/prototype.rb:68:in
prototyping' from /usr/local/lib/ruby/gems/1.8/gems/prototype-2.0.0/lib/prototype.rb:41:innew’
from (irb):3irb(main):006:0>
irb(main):007:0*
irb(main):008:0*
irb(main):009:0* quit

It is not an irb issue tested with a source file too:(

Did I do something stupid?

Thx in advance
Robert

On 8/13/07, ara.t.howard [email protected] wrote:

On Aug 12, 2007, at 3:34 PM, Robert D. wrote:

Did I do something stupid?

i’ve broken it with the latest attributes release - i’ll fix soon…

gem locking a good idea? :slight_smile:

On Aug 12, 2007, at 3:34 PM, Robert D. wrote:

Did I do something stupid?

i’ve broken it with the latest attributes release - i’ll fix soon…

sorry!

a @ http://drawohara.com/

On Aug 12, 2007, at 3:34 PM, Robert D. wrote:

after my primitive research and my very slow implementation of
Prototypes …

btw - i’ve learned something since my initial implementation:

obj = Object.new.instance_eval do

@var = 42

def method
@var
end

self
end

i was quite suprised that it worked - it would be interesting to play
with that in the context of a prototype impl.

cheers.

a @ http://drawohara.com/

On Aug 13, 2007, at 13:05 , ara.t.howard wrote:

cheers.

a @ http://drawohara.com/

What does the self at the end accomplish?

~Wayne

s///g
Wayne E. Seguin
Sr. Systems Architect & Systems Administrator

Wayne E. Seguin wrote:

On Aug 13, 2007, at 13:05 , ara.t.howard wrote:

What does the self at the end accomplish?

It makes the block return the value of self (i.e. the newly created
object).
Otherwise the return value of the block would be nil (since def returns
nil)
and thus obj would be nil.

On 8/13/07, Wayne E. Seguin [email protected] wrote:

@var = 42

cheers.

a @ http://drawohara.com/

What does the self at the end accomplish?

it returns the object. See this example:

a = Object.new.instance_eval { 2 }
=> 2
a
=> 2

a = Object.new.instance_eval { self }
=> #Object:0x2c01d70

On Aug 13, 2007, at 13:17 , Sebastian H. wrote:

It makes the block return the value of self (i.e. the newly created
object).
Otherwise the return value of the block would be nil (since def
returns nil)
and thus obj would be nil.

Ok that was blatantly obvious.

Thank you.

~Wayne

s///g
Wayne E. Seguin
Sr. Systems Architect & Systems Administrator

On Aug 13, 2007, at 11:49 AM, Wayne E. Seguin wrote:

Ok that was blatantly obvious.

i wouldn’t say that - i bloody forgot it the first time making the
example! :wink:

a @ http://drawohara.com/

On 8/13/07, ara.t.howard [email protected] wrote:

@var = 42

def method
@var
end

self
end

That is hilarious, but it will put me back to where I was fleeing from,
irb(main):001:0> o = Object.new.instance_eval do
irb(main):002:1* @a = 222
irb(main):003:1> def x
irb(main):004:2> @a
irb(main):005:2> end
irb(main):006:1> self
irb(main):007:1> end
=> #<Object:0xb7d648c4 @a=222>
irb(main):008:0> o.x
=> 222
irb(main):014:0> o.extend Module::new {
irb(main):015:1* def x
irb(main):016:2> super.to_s << " is really " << @a.to_s(4)
irb(main):017:2> end
irb(main):018:1> }
=> #<Object:0xb7d648c4 @a=222>
irb(main):019:0> o.x
=> 222
================ of course you know about this :wink:

i was quite suprised that it worked - it would be interesting to play
with that in the context of a prototype impl.
yup much food for the brain, thx for sharing.

cheers.

a @ http://drawohara.com/

we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama

Robert