Re: [ANN] CHICKEN 5.4.0 release candidate 2 available
Kristian Lein-Mathisen <[email protected]>
| Newsgroups | gmane.lisp.scheme.chicken |
|---|---|
| Message-ID | <CAAGQtHxYZ-AKvodEyeFXeVk4CfkwMVOCi97uS=avisZZznM6bg@mail.gmail.com> |
Hi Felix, Thanks for your feedback. > #;2> #u8(1 "hello") > > #u8(1 104 101 108 108 111) > > #;3> (u8vector 1 "hello") > > Error: (u8vector-set!) bad argument type: "hello" > > Literals like vectors contain <datum>s, which are not arbitrary > expressions, > this is just how the language is defined. I actually never looked into this for normal Scheme vectors. Are the literals for these defined as part of the Scheme language? #;8> #(1 2 (+ 1 2)) #(1 2 (+ 1 2)) #;9> `#(1 2 ,(+ 1 2)) #(1 2 3) It appears there is a way to mix-and-match literals and arbitrary expressions using quasiquote. Would it be appropriate to support this for srfi-4 vectors too? #;11> `#u8(1 2 ,(+ 1 2)) Error: (u8vector-set!) bad argument type: (unquote (+ 1 2)) In normal vectors allowing expressions > would create ambiguities, as a vector can contain any value. For > bytevectors > one could argue that this situation does not exist, but I somehow find that > it gets confusing. So consider the string-notation in literals a convience > feature, > nothing more. Generalizing this to the constructor procedure just invites > type > errors and hides mistakes, I think. > Fair enough. I was expecting this feature could replace string literals for binary protocols and such, but that might quickly get ambitious. I will stick to doing things like (blob->u4vector/shared (string->blob "\x00\x05hello") K.