rebcabin / masr

Meta ASR: replacement for aging ASDL
MIT License
4 stars 0 forks source link

Design Question forced by Ambiguous Return Type of `StringItem` #52

Open rebcabin opened 1 year ago

rebcabin commented 1 year ago

This is a top-level design issue as the types for Character and String are currently conflated, and some ASR terms further conflate Character scalars with Integer scalars.

By Issue #51 , StringItem might return a String (which is actually a Character), or an Integer. Terms that take a StringItem, therefore, must be prepared to take either a Character or an Integer. This need complicates ("complexifies," in Hickey-speak) the fine-grained types for string-expr and integer-expr.

Resolution is possibly a redesign of those fine-grained types, or perhaps new, top-level types that distinguish String and Character and permit a character to be either an Integer or a new type for a primitive character.

rebcabin commented 1 year ago

Perhaps to clarify the questions:

  1. Should there be different types for single characters versus strings that just happen to have a single character?
  2. Is Character of length 42 the same as or different from Character of dimension* [42]?
  3. Is an array of characters the same as or different from a String?
  4. Is a Character the same as or different from an Integer within appropriate limits?
  5. Should we have a type String that is different from the type Character?

Clean answers to these questions should force a better design. Currently, I see only special-case kludges in terms like StringChr, StringItem, and StringCompare.