Why is TYPE OF 1 an &INTEGER and not INTEGER!

>> type of 1         
== &integer

I would have expected this to print as integer!, since that’s how we refer to it in discussions. But no, it prints with an ampersand. I’m sure there’s some good reason for this, but the apparent inconsistency is jarring.

INTEGER! is a word, and looks up to a datatype.

Historical Redbol has the same problem here as with not having a good representation for true and false, where it just kind of lies and makes DATATYPE! conflate with words:

rebol2>> type? 1
== integer!

rebol2>> type? first [integer!]
== word!

rebol2>> type? type? 1
== datatype!

There were proposals to say that if a spelling ends in exclamation point that means it's lexically considered a datatype, e.g.

>> type? first [integer!]
== datatype!

This would have created a lot of trouble for renamings like the PAREN! => GROUP!, because there'd be no lookup step for the word, as datatype literals would presumably just evaluate to themselves.

Ren-C made TYPE-WORD! (and TYPE-BLOCK!, TYPE-GROUP!, etc.) so you have some more parts. If you're making a dialect and want to use &AElig as an HTML entity you can.

This means exclamation point doesn't have any special lexical meaning, and is an ordinary word character.

I don’t follow this… how is the syntax of datatype literals connected to renaming PAREN!? Could you elaborate please?

It's for when you're establishing compatibility layers, e.g. you can say:

paren!: &group
group!: &group

Because PAREN! and GROUP! are words, the lookup step lets them find the same datatype.

I suppose that makes sense… except this doesn’t actually seem to work when I try it in the console:

>> paren!
** Script Error: paren! word is attached to a context, but unassigned
** Where: console
** Near: [paren! **]
** Line: 1

So if there isn’t actually any compatibility layer, I don’t see the value in doing this rather than simply writing TYPE-WORD!s as literals with exclamation marks.

See the Redbol Module.

Additionally, Ren-C has to deal with type checks beyond fundamental types. There's no good answer for TYPE OF an isotope. So TYPE-BLOCK!s / TYPE-GROUP!s allow you to check these:

logic?!: &[logic?]
splice?!: &[splice?]

switch/type spread [a b c] [
    logic?! [print "It's a logic"]
    splice?! [print "It's a splice"]

More generally, taking away ! from words is a controversial idea.

1 Like