You generally don't store VOID in variables (using WORD!-assignments of VOID will now unset things)
actually storing VOID is done very rarely, and requires ^META designation on both the assignment and fetch:
^var: ~[]~
assert [void? ^var] ; plain VAR would just panic
Typical non-metacode wouldn't do this.
Hence the general working pattern is to initialize things to NULL, and then using OPT at any site that is willing to overlook that...and create an intentional "opt out" from it.
OPT is already an abbreviation (of OPTIONAL). But it does break the flow of what you're reading a little. Not as badly as it did when it was a longer word of MAYBE (which is now something else cool!) But still it's a little wordier than it needs to be.
Here's some code from Rebmake:
depends: compose [
(ext-objlib) ; !!! Pulls in in all of extensions deps?
;
; (app) all dynamic extensions depend on r3, but app not ready
; so the dependency is added at a later phase below
;
(opt spread app-config.libraries)
(opt spread ext-objlib.libraries)
]
post-build-commands: all [
not cfg-symbols
reduce [
make rebmake.cmd-strip-class [
file: join output opt rebmake.target-platform.dll-suffix
]
]
]
ldflags: compose [
(opt spread ext.ldflags)
(opt spread app-config.ldflags)
; GCC has this but Clang does not, and currently Clang is
; being called through a gcc alias. Review.
;
;<gnu:-Wl,--as-needed> ; Switch ignores linking unused libs
]
I Feel Like OPT Needs A Shorthand
I've expressed my distate for taking the ?
symbol that can be so useful in the language for something like help
when you can just type help. (or make a shorthand that applies only in the console that turns h
into HELP, if you must, and then you'd say (h)
if you wanted to get the variable.
So... what about ?
for OPT:
depends: compose [
(ext-objlib) ; !!! Pulls in in all of extensions deps?
;
; (app) all dynamic extensions depend on r3, but app not ready
; so the dependency is added at a later phase below
;
(? spread app-config.libraries)
(? spread ext-objlib.libraries)
]
post-build-commands: all [
not cfg-symbols
reduce [
make rebmake.cmd-strip-class [
file: join output ? rebmake.target-platform.dll-suffix
]
]
]
ldflags: compose [
(? spread ext.ldflags)
(? spread app-config.ldflags)
; GCC has this but Clang does not, and currently Clang is
; being called through a gcc alias. Review.
;
;<gnu:-Wl,--as-needed> ; Switch ignores linking unused libs
]
I Like It
This seems to me a pretty strong use of the symbol (especially when contrasted with sacrificing it for interactive help.)
Of course, you can override anything and everything. If you're in a function and you think ? would be more useful to do something else, do something else with it. let ?: <whatever>
and fallback on OPT. (Or lib/?
, or whatever.)