--Apple-Mail-4--455575283 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On 15 Mar 2005, at 21:23, Stefan Kaes wrote: > Eric Hodel wrote: > >> Ok, I lied. ERB::DefMethod is both not used by Rails (does something >> else) but it is also unsuitable for the task. >> > Why did you lie??? I didn't bother to double-check first. My bad. >> Anyhow, as my penance, here's my implementation, I did use >> def_method, though: >> >> http://segment7.net/projects/ruby/snippets/erb_cache.rb >> > Thanks for the code, but I already knew this would also be a possible > solution. But probably less efficient than using instance variables, > though I have not checked that yet. Did you? attr* methods are optimized for speed so you don't have all the overhead of a regular method call, but I doubt this will be faster than ivars. An ivar implementation would be pretty easy too, use instance_variable_set instead of send. Here's how Ruby optimizes attr* methods: $ parse_tree_show class Example attr_reader :x def y() @y; end end [[:class, :Example, :Object, [:defn, :x, [:ivar, :@x]], [:defn, :y, [:scope, [:block, [:args], [:ivar, :@y]]]]]] No scope setup is done for attr*. -- Eric Hodel - drbrain / segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 --Apple-Mail-4--455575283 content-type: application/pgp-signature; x-mac-type=70674453; name P.sig content-description: This is a digitally signed message part content-disposition: inline; filename=PGP.sig content-transfer-encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (Darwin) iD8DBQFCOHKbMypVHHlsnwQRAmJCAJ4oiwEylvrmGisLFcgO418Y1FZnVgCfQoo7 m0X3hNlnq4YO4L7nnKMLHiQ ic -----END PGP SIGNATURE----- --Apple-Mail-4--455575283--