[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
srfe records in reworked match
From: |
stefan |
Subject: |
srfe records in reworked match |
Date: |
Tue, 20 Apr 2010 15:14:18 +0200 |
User-agent: |
KMail/1.12.4 (Linux/2.6.31.12-0.2-desktop; KDE/4.3.5; x86_64; ; ) |
Ok,
I have started to code in some record recognition into the match construct
I need first to make sure that I grok the intention of the syntax!
Now, one can do ...
* (define rtf (make-record-type "n" '(x y z)))
* (define make-n (record-constructor rtf))
* (define v (make-n 1 2 3))
* (define g (record-accessor rtf 'x))
* (define s (record-modifier rtf 'x))
* (match v ((= g 1) 'yes)) ;; This is the old behavior
yes
;; = allow for a getter and setter argument so that we can do ...
* (match v ((= (g s) (and (set! x.set)
* (get! x.get)
* 1))
* (begin (x.set 2)
* (x.get))))
2
;;Now the $ syntax work, although a lot of unpacking of accessors and
modifiers
;;are done dynamically and not at compile time.
* (match v (($ rtf x 2 3) x))
2
* (match v ( ($ rtf
* x
* (and (set! y.set)
* (get! y.get))
* 3)
* (begin (y.set 4)
* (+ x (y.get)))))
6
It's recursive.
Not solid yet though, need to make sure that variables can be extracted
correctly from $ and =
/Stefan
- srfe records in reworked match,
stefan <=
Re: srfe records in reworked match, stefan, 2010/04/23