Hi,
I have some code thus:
-----
(define p
(lambda (m state)
(printf "m: ~S\nstate: ~S\n\n" m state)
(let ((k (car m))
(v (cdr m)))
(case k
((team)
(append `((team/name . ,(alist-ref 'name v eqv? 'sentinel)))
state))
(else
(cons `(,k . ,v) state))))))
(pp (p '(team . null) '()))
-----
On 4.7.0 I see this:
-----
$ csi -ns x.scm
m: (team . null)
state: ()
((team/name . sentinel))
-----
On 4.9.0rc1 I see this:
-----
$ csi -ns x.scm
m: (team . null)
state: ()
Error: (assv) bad argument type: null
Call history:
<syntax> (pp (p (quote (team . null)) (quote ())))
<syntax> (p (quote (team . null)) (quote ()))
<syntax> (quote (team . null))
<syntax> (##core#quote (team . null))
<syntax> (quote ())
<syntax> (##core#quote ())
<eval> (pp (p (quote (team . null)) (quote ())))
<eval> (p (quote (team . null)) (quote ()))
<eval> [p] (printf "m: ~S\nstate: ~S\n\n" m state)
<eval> [p] (car m)
<eval> [p] (cdr m)
<eval> [p] (eqv?8 tmp5 (quote team))
<eval> [p] (append (quasiquote ((team/name unquote (alist-ref
(quote name) v eqv? (quote sentinel))))) state)
<eval> [p] (##sys#list (##sys#cons (##core#quote team/name)
(alist-ref (quote name) v eqv? (quote sentinel))))
<eval> [p] (##sys#cons (##core#quote team/name) (alist-ref
(quote name) v eqv? (quote sentinel)))
<eval> [p] (alist-ref (quote name) v eqv? (quote sentinel)) <--
-----
However, if I add "(use numbers)" at the top of my script:
-----
(use numbers)
(define p
(lambda (m state)
(printf "m: ~S\nstate: ~S\n\n" m state)
(let ((k (car m))
(v (cdr m)))
(case k
((team)
(append `((team/name . ,(alist-ref 'name v eqv? 'sentinel)))
state))
(else
(cons `(,k . ,v) state))))))
(pp (p '(team . null) '()))
-----
...it works on 4.9.0rc1:
-----
$ csi -ns x.scm
m: (team . null)
state: ()
((team/name . sentinel))
-----
More information about the purpose of the code:
The example is code derived from my development version of the dropbox egg.
The code tries to munge the hierarchical JSON returned from the dropbox
API. There's usually another branch of the case statement thus:
((quota_info)
(append `((quota_info/normal . ,(alist-ref 'normal v))
(quota_info/shared . ,(alist-ref 'shared v))
(quota_info/quota . ,(alist-ref 'quota v)))
state))
...which shows the intention more clearly. We are taking nested alists
and flattening them out, with keys delimited by a "/" character.
Sometimes the data returned by the API is 'null rather than a list. This
is the common case for the "team" key.
I haven't tried CHICKEN 4.8.
Regards,
@ndy
--
[email protected]
http://www.ashurst.eu.org/
0x7EBA75FF
_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users