General
Dot notation for object attributes
Started by dBlicious on .
Sign in or create an account to join the conversation.
Got my Lemur app about a week ago and am diving headfirst into scripting. Most of my programming experience is with javascript, so I want to make my scripting more object oriented. One of the first things I noticed is the cumbersome way to get and set object attributes. Fortunately it wasn't too difficult to fix this. With a little scripting I can do this:
-A
MultiSlider.nbr = 16;
x = MultiSlider.nbr;
instead of this:
setattribute(MultiSlider, 'nbr', 16);
x = getattribute(Multislider, 'nbr');
I was thinking of making custom modules for all the objects and their attributes. Before I start, has anyone already done this and wouldn't mind sharing their work? If not, would anyone else find it useful?-A
I think you found a good method. I am using both, but still not sure when to use which. Sometimes you can use the '=', sometimes you have to use the set/getattribute().
One year of experience (me), and still unsure about fundamental things.
One year of experience (me), and still unsure about fundamental things.
Hi
Yes you can make attibutes act like variables - I do similar stuff sometimes with modules to expose vars at a higher level . . .
Though, I would suggest learning a bit more about Lemur scripting before over-riding basic syntax - you may find issues with your approach later on. . .
Dot.notation applies to variables - get/setattribute applies to attributes . . .
MM
Yes you can make attibutes act like variables - I do similar stuff sometimes with modules to expose vars at a higher level . . .
Though, I would suggest learning a bit more about Lemur scripting before over-riding basic syntax - you may find issues with your approach later on. . .
Dot.notation applies to variables - get/setattribute applies to attributes . . .
MM
thanks for clarifying.
But a dot.notation is the same as an object expression? Not quite, isn't it? It's not on the same 'level'?
But a dot.notation is the same as an object expression? Not quite, isn't it? It's not on the same 'level'?
MM, can you think of any possible issues to be aware of? Aside from the tedium of implementing it?Macciza wrote: Though, I would suggest learning a bit more about Lemur scripting before over-riding basic syntax - you may find issues with your approach later on. . .
MM
Hi
Hard to say without seeing what you're doing . ..
But there will be bloat if you add it to everything and use a lot of objects etc
It may may it difficult to understand standard Lemur programming as you wont have learnt it . .
Others may find your Projects difficult to understand or use bits of due to your over-riding . . .
Somethings that are standard practice may give unexpected results
Send in an example of how you might approach it
And run comprehensive tests to evaluate that things do work . . .
Usually attributes are not used as much or in the same way as object variables so it is hard to say how much actual advantage you may gain
I can see that it nmay be handy in certain instances but feel it is probably best on a per case basis for certain attributes of certain objects rather than open slather . . .
Cheers
MM
Hard to say without seeing what you're doing . ..
But there will be bloat if you add it to everything and use a lot of objects etc
It may may it difficult to understand standard Lemur programming as you wont have learnt it . .
Others may find your Projects difficult to understand or use bits of due to your over-riding . . .
Somethings that are standard practice may give unexpected results
Send in an example of how you might approach it
And run comprehensive tests to evaluate that things do work . . .
Usually attributes are not used as much or in the same way as object variables so it is hard to say how much actual advantage you may gain
I can see that it nmay be handy in certain instances but feel it is probably best on a per case basis for certain attributes of certain objects rather than open slather . . .
Cheers
MM