Re: Extensibility (and the lack thereof)
Felix Thibault 27 Oct 2020 02:18 UTC
Ok, I think I'll add an example with (match (proc obj) (pattern ...))
to the extension section and say something like "there will be a
future srfi using the syntax -> and => and an analogous technique to
accomplish this."
Felix
On Mon, Oct 26, 2020 at 9:58 PM John Cowan <xxxxxx@ccil.org> wrote:
>
>
>
> On Mon, Oct 26, 2020 at 8:35 PM Felix Thibault <xxxxxx@gmail.com> wrote:n
>
>> Wait, is this like (match (view-proc obj) pattern ...)) ?
>
>
> That was my original idea, but now I think it's better to do it differently. I'm going to stick with -> for now, as I think it helps readability. Here's an example:
>
> (define-record-type <point>
> (make-point x y)
> point?
> (x point-x)
> (y point-y))
>
> (define (point-view pt)
> (if (point? pt)
> (values (point-x pt) (point-y pt))
> (values))
>
> (define p (make-point 10 20))
>
> (match p
> ((-> point? point-view 10 y)
> (+ y 1))) => 21
>
> (match p
> ((-> point? point-view x 10)
> (- x 1))) => error
>
> That allows `match` users to match against any type for which a view-proc can be created (it need not be a record type), so I don't think we need any of the other bells and whistles. Note that if view-proc returns zero values, the -> pattern fails. (That's a usable convention, but not ideal.)
>
>
>
> John Cowan http://vrici.lojban.org/~cowan xxxxxx@ccil.org
> There is a Darwinian explanation for the refusal to accept Darwin.
> Given the very pessimistic conclusions about moral purpose to which his
> theory drives us, and given the importance of a sense of moral purpose
> in helping us cope with life, a refusal to believe Darwin's theory may
> have important survival value. --Ian Johnston
>