[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unintentional conflict in define-immutable-type?
From: |
Mark H Weaver |
Subject: |
Re: Unintentional conflict in define-immutable-type? |
Date: |
Thu, 19 Nov 2015 15:32:00 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Hi Rob,
Rob Browning <address@hidden> writes:
> This crashes in 2.0:
>
> (use-modules (srfi srfi-9 gnu))
>
> (define-immutable-record-type foo
> (foo x)
> foo?
> (x x))
>
> (foo 1)
>
> like this:
>
> foo.scm:10:9: In procedure #<procedure 131fd00 ()>:
> foo.scm:10:9: In procedure make-struct: Wrong type argument in position 1:
> #<procedure %foo-procedure (x)>
The problem is that (define-immutable-record-type foo ...) binds 'foo'
to the record-type-descriptor (rtd), and you are also binding 'foo' to
the constructor. I suppose we should try to improve the error message
in cases like this.
> Changing the type name to <foo> (or even xfoo) fixes the conflict,
Right.
> even though "define-immutable-type foo" actually creates a binding for
> <foo>, not foo.
I believe you are mistaken about that. Looking at both the code and the
expansion of your 'define-immutable-record-type' form above, I see no
evidence that <foo> is bound to anything by it.
Regards,
Mark