Annotation for When Something May Be Null

Sometimes you might want to reinforce that a value may or may not be null. You can do this in the name, like optional-foo, so if you were printing it:

optional-foo: if condition [<thing>]  ; else it will be null
print ["This is message" optional-foo bar baz]

You might also keep the name short, and then invoke conditionality even though you don't need reinforce the awareness:

foo: if condition [<thing>]
print ["This is message" (if foo [foo]) bar baz]

MAYBE is taken for another much cooler purpose than this.

>> x: 10

>> x: maybe case [
      1 = 2 [<not>]
      3 = 4 [<not either>]

>> x
== 10  ; right hand side of NULL meant MAYBE didn't overwrite X

There's still MAYHAP. :face_with_monocle: or PERHAPS.

print ["This is message" (perhaps foo) bar baz]

Or building on IF... IFFY?

print ["This is message" (iffy foo) bar baz]

OPT has been used to turn blanks into nulls. To help avoid using OPT where it isn't needed, it has been turning nulls into voids. But I guess it doesn't have to.

print ["This is message" (opt foo) bar baz]

Still...if it does anything then it's potentially going to add confusion in the mind of whoever's reading as to whether it's necessary.

Could involve symbols in the name. Dashes? Leading question marks?

print ["This is message" -foo- bar baz]

print ["This is message" ?foo bar baz]

print ["This is message" foo* bar baz]

For a while I'd wondered if you should have to use / to read null variables, otherwise they'd error...but I thought of some reasons to not do that which presumably still apply (including wanting to use them in APPLY)

print ["This is message" /foo bar baz]

Dunno. Out of the above, I probably like PERHAPS the most. It's a bit long, but the thing is that when you consider the amount of clarity such things can provide it can save on much lengthier naming and commenting to try and communicate intent.

I'll mention that THE (discussed recently as a potential alternative to ENSURE) was previously considered as a shortcut for NON NULL:

print ["This is message" (perhaps foo) (the bar) (the baz)]

Which seems fairly intuitive.

Just a thought: quasi, Latin for "as if"

They used to say programming languages should be careful before they cross over to where "line noise" (garbage characters you get on a modem from interference) became executable.

We should probably be careful of being able to actually run the "lorem ipsum" filler text :slight_smile:

As someone who's frequently concatenating and writing text! data to files, I prefer a shorter (even cryptic) notation to repeating functions throughout the output expression. Even though:

(ostensibly foo)

Is probably the clearest English language meaning. :wink: