clarity-lang / reference

The Clarity Reference
149 stars 34 forks source link

Consider asciii a subtype of utf8 strings #35

Open njordhov opened 3 years ago

njordhov commented 3 years ago

Clarity currently strictly distinguishes between single-byte string-ascii and utf8 encoded unicode string-utf8, restricting these types from being mixed. However, an ASCII encoded string is already valid UTF8, per the specification of the latter.

It would be beneficial if Clarity considered string-ascii to be a subtype of string-utf8, where an ascii string can be used in place of utf8, but not the other way around.

With ascii being a subtype of utf8, Clarity no longer requires a prefixed u"Hello World" literal syntax for UTF-8 strings but can use the characters in the string to determine whether or not it should be considered ASCII. This eliminates an error-prone complication for developers as described in https://github.com/blockstack/stacks-blockchain/issues/2114