rebcabin / masr

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

Return type of `StringChr`: string or character ? #41

Open rebcabin opened 1 year ago

rebcabin commented 1 year ago

In the examples, I see only

(StringChr
                                            (Var 4 p)
                                            (Character 1 1 () [])
                                            ()
                                        )

with an empty return value.

I've spec'ced it to return a string, but is this right ?

(defn StringChr
  ([str-expr, char-ttype, string-val?]
   "trinary ... Return ascii value of the indicated
   character in the string."
   (let [cnd {::term ::expr,
              ::asr-expr-head
              {::expr-head ::StringChr
               ::string-expr       str-expr
               ::Character         char-ttype
               ::string-value?     string-val?}}]
     (if (s/valid? ::StringChr cnd)
       cnd
       :invalid-string-chr)))
  ([str-expr, string-val?]
   (StringChr str-expr, (Character) string-val?)))