Hello,

it seems that defstruct on a copy or set! operation doesn't let you
set the value of a field to an empty list. For instance, test the
following code:

    (use defstruct)

    (defstruct test a b)

    (define t1 (make-test a: '(1 2 3) b: '(4 5 6)))

    (define t2 (test-copy t1 a: '()))

    (display (test-a t2))
    (newline)

    (set-test! t1 b: '())

    (display (test-b t1))
    (newline)

t2 should be a copy of t1 with the field "a" modified to an empty list.
t1 should have had the field "b" changed to an empty list.

None of these things happened. That's because defstruct is using
internally an empty list to denote the value of a key that wasn't
informed to these procedures.

Probably a fix for this would be iterating through the arguments list
to know which keys weren't really informed. Or maybe Chicken has
another method to know this that I'm not aware.

Thanks,

Alonso Andres


_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to