Dot notation for object attributes

Discuss Lemur and share techniques.
Post Reply
dBlicious
Newbie
Posts: 25
Joined: 12 Jan 2013 06:49

Dot notation for object attributes

Post by dBlicious »

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:

Code: Select all

MultiSlider.nbr = 16;
x = MultiSlider.nbr;
instead of this:

Code: Select all

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
Phil999
Regular
Posts: 919
Joined: 11 Jan 2012 01:53

Re: Dot notation for object attributes

Post by Phil999 »

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. :)
Formant+Eurorack, PPG wave 2.2, Korg MS-20, etc., EWI 4000s, QuNeo, etc., Mixbus32c, u-he, MadronaLabs, Samplemodeling, NI, etc., iPad2/4/Pro
Macciza
Regular
Posts: 1315
Joined: 07 Dec 2011 04:57
Location: Sydney, Australia.

Re: Dot notation for object attributes

Post by Macciza »

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
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Phil999
Regular
Posts: 919
Joined: 11 Jan 2012 01:53

Re: Dot notation for object attributes

Post by Phil999 »

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'?
Formant+Eurorack, PPG wave 2.2, Korg MS-20, etc., EWI 4000s, QuNeo, etc., Mixbus32c, u-he, MadronaLabs, Samplemodeling, NI, etc., iPad2/4/Pro
dBlicious
Newbie
Posts: 25
Joined: 12 Jan 2013 06:49

Re: Dot notation for object attributes

Post by dBlicious »

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
MM, can you think of any possible issues to be aware of? Aside from the tedium of implementing it? :D The big problem I see is changing an attribute directly after the referencing expression is initialized. I think that should easily be avoided if I'm not careless, but I might be overlooking something due to my lack of experience. I can see the possibility of painting myself into a corner. I guess it's safest to start off small and see how that goes.
Macciza
Regular
Posts: 1315
Joined: 07 Dec 2011 04:57
Location: Sydney, Australia.

Re: Dot notation for object attributes

Post by Macciza »

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
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Post Reply