In R3-Alpha, Carl asked the question:
count: 0
++ count ; add one
-- count ; sub one
While it's cool that you can do this, I don't like it being in the box. Especially now that double dashes are principally used by strings.
Ren-C Has A Cooler Answer, Using Literal Left Infix
There are two interesting operators called ME and MY.
You put a SET-WORD (or SET-TUPLE) on their left. They take that infix literally. Then they use the value of that as the argument to whatever's on the right.
ME is used when you have an infix function on the right:
>> my-long-variable-name: 0
== 0
>> my-long-variable-name: me + 1
== 1
>> my-long-variable-name
== 1
Whereas MY is used when you have a prefix function on your right, and you want to inject the thing on the left as the first argument to it:
>> my-long-block-name: [a b c]
== [a b c]
>> my-long-block-name: my append [d e]
== [a b c [d e]]
>> my-long-block-name
== [a b c [d e]]
Literate, Generalized, and Easy To Implement
They use the INLINER facility.. (Ideally they would use MACRO, but since MACRO is being written on top of INLINER during its development that would be slower...)
me: infix inliner [
"Update variable using it as the left hand argument to an infix operator"
@left [set-word? set-tuple?]
@right [word! path! chain!]
][
spread reduce [left, unchain left, right]
]
my: infix inliner [
"Update variable using it as the first argument to a prefix operator"
@left [set-word? set-tuple?]
@right [word! path! chain!]
][
spread reduce [left, right, unchain left]
]
![]()