Dialecting With Quasiforms

In the list of potential ideas of the long forgotten past, there was a thought that strings would come in two forms... one that was compared case-sensitively, and another that was not.

The visual look of the case-insensitive form was suggested as having a leading tilde, as one representation.

>> "a" = ~"A"
== #[true]

No one really went to bat for the idea or thought through its ramifications. It wasn't particularly easy to test what that would be like.

Quasiforms Make The Proposal Easier To Test

We now basically have the implementation guts needed to where we could consider the bits passed on the value. It even has a decent name:

>> quasi "A"
== ~"A"~

 >> "a" = "A"
 == #[false]

 >> "a" = quasi "A"
 == #[true]

The principle meaning of a quasiform is as the ^META of an isotope form. And what this would mean is, there's no such thing as a differentiation between an isotopic case-sensitive word/string and an isotopic case-insensitive word/string.

I Don't Think I Like It, BUT...

Regardless of me not liking it, it's a possibility for dialects. If you wanted to mark some strings for case-insensitivity you have another option in the box.

The reason I don't like it is because the isotope and quasi forms are supposed to stand out and draw attention to weirdness. This is too common an application. And it would mean your case-insensitive forms would be evaluating to isotopes everywhere, unless the quasiform evaluation changed in some way to make quasi-strings inert. This isn't in line with what I want to do.

But...your dialect can do it.

2 Likes

So this points to a place where generic quasiforms really shine, I think: drawing attention in dialects to the bad cases.

In fact, I've updated the test dialect so that it uses QUASI-WORD!s next to the test to indicate the ID of an error of failure.

Before the tests would often be something like:

(
     e: trap [1 / 0]
     assert [error? e]
)

But now, I use the dialect to specifically name the error-id. It's more succinct...and it verifies that the error that was raised was actually the error you thought:

~zero-divide~ !! (
    1 / 0
)

I threw in a !! just to punctuate it a little bit more--it's not strictly necessary. But it helps distinguish it from the mere appearance of a quasiform in a test itself.

Rebol2 could have looked like that (since ~zero-divide~ was a WORD!). It just would have run into the question of "what if the error ID actually was the WORD! of ~zero-divide~", and the quasi rules remove that possibility...which makes things cohere better.

But now we have quasiforms for BLOCK!, GROUP!, TAG!, TEXT!... you name it!

expressions: [
   [1 + 2]
   ~[1 + + 2]~
   [3 * 4 * 5]
   [1 + 2 * 3]
   ~[* * 2 3]~
]

I think this will further empower creativity in dialect design, in notable ways. In the past I've done some kinds of markings like this using quotes... but the tildes are better if what you mean to do is "call out" cases as being special or outliers.

2 Likes

Seems useful. I just normally check the error id