[Tip] Propeties & sets & List of 'reserved words' and gotchas

Trevor DeVore lists at mangomultimedia.com
Mon Feb 20 22:05:05 EST 2006


On Feb 20, 2006, at 5:27 PM, J. Landman Gay wrote:
>
> Regardless of the above, you couldn't say a truer thing. Reserved  
> words shouldn't be used for variable names.

Jacque,

I'm going to respectfully disagree on this one in that I haven't  
found any problems with using reserved words as keys of custom  
property sets.  Here is why -

I use custom properties quite a bit in order to link objects to  
libraries.  At first I did everything like this:

set the uLibPrefix["uName"] of myObject to "something"

But then I realized that
1) It is less readable to me then uLibPrefix["Name"] and
2) It doesn't matter because I am always using array notation with  
custom property sets.  In all of my tests it appears that using array  
notation protects you from naming problems.

So I anything custom property that is in the default (empty) set is  
prefixed with a "u" while any custom property residing in a custom  
property set has no prefix and is always referenced through array  
notation.  I also prefix any custom property sets with "u".

The fact that array notation protects you from naming collisions is  
great because it means you can easily transfer arrays to custom  
property sets and back to arrays without having to worry about the  
key values.  I use this feature in my standard data storage library  
and it works really well.  So unless Rev comes out and says that in  
the future using reserved words in array notation will cause my app  
to implode I find it a very useful approach.


-- 
Trevor DeVore
Blue Mango Multimedia
trevor at mangomultimedia.com





More information about the use-livecode mailing list