Tokens in object.notation

Question

I’d asked


object notation is something like
$name:=$o.Firstname
the key Firstname is not set in doublequotes. Hmh, that means Firstname is tokenized, or is it?

Will keys in OB SET($o;Firstname;“Vorname“) be tokenized too?

Answer

by Raphael Herouart


$name:=$o.Firstname

Will be tokenized into something like this:

[LocalVar][Assign][LocalVar][TokenMember]

So if it was your question „1“, yes first name in this case will be a separate token. In fact so is a quoted 4D string, which is a 4D [constante] token of type string…

Regarding your question 2. Lets take a detour.

Dot syntax should really be understood as a shortcut for
$name:=$o[„Firstname“]
Or
$name:=OB GET($o;“Firstname“)

This shortcut is available only when one can resolve any lexical (understand tokenization) ambiguity. Indeed, an object is only a key-value dictionary. The key is a string with very few constraints. Taking an extreme example:

$o[„value“]:=1
$o[„value+[Table_1]Num“]:=2//This is an absolutely valid object key!
[Table_1]Num:=3
Alert(String($o.value+[Table_1]Num))//Am I actually performing an addition or just requesting a key?

Most language accepting object notation, notably javascript put some restriction on which key can be used in these shortcuts. Check the „Object property identifiers“ paragraph.

this is why, when using ob set/get or bracket syntax, you’ll still have to use a string.
I hope I helped.