"Insanity Level" for The Mu-Library In Rebmu

Rebmu has a fairly strict design principle, which is that a typical library function can only be overridden with a version that is a superset of its functionality. It can have special handling for things that would cause panics, but should give the same output for any valid input.

As an example: IF should not be redefined to something that would consider 0 to be conditionally false. If you write regular old lowercase code, you always want:

rebmu>> if 0 [print "truthy"]
truthy

However... IF typically doesn't allow VOIDs, TRASH!, ERROR! as conditions. We could treat them all as falsey if we liked, or truthy. Or do various weird things (IF of a VOID could make the whole IF expression void...)

And at the moment, WORD!s are illegal in the branch slot (the branch is not evaluated by default, it is taken literally for "soft literal branching"). But if WORD! wasn't an error, what could it mean?

I like the idea of it being able to build a specialized action out of the branch:

rebmu>> if 0 print "truthy"
== truthy

rebmu>> if null print "truthy"
== \~null~\  ; antiform

So that would be like you had written:

rebmu>> if 0 (specialize print/ ["truthy"])
== truthy

rebmu>> if null (specialize print/ ["truthy"])
== \~null~\  ; antiform

It could save the [ and ] off of a lot of calls, I think it would be particularly interesting with things like function:

z: function [x y] any [equal? 10 add x y, equal? 20 subtract x y]

Which would wind up being written like:

Zfn[xY]ay[e?10adXyE?20sbXy]

Of course this is just the tip of the iceberg.

Lots I Could Talk About, But Wanted To Mention Something

In thinking about the idea of a version of IF that didn't raise ERROR!s but treated them as false, I thought about how maddening that would be to debug.

"True Rebmu" should probably be as liberal as it can about finding meaning for inputs, without concern for debuggability. But you shouldn't dial the settings for insane unless you're actually using them.

So I think in the Rebmu header, there should be some configuration you can do.

Rebmu [
    file: %99-bottles.rebmu
    title: "99 Bottles of Beer on the Wall, Code Golfed"
    configure: [
        if: [:errors-are-falsey :void-if-void-condition]
        ...
    ]
]

None of the options would be contradictory...they're all just creeping you along the path to ultimate "insanity mode" where it's maximally permissive (the zero-header run state, to be the most minimal characters for code golf). Headers are just documentation of which facilities you're actually using on purpose in the program, to help debugging by not enabling behaviors you won't use.

For things like ERROR! are falsey in conditionals, it's something you should be able to turn on for all conditionals or selectively for specific ones.

This resembles the kinds of problems of configuration for "real" tasks, so will have to see how things like RebindableSyntax can help.

1 Like