Hey Howard et. al.
I was thinking about the var prefix in loops which allow for
scalars to be held without having to create a property on the
component. I was wondering about an alternative. I recognize that
this mechanism doesn't use reflection, so cannot dynamically determine
the type of the object, hence the limitation. But I wonder if a
simple syntax change to allow type declaration would be suitable, such
that the component could determine type at compile time. What I'm
thinking would look something like:
<ol t:type="loop" t:source="listItems" t:value="${var:
(com.foo.bar.blah.MyObject)listItem}">
<li>${var:listItem.name}</li>
</ol>
In other words, it would explicitly provide a cast-like syntax to
allow the bytecode manipulation to be instructed with the type. Now,
I'm not 100% sure I think this is better than adding a single
@Property private MyObject listItem in the code, but because this is
truly a local variable for this iteration, it seems like having an
instance variable is not appropriate for the purpose. Also, I'm not
sure about whether such instance variables end up on the heap, since
they aren't created and destroyed on the call stack as are local
variables. (Mind you, I'm not clear on how the bytecode is
manipulated, so it could be that your pre-processing just creates an
instance variable and it's all the same.) I admit part of this is an
aesthetic choice, and I'm having real problems deciding which is more
appropriate.
It would be nice if you could get any type information from listItems,
but Java's generics are meaningless out at runtime, and even then,
it'd be runtime, not compile-time information you got back, so we're
back to reflection. God I miss informal protocols and selector-based
messaging in Objective-C... <sigh> If only Javasoft had listened when
all us NeXTSTEPers bitched and complained about its absence...
Anyway, I'm just putting it out there for comment. Essentially
extending the var: binding's format with optional cast-alike syntax.
cheers,
Christian.
Christian E. Gruber - President / Senior Consultant
Isráfíl Consulting Services Corporation
email: [email protected]
mobile: +1 (289) 221-9839
web: http://www.israfil.net/
"...keenness of understanding is due to keenness of vision."
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]