[Laszlo-dev] Is this the idiom people use to set the initial value of an attribute in a class declaration?

Henry Minsky henry.minsky at gmail.com
Sun Jul 8 19:25:12 PDT 2007


I've been hacking on an app this week, and realizing it's been awhile since
I tried
to actually program anything in Laszlo.

There's this huge "gotcha" when setting the initial value of attributes to
an object in a class
declaration, like this


<class name="foo">
  <attribute name="pets" value="[]"/>

Which screws you since that object will now be shared among all instances.

The idiom I think I remember people using is

<class name="foo">
  <attribute name="pets" value="$once{[]}"/>

Or more readably

<class name="foo">
  <attribute name="pets" value="$once{new Array()}"/>

Is that what we recommend to do now? I guess we going to quietly fix this
issue if and when we get
our node initialization rewritten as a compile-time-generated initializer
function?


-- 
Henry Minsky
Software Architect
hminsky at laszlosystems.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.openlaszlo.org/pipermail/laszlo-dev/attachments/20070708/85b45f9c/attachment.html


More information about the Laszlo-dev mailing list