questions on libraries, pattern matching etc

Per Bothner per@bothner.com
Mon Dec 16 00:59:00 GMT 2019


On 12/15/19 3:46 PM, Ben wrote:
> hi
> I'd like to test how I can use pattern match in Kawa. First I did try to use Kawas pattern matching function, but from what I saw it is a bit limited, for example there is no matching of lists.

Actually, there is matching of lists, but by matching them as general sequences:

#|kawa:1|# (! [a b c @rest] [1 2 3 4 5 6])
#|kawa:2|# (format "a: ~a b: ~a c: ~a rest: ~a~%" a b c rest)
a: 1 b: 2 c: 3 rest: #(4 5 6)

Implementing more general matching is mainly an issue of design including deciding on a syntax.
Fundamentally, should be syntax for matching a pair be:

(! (pat_car . pat_cdr) value)

or:

(! (cons pat_car pat_cdr) value)

or something else?
The latter is used in Racket, and is more flexible, I believe, but not as elegant -
which ties back to fundamental awkwardness with the Scheme evaluation model.

Of course once we/I decide on a syntax, then it needs to be implemented, but
should be fairly straight-forward, given the existing framework.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/



More information about the Kawa mailing list