"the" issues & variables vs. properties

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderator: Klaus

Post Reply
TheSHEEEP
Posts: 8
Joined: Mon Jun 03, 2013 10:13 am

"the" issues & variables vs. properties

Post by TheSHEEEP » Mon Jun 03, 2013 3:56 pm

I find the current setup to be very inconsistent and very confusing, especially to new users.

For example, you can write:

Code: Select all

get text of field "field1"
put it into field "field2"
No problem, everything works.

But you could also write:

Code: Select all

get the text of the field "field1"
put it into the field "field2"
Again, fully legal.
You end up with the impression that "the" is purely optional, for properties as well as anything else.

But suddenly, when dealing with custom properties, things go wrong when not using "the".

Code: Select all

switch distance of me -- won't work without giving an error
....
switch the distance of me -- works
Now, why should there be any difference between "X of" and "the X of"? It's not like there could be many "X of", and even if, which one would "the" specify?

And this is only the first case I encountered. Maybe there are even situations in which something only works without a "the"?

And there's more.
Variables - why distinguish between variables and properties, btw? They are the same in far more complex languages - cannot have a "the" written in front of them.
So you cannot write...

Code: Select all

put the thingVar into field "field1"
... if thingVar is a variable. At least this time, you get a proper error in the IDE.
Again, why? To be able to distinguish between variables and properties by how they are used?
The "of" already does that. Cannot have a "variable of object", correct?
And the "the" is optional even for properties (except custom properties where they are required).

In both the required and the will-break-if-used case, it seems like a very arbitrary decision was made concerning the usage of "the".

The biggest problem is that I'll use LiveCode for a programming course, and I will have a pretty hard time explaining when to use "the" and when not.
It certainly won't work without explaining the difference between variables and properties, which is a difference I really don't get.
I mean, I get how they behave differently and what you can do with properties what you can't with variables, etc.
But what I don't get is why there even are properties. It's like a second type of variables the language could easily live without. At least if variables could do everything a property can do right now.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: "the" issues & variables vs. properties

Post by FourthWorld » Mon Jun 03, 2013 4:02 pm

The occasional allowance of omitting the "the" from property accesses is a holdover from the original HyperTalk. If we teach newcomers to always use "the" when accessing properties they'll have a much better time.

Personally, I wouldn't mind if such exceptions were deprecated, but there are likely some older stacks relying on such anomalies so perhaps better to just not teach alternatives and let the old folks be. :)
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

TheSHEEEP
Posts: 8
Joined: Mon Jun 03, 2013 10:13 am

Re: "the" issues & variables vs. properties

Post by TheSHEEEP » Mon Jun 03, 2013 4:08 pm

I agree, but then it would be great to remove that "legacy" at least from the tutorials and official ressources. A bit on the active side of "letting it die" ;)

Also, about the variables vs. properties thing:
When would you ever require to use a variable and not a property?
Except temporary variables (function scope), of course (which could just be called local properties).

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: "the" issues & variables vs. properties

Post by dunbarx » Mon Jun 03, 2013 5:57 pm

Hi.

Interesting points that you make. They do act sort of the same, and CP's are available like a global, which is nice, and are saved with the app, which is nicer. However, variables are much faster than custom properties:

on mouseUp -- takes 230-odd ticks
set the cpTimer of me to "aa"
put the ticks into tTime
repeat 1000000
get the cpTimer of me
end repeat
answer the ticks - tTime
end mouseUp

on mouseUp --takes 18 ticks
put "aa" into temp
put the ticks into tTime
repeat 1000000
get temp
end repeat
answer the ticks - tTime
end mouseUp

Craig Newman

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: "the" issues & variables vs. properties

Post by FourthWorld » Mon Jun 03, 2013 6:12 pm

TheSHEEEP wrote:Also, about the variables vs. properties thing:
When would you ever require to use a variable and not a property?
Except temporary variables (function scope), of course (which could just be called local properties).
Some folks use properties for all sorts of things, but for myself I generally only use them when I need them attached to an object or when I need persistence.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

TheSHEEEP
Posts: 8
Joined: Mon Jun 03, 2013 10:13 am

Re: "the" issues & variables vs. properties

Post by TheSHEEEP » Mon Jun 03, 2013 7:36 pm

Ahh, the speed argument is a very valid one, I was not aware of that (and it is not noted anywhere I came across ;) ).

Post Reply