17 Feb 2009, 07:37
Generic-user-small

John Morrison (2 posts)

Perhaps I’m getting something wrong, but this just seems like a ruby 1.9 issue, and the example is not supported for the call to super. Appears that the call super now needs to be super(*args), which works for this simple example, but I have no idea if it’s the correct thing to do.

[myhost]# ruby --version
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]

[myhost]# ruby 05_generate_ghost_class.rb.orig
05_generate_ghost_class.rb.orig:22:in `block (2 levels) in memoize': implicit argument passing of super from method defined by define_method() is not supported. Specify all arguments explicitly. (RuntimeError)
        from 05_generate_ghost_class.rb.orig:31:in `<main>'

[myhost]# ruby 05_generate_ghost_class.rb
Expensive calculation for [1, 2, 3]
6
6
Expensive calculation for [2, 3, 4]
9
9

[myhost]# diff -u 05_generate_ghost_class.rb.orig 05_generate_ghost_class.rb
--- 05_generate_ghost_class.rb.orig     2008-11-21 09:44:29.000000000 -0500
+++ 05_generate_ghost_class.rb  2009-02-17 02:09:44.000000000 -0500
@@ -19,7 +19,7 @@
       if memory.has_key?(args)
         memory[args]
       else
-        memory[args] = super
+        memory[args] = super(*args)
       end
     end
   end
17 Feb 2009, 08:27
Generic-user-small

John Morrison (2 posts)

same pattern applies in 03_generated_subclass.rb (oops, missed that one).

  You must be logged in to comment