[Laszlo-dev] Syntactic sugar

P T Withington ptw at pobox.com
Wed Dec 3 15:10:40 PST 2008


We could have the shortcut name be `$et` or something, to make it less  
likely to collide.

Don should comment on how hard it might be to add your `set v.a`  
proposal.  If we did something like that, we ought to spend some time  
thinking about how we might put the other half of constraints into a  
JS-like syntax, something like:

   bind v.a = ....;


On 2008-12-03, at 15:27EST, André Bargull wrote:

> If we had (native) setters in all runtimes, things would be much  
> easier. I've you add an alias for "setAttribute", I'd like to remind  
> you on the current limitation of the "setAttribute" inline compiler:
>> // FIXME: [2002-12-03 ptw] This substitution is not correct
>> // because it does not verify that the method being inlined is
>> // actually LzNode.setAttribute.
> So any new alias (let's say "set(..)") will be restricted to the  
> same limitation.
>
> And there is another issue which comes to my mind: in my opinion,  
> it's not only the longer method name ("setAttribute" instead of  
> "setX"), but also the whole function call with attribute-name in  
> quotes + value. Just as an idea, what about adding a new syntax? (I  
> do know adding a non-ECMAScript syntax may be harmful..)
> For example to set the "x"-attribute to "10" on a view "v":
> set v.x = 10;
>
>
>
>
>> I'd like to replace:
>>
>>   v.setAttribute('x', ...);
>>
>> with:
>>
>>   v.x = ...;
>>
>> someday.  Having an alias `set` for `setAttribute` would be a fine   
>> interim step.
>>
>> On 2008-12-03, at 00:45EST, Max Carlson wrote:
>>
>> >/ I've had a number of developers tell me they miss the shorthand  
>> of  />/ setX(...) - 4.2 now requires setAttribute('x', ...).  This  
>> is good  />/ for consistency, but it's bad for backward  
>> compatibility and makes  />/ code more verbose.   
>> setAttribute('foo', ...) requires a lot of extra  />/ typing...
>> />/
>> />/ What do you think about having the compiler expand the old setX/ 
>> Y()  />/ methods into the corresponding setAttribute('x/y')?  We  
>> could add a  />/ terse alias for setAttribute() - set(), or maybe  
>> s()...
>> />/
>> />/ Thoughts?
>> />/ -- />/ Regards,
>> />/ Max Carlson
>> />/ OpenLaszlo.org
>> /




More information about the Laszlo-dev mailing list