I am trying to use -->
operator with highest precedence
Unprotect[LongRightArrow];
LongRightArrow[obj_,property_]:=obj[ToString[property]];
Protect[LongRightArrow];
With this I can do basic operations like accessing properties of an association
In:= obj = <|"a" -> {2, 3}, "b" -> 5|>
Out:= <|"a" -> {2, 3}, "b" -> 5|>
In:= obj⟶a
Out:= {2, 3}
However when I try to access elements of list in obj-->a
Part
takes higher precedence. Same applies for operator ^
.
In:= obj⟶a[[1]]
Out:= Missing["KeyAbsent", "a[[1]]"]
In:= obj⟶a^2
Out:= Missing["KeyAbsent", "2 a"]
LongRightArrow
doesn't have any built in precedence, according to reference.wolfram.com/language/tutorial/OperatorInputForms.html. You might be able to use reference.wolfram.com/language/ref/PrecedenceForm.html $\endgroup$obj-->Part[a,1]
do? $\endgroup$obj-->a[[1]]
to be interpreted asPart[obj-->a,1]
and notobj-->Part[a,1]
? Or do you actually wantobj-->Part[a,1]
to give2
? @george2079 I think if he is talking about precedence he means the first. $\endgroup$