[laszlo-reviews -> laszlo-dev:  this affects all devs, not just reviewers]

Here's the history:

When you made mixins work for anonymous (instance) classes, I realized that the 
`tagname` property of those classes is really a lie.  Those anonymous classes 
do not represent <class> definitions, so they do not have a corresponding tag 
that you can look up in `lz` to instantiate them.  The upshot is, the compiler 
no longer emits a `tagname` property on these classes (and no longer makes 
bogus entries in `lz`).

The list code (and elswhere) uses the idiom `constructor.tagname` to try to 
capture the class (constructor) of its items (for replication) by looking at 
its child and asking (eventually):

  itemclass = lz[child.constructor.tagname]

For anonymous (instance) classes, this only worked by accident in the past (due 
to a collusion of bugs, not because of a documented API).  If anyone tried to 
use an instance mixin, it would fail similarly.

But, this code is really going around its elbow to get to its nose since, for 
all instances that are _not_ anonymous:

  lz[foo.constructor.tagname] === foo.constructor

you can simplify (and make your code correct) by saying:

  itemclass = child.constructor

That will always compute the class (constructor) of _any_ instance, and can be 
used for replicating.

---

Because `constructor.tagname` is an idiom that people have used, I think we 
should have a release note (and/or a column in the OL <view>) explaining all 
this, and we should update the documentation for `tagname` to indicate that it 
will only be valid for constructors that are defined by <class>, and not for 
anonymous constructors created by instance classes (instances with methods, 
handlers, mixins, etc.)



On 2010-01-05, at 22:10, Henry Minsky wrote:

> What was the reason that we wanted to make this change?
> 
> 
> On Tue, Jan 5, 2010 at 8:59 PM, Max Carlson <[email protected]> wrote:
> 
>> Change 20100105-maxcarlson-T by maxcarl...@bank on 2010-01-05 14:09:06 PST
>>   in /Users/maxcarlson/openlaszlo/trunk-clean
>>   for http://svn.openlaszlo.org/openlaszlo/trunk
>> 
>> Summary: UPDATED AGAIN: Fix lz/list.lzx to use correct methods for
>> instantiating new items
>> 
>> Bugs Fixed: LPP-6002 - lztextlistitem warning/errors of undefined
>> properties (title, height, setAttribute), LPP-8690 - Update components to
>> use class references directly instead of tagnames (partial)
>> 
>> Technical Reviewer: ptw
>> QA Reviewer: hminsky
>> 
>> Details: This has turned into a pretty hairy API-breaking change fairly
>> quickly...  Perhaps we should rethink correcting tagname?
>> 
>> Rename *classname to *class.  *class attribute now contains a reference to
>> the class that should be created dynamically.  Directly instantiate classes,
>> instead of looking up by tagname first.
>> 
>> Tests: Testcase from LPP-6002 no longer warns, component_sampler.lzx
>> continues to work.  lzunit-basedatacombobox.lzx runs as before.
>> 
>> Files:
>> M       test/components/base/lzunit-basedatacombobox.lzx
>> M       lps/components/lz/tabslider.lzx
>> M       lps/components/lz/radio.lzx
>> M       lps/components/lz/list.lzx
>> M       lps/components/lz/tabs.lzx
>> M       lps/components/base/basetabelement.lzx
>> M       lps/components/base/basecombobox.lzx
>> M       lps/components/base/basetabslider.lzx
>> M       lps/components/base/baselist.lzx
>> M       lps/components/base/basetabs.lzx
>> M       lps/components/base/basedatacombobox.lzx
>> 
>> Changeset:
>> http://svn.openlaszlo.org/openlaszlo/patches/20100105-maxcarlson-T.tar
>> 
> 
> 
> 
> -- 
> Henry Minsky
> Software Architect
> [email protected]
> _______________________________________________
> Laszlo-reviews mailing list
> [email protected]
> http://www.openlaszlo.org/mailman/listinfo/laszlo-reviews


Reply via email to