Shorthand for MAYBE... what about `?`

I'm not crazy about storing VOID in variables (though you can do it). I suggest initializing things to NULL and then using MAYBE at any site that is willing to overlook that, and create an intentional "opt out" from it.

But MAYBE does break the flow of what you're reading.

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
    ;
    (maybe spread app-config.libraries)
    (maybe spread ext-objlib.libraries)
]
post-build-commands: all [
    not cfg-symbols
    reduce [
        make rebmake.cmd-strip-class [
            file: join output maybe rebmake.target-platform.dll-suffix
        ]
    ]
]

ldflags: compose [
    (maybe spread ext.ldflags)
    (maybe 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 MAYBE 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 MAYBE?

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

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 MAYBE. (Or lib/?, or whatever.)

1 Like