Re: [ANN] CHICKEN 5.4.0 release candidate 2 available

[email protected]
Newsgroups gmane.lisp.scheme.chicken
Message-ID <[email protected]>
> > 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))

Hi!

I looked into this again and it turns out to be not that easy. Bytevectors
are created at read-time: when the reader encounters "#u8...", it reads
data elements and stores them in the vector, expecting numeric integer
values (hence the error message you saw). Quasiquote works at
expansion-time, it expects a valid s-expression and walks it, substituting
unquoted forms. This works for lists and vectors since they can contain
arbitrary values, so after reading a "normal" s-expression, possibly
containing "unquote" forms, we can transform these by evaluating
them. Bytevectors are already read when seen by quasiquote.

From my reading, R7RS does not support quasiquoted u8vectors either, the
formal grammer refers to "<qq template>" which seems to be allowed to
be only a list, a vector or a datum, the latter not being processed any further.

I hope this makes sense.


felix
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.