[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: "with" statement in Lua?
- From: Dave Bollinger <DBollinger@...>
- Date: Tue, 13 Jul 1999 21:26:41 -0400
>> Which of the three a,v,w are global?
I knew I was overlooking something, creation, and I see how it would be
impossible to determine if the coder intended to create a new variable in
the table or globally. I was approaching it thinking about fields that had
PREVIOUSLY been created in t, only those would have been table fields, the
others would've had to been assumed to be global, but that just doesn't
work if creating NEW fields in t.)
>> with t do
Understood. This is similar to the syntax that Visual Basic uses, where
the "." is more stringently required as an accessor to the object, and
would be easier to establish context within. In that case ".w" and ".v"
would be members of t, "a" would not. (to access a field named "a" in t
within that with statement, you'd have to call it ".a")
>> (which is ambiguous because it conflict with w=a.v)
In that case, plain "w" would not be a member of t, nor would "a.v".
They'd have to be specified as ".w" or ".a.v" to be members of t. "w=av"
inside a with (if it were to require the . accessor as VB does) should work
exactly the same as if no with statement were present.
>> Plus, if you're writing .w, why not write t.w?
Laziness? ;-) It might save you from having to create your own alias
objects when you have a deeply nested "tables-within-tables-within-tables"
setup, but I agree that it's almost too trivial to consider. I just wanted
to toss the idea into the mix again. Since it wouldn't really DO anything,
even if it were possible, I certainly don't have a literal NEED for it.