>>>>> "AA" == Alex Aminoff <a...@basespace.net> writes:

  AA> On Tue, 25 May 2010, Kenneth Graves wrote:

  >> In the simple case (known methods/no side effects), then one of Uri's 
solutions will work.
  >> 
  >> For the case of unknown methods, a two pass solution might work: collect 
the method names from the template, then call them with $object->$method() 
syntax, then interpolate the results.

  AA> Unfortunately, unless the perl compiler can magically delay execution
  AA> in some way, you then end up calling every single method to get its
  AA> value, even if you only need a couple of them. These objects have over
  AA> 100 methods. Also, some of the methods might have side effects, like
  -> delete.

that makes no sense. you only call the ones you know you need and store
the results in a hash. again, you are saying things which have
assumptions or knowledge about your needs which aren't clear. back up a
bit and show how you want to use this thing. show method calls and where
you want to interpolate them. 

  AA> It looks like TT has a perl-like interpolation mode so you can use
  AA> $var instead of [%var%]. It looks like it would work if I iterate over
  AA> my namespace as I did before to construct the variables hash for TT,
  AA> with a bunch of

  AA>  $symbol => sub { $object->$symbol() }

  AA> that does get away from the eval and the tied scalar, thanks.

and slows you down even more as you have an extra sub call for each
method. also in that line you are destroying the method name with the
result of the call.

  >> TT is big, so make sure this isn't a case of using a bazooka to swat a fly.

  AA> Fair point. If it works it will be worth it.

TT is not needed for this. not at all.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

_______________________________________________
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to