guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Functional record "setters", a different approach


From: Mark H Weaver
Subject: Re: Functional record "setters", a different approach
Date: Fri, 09 Nov 2012 23:13:30 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Hi Ludovic,

address@hidden (Ludovic Courtès) writes:
> Mark H Weaver <address@hidden> skribis:
>> +    (pass-if "set-fields with one path as a prefix of another"
>> +      (let ()
>> +        (define-immutable-record-type foo (make-foo x) foo?
>> +          (x foo-x)
>> +          (y foo-y set-foo-y)
>> +          (z foo-z set-foo-z))
>> +
>> +        (define-immutable-record-type :bar (make-bar i j) bar?
>> +          (i bar-i)
>> +          (j bar-j set-bar-j))
>> +
>> +        (catch 'syntax-error
>> +         (lambda ()
>> +           (compile '(let ((s (make-bar (make-foo 5) 2)))
>> +                       (set-fields s
>> +                         ((bar-i foo-x) 1)
>> +                         ((bar-i foo-z) 2)
>> +                         ((bar-i) 3)))
>> +                    #:env (current-module))
>> +           #f)
>> +         (lambda (key whom what src form subform)
>> +           (equal? (list key whom what form subform)
>> +                   '(syntax-error set-fields
>> +                                  "one field path is a prefix of another"
>> +                                  (set-fields s
>> +                                    ((bar-i foo-x) 1)
>> +                                    ((bar-i foo-z) 2)
>> +                                    ((bar-i) 3))
>> +                                  (bar-i)))))))))
>
> You might want to use ‘pass-if-equal’ here, for better reporting.

I see now what you meant, and I just pushed a patch to convert these to
use 'pass-if-equal'.

I also pushed a couple more patches to improve error reporting.

    Thanks!
      Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]