>>>>> "BL" == Bart Lateur <[EMAIL PROTECTED]> writes:

  BL> On Thu, 07 Sep 2006 03:29:02 -0400, Uri Guttman wrote:
  >> this line of my code grew to its present form which i find amusing. 
  >> 
  >> @{$self->{templates}}{ keys %{$tmpls} } =
  >> map ref $_ eq 'SCALAR' ? \"${$_}" : \"$_", values %{$tmpls} ;
  >> 
  >> discuss amongst yourselves. topics include: what does it do? wtf am i
  >> doing that? and general esthetics.

  BL> It makes a ref to a (stringified) copy of every scalar, or dereferenced
  BL> scalar ref.

1 point for that!

  BL> Why would anyone take a copy instead of using an alias? Well, duh! To
  BL> make it safe to modify without touching the original, of course. Why you
  BL> are storing references instead of the string values, I don't know. It
  BL> won't save space.

it saves copying around between methods and such. loading a template
from a file is done with file::slurp returning a scalar ref. and the
template cache lookup is done via another method which also wants to
return a ref. i could store the cached templates as plain scalars but i
went this way (for at least today! :). internally scalar refs are passed
around and only copies are made when they will be modified. and since
the templates can be passed in as scalar refs, i wanted to make sure the
cached templates are not modifiable from the outside, hence the copying
in that line of code.

  BL> BTW I assume this module is the subject of the slides at
  BL> <http://www.sysarch.com/tiny_template/slides/index.html>, no?

yep. that also has the original 42 line hack version of this module.

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org

Reply via email to