unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* srfe records in reworked match
@ 2010-04-20 13:14 stefan
  2010-04-21  8:40 ` Ludovic Courtès
  0 siblings, 1 reply; 18+ messages in thread
From: stefan @ 2010-04-20 13:14 UTC (permalink / raw)
  To: guile-devel

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






^ permalink raw reply	[flat|nested] 18+ messages in thread
[parent not found: <CCF7F725-F332-40DE-8193-65FB81ADD08C@spray.se>]

end of thread, other threads:[~2010-05-03 16:24 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-20 13:14 srfe records in reworked match stefan
2010-04-21  8:40 ` Ludovic Courtès
     [not found]   ` <07487229-BEA5-49C8-B73F-83370F028513@spray.se>
2010-04-21 11:47     ` Ludovic Courtès
2010-04-22 11:13   ` Andy Wingo
2010-04-22 12:27     ` Ludovic Courtès
2010-04-22 12:52       ` Andy Wingo
2010-04-22 12:57         ` Ludovic Courtès
2010-04-22 13:48           ` Andy Wingo
2010-04-22 17:09       ` stefan
2010-04-23  7:52   ` stefan
2010-04-23  9:23     ` Ludovic Courtès
2010-04-23 20:21   ` stefan
2010-04-28  8:40     ` Ludovic Courtès
     [not found] <CCF7F725-F332-40DE-8193-65FB81ADD08C@spray.se>
2010-04-28 13:50 ` Stefan
2010-05-03 12:38   ` Ludovic Courtès
2010-05-03 13:35     ` Stefan
2010-05-03 13:51       ` Ludovic Courtès
2010-05-03 16:24         ` stefan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).