20170201225639 wrote: ↑15 Oct 2021, 18:26
Isn't there a sense in which the Obj.Prop notation is merely
shorthand for the more "canonical" and strictly correct notation Obj["Prop"] that arguably more accurately reflects how AHK interprets the statement under the wraps? [1]
Not in v2.
Then if everyone is forced to always use Obj["Property"] rather than Obj.Property, then one source of misconception could be entirely eliminated.
Doubtful.
.Property is already different to
Variable.
Even if a
class static variable was a
variable, it would still be scoped to the object, not the function or the script.
Consider, for example, the issue in v1 about passing Obj.Property ByRef to a function.
Consider that this is v2, and no (breaking) changes will ever be made to v1 syntax. In v2, passing of variables by reference must be explicit. If you attempt to pass
&obj.Prop in v2.0-beta.2, you will get an immediate load time error drawing attention to the problem; in future it may simply work.
Then it'd be immediately clear that they'd be passing the result of evaluating an expression
I disagree. I do not believe it is so easy for a new user to grasp what is or is not an expression, what that expression returns, or that they would even think to make these distinctions. In
f(x := y), you are passing the result of evaluating a sub-expression, but that result is itself a variable.
Array%n% is a variable disguising as an expression
False (and I think that supports my previous point).
Array%n% is an expression (in the general sense) which evaluates to a variable reference.
Array1 would be a variable.
n is a variable.
Array is a string. The expression concatenates "Array" with
n and returns the variable with that name.
The important thing in v1 is that
Array%n% and
x := y and
++x evaluate to the
variable, not just its value.
[1] What I mean is, presumably variable names only exist in the source code, but property names are real strings that exist at runtime.
No. For
Array%n%, Array1 may or may not exist in the source code and/or at runtime. For
obj.Prop, Prop clearly exists in the source code. For
x := y, both x and y exist in the source code and at runtime. How would a double-deref work if the name didn't exist at runtime?
For example, if I go through my source code, and change all occurrence of "for index, element ..." to "for indeeeeeeeeex, element", the compiled executable shouldn't differ in size at all
"Compiling" a script is just packaging it with the interpreter in a single file. The "compiled executable" contains all of your original variable names.
... so some of what I said is moot, but I imagine it would hold true for compiled languages.
Keep in mind that your comments were supposed to support your assumptions about "how AHK interprets the statement under the wraps".