Re: Objects - preview of upcoming changes
Posted: 06 May 2019, 17:08
I have updated the script to utilize the __Item property added in v2.0-a101.
The x.Item[y] properties are removed. Use x[y] instead. When the script performs recursion into a property, such as with obj.prop[y] or arr[x, y], it now uses v[y] instead of v.Item[y]. To handle this in custom objects, override __Item rather than Item.
Do not use x[y] to access properties or methods. Use x.%y% instead.
__Item (added in v2.0-a101) is not intended to be invoked directly, and I felt that Item was too common a name to reserve. By contrast, the Item property in previous versions of this script had to be invoked directly, so I left out the underscores.
@Helgef I think I've demonstrated that any decision I make during the (very long) alpha stage is not necessarily final. At this point, it made much more sense to extend the %expr% syntax than to add something new or overload something that had a different meaning before. I also figured that it will be used considerably less often than the indexing operator [].
I do not like <fn>(), and would not even if it was not ambiguous. a <b>(c) is a valid but strange way to use the comparison operators. (If the parser was more flexible, I would perhaps interpret it as a < b && b > c, and a < b < c would be a < b && b < c.)
(obj[expr])() would mean obj[expr].Call(), as the context of "invoking obj" is limited to inside the parentheses. obj[expr]() is still unambiguous (and allowed in the current build), but I thought it best for properties and methods to be consistent. If () is allowed as the call operator on any expression, obj[expr]() should probably also mean obj[expr].Call() (or perhaps obj[expr].Call(obj) if the () binds more closely to the previous operator).
The x.Item[y] properties are removed. Use x[y] instead. When the script performs recursion into a property, such as with obj.prop[y] or arr[x, y], it now uses v[y] instead of v.Item[y]. To handle this in custom objects, override __Item rather than Item.
Do not use x[y] to access properties or methods. Use x.%y% instead.
__Item (added in v2.0-a101) is not intended to be invoked directly, and I felt that Item was too common a name to reserve. By contrast, the Item property in previous versions of this script had to be invoked directly, so I left out the underscores.
@Helgef I think I've demonstrated that any decision I make during the (very long) alpha stage is not necessarily final. At this point, it made much more sense to extend the %expr% syntax than to add something new or overload something that had a different meaning before. I also figured that it will be used considerably less often than the indexing operator [].
I do not like <fn>(), and would not even if it was not ambiguous. a <b>(c) is a valid but strange way to use the comparison operators. (If the parser was more flexible, I would perhaps interpret it as a < b && b > c, and a < b < c would be a < b && b < c.)
(obj[expr])() would mean obj[expr].Call(), as the context of "invoking obj" is limited to inside the parentheses. obj[expr]() is still unambiguous (and allowed in the current build), but I thought it best for properties and methods to be consistent. If () is allowed as the call operator on any expression, obj[expr]() should probably also mean obj[expr].Call() (or perhaps obj[expr].Call(obj) if the () binds more closely to the previous operator).