Enfixing ALSO, stylizing it after THEN and ELSE

As we contemplate re-stylizing operations to embrace enfix more, one kind of historically ugly construct that could use an improvement is ALSO.

Consider this line from IN-DIR:

also do block change-dir old-dir

This is a shorthand for writing:

(temp: do block, change-dir old-dir, temp)

But this can be done just fine with ELIDE (!)

(do block, elide change-dir old-dir)

So wouldn't it be more interesting if ALSO could be in the same family as THEN and ELSE, perhaps being like a THEN that doesn't modify the result?

tester: func [num] [
    switch num [
        1 [<one>]
        2 [<two>]
     ] also [
        print "It was one or two"
     ] else [
        print "It was neither one nor two"
     ]
]

>> tester 1
It was one or two
== <one>  ; the ALSO branch ran, but didn't modify the overall result

>> tester 3
It was neither one nor two

I like that it's the same number of letters as THEN and ELSE. :slight_smile:

2 Likes

The historical ALSO always plays havoc with my comprehsion, an enfix form looks far more natural to me.

2 Likes