[Chicken-users] Hygienic Chicken's desftruct issue

From:

Alonso Andres

Subject:

[Chicken-users] Hygienic Chicken's desftruct issue

Date:

Mon, 25 Aug 2008 15:29:30 -0300

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