Usermode Expression Barriers: Faking "Holes"

If a function parameter is marked with <hole>, then evaluations looking to the right will receive something that looks like NULL... that they can also "sense" as being "actually missing":

test-normal: func [x [<hole> any-value?]] [
    return reduce [lift x, boolean hole? $x]
]

>> test-normal
== [~null~ true]  ; looks like null, but if you ask, it's a hole

>> test-normal third [a b]
== [~null~ false]  ; is actual null, and if you ask it's not a hole`

Besides happening at the end of expression input, you also get the "hole" when there's a COMMA!:

>> test-normal,  ; <-- comma after TEST-NORMAL
== [~null~ true]  ; looks like null, but if you ask, it's a hole

Could You "Make Your Own Comma"?

What if you had something that you wanted to behave as "barrier-like"?

For instance, a thing I made once was the "ELIDE-TO-END" operator (|||)

>> 1 + 2 ||| x <y> #z 10 * 20
== 3

It's a variadic function that just keeps feeding what comes after it literally, and discards all of it and vanishes.

But what if I wanted it to "look like a comma" as far as a hole-taking function is concerned?

>> test-normal ||| x <y> #z 10 * 20
== [~null~ true]  ; how to get this result?

Perhaps All Vanishable Functions Look Like Holes?

It's a thought. Off the top of my head I like it better than having another flag or state for it.

I think it should only apply in evaluative contexts... (while COMMA! has special treatment even literally.)

The general idea is that holes become null when passed as arguments. Does that change things for instance with passing COMMENT to a function?

>> foo: proc [x] [probe x]

>> foo comment "test"
\~null~\  ; antiform

I'll get back to you on that.

:thinking:

Doesn't Change The "Vanishing PRINT" Calculation

A little inkling of this perhaps makes things like PRINT more viable as vanishable... since it could stop the rogue APPEND:

>> append [a b c] print "What if this was a hole?"
What if this was a hole?
** PANIC: APPEND is missing its VALUE argument

But now if we don't want anything to print, we have to erase both VOID! and HEAVY VOID from console output, so both these cases would vanish:

>> print "Don't want an == here"
Don't want an == here  ; v-- we aren't printing a \~,~\ antiform

>> append [a b c] [d e] print "No == here, either"
No == here, either  ; v-- we aren't printing a \~()~\ antiform

That's a pretty serious suppression of important educational information.

1 Like