ENFIX vs. LOOKBACK

There was a very old useless thread discussing this (which I deleted for its uselessness), and I'll extract just the top-level question.

Today if you want to make an action take its first argument from the left, you say ENFIX:

>> add 1 2
== 3

>> /+: enfix get $add

>> 1 + 2
== 3

The reason it's ENFIX and not INFIX is because it can be used with functions of any arity. They get their first argument from the left, and everything else from the right.

>> /apd: enfix get $/append/dup

>> [a b c] apd [d e] 2
== [a b c [d e] [d e]

I picked ENFIX sort of based on the notion of N-Arity Infix. Choosing a made-up word for a concept that doesn't have any well-known precedent seemed as good as anything.

But What About Just "LOOKBACK" ?

In the interpreter internals I talk about what these functions do as being "lookback".

Is there any reason not to call them "lookback functions", so more like:

>> /apd: lookback get $/append/dup

>> [a b c] apd [d e] 2
== [a b c [d e] [d e]]

"ENFIX" sounds like more of a verb, which is something I like about it:

EN: a prefix occurring originally in loanwords from French and productive in English on this model, forming verbs with the general sense “to cause (a person or thing) to be in” the place, condition, or state named by the stem; more specifically, “to confine in or place on” (enshrine; enthrone; entomb); “to cause to be in” (enslave; entrust; enrich; encourage; endear); “to restrict” in the manner named by the stem, typically with the additional sense “on all sides, completely” (enwind; encircle; enclose; entwine). This prefix is also attached to verbs in order to make them transitive, or to give them a transitive marker if they are already transitive (enkindle; enliven; enshield; enface) via dictionary.com

When I've questioned the choice of ENFIX before, I've always come back to it. But maybe I've gotten too used to a term that's not that good? I dunno.

The term ‘enfix’ has always confused me somewhat. ‘Lookback’ makes much more sense to me.

(The issue with the derivation from ‘en-’ is that ‘to fix’ means something completely unrelated.)

2 Likes

The "keep it simple" option would be just to call it INFIX... with the caveat that if you use INFIX on a function that has more than two arguments, it'll just pick up the extra arguments normally.

>> either 1 = 1 [print "okay"] [print "not okay"]
okay

>> /?: infix get $either

>> (1 = 2) ? [print "okay"] [print "not okay"]
not okay

It can be argued there's still infixedness going on there. It's just between the first and second argument. What else would it do?

So why make up a word, if it's obvious enough what's going on?

And if your function has one argument, then it's infix with nothing. So postfix. Or, if that's going a bit too far, make infix check that your function has at least 2 arguments, and postfix that it has exactly one.

As for removing infixedness... unfortunately, prefix is kind of a generic word... a little reckless to have an lib/prefix "operator"

>> /add: prefix get $+

unfix sort of has the same problems as enfix.

Maybe a refinement to infix to say "...NOT!"

>> /add: infix:off get $+

:arrow_double_up: @bradrn

I know you are picky about terminology so would like to know if you feel this has plausible reasoning.

I am mostly convinced it is not worth it to make up words or make it any more complicated.