Hello list,
while trying to get cl-num-utils running on ECL i encountered a problem
with let-plus in combination with define-modify-macro.
Informal description: When define-modify-macro defines a three-argument
"modifier", ECL complains about "wrong number of arguments" when used in
combination with let-plus and structure slots. I see no problems when
used outside of let-plus. I also see no problems when i use a two
argument modifier.
I attached an hopefullly illustrating sample. This runs fine on SBCL
and CLISP but produces the aforementioned error when run under ECL
(both, recent release and current git head).
So, please, can anybody give me a hint how to do it right.
Cheers, Tara
;(ql:quickload "let-plus")
(defpackage :incf-test
(:use :cl :let-plus))
(in-package :incf-test)
(define-modify-macro incf-mean (value tally)
(lambda (mean value tally)
(+ mean (/ (- value mean) tally))))
(define-modify-macro incf-noop (ignored)
(lambda (old-value ignored)
old-value))
(let ((x 0))
(incf-mean x 10 1)) ; -> 10, as expected
;; Use in combination with let+
(let+ ((x 0))
(incf-mean x 10 1)) ; -> 10, as expected
;; Use in combinaton with let+ and structures
(defstruct mean-accumulator mean tally)
(defun update-mean-accumulator (accum value)
(let+ (((&structure mean-accumulator- mean tally) accum))
;; The next two expressions cause no trouble
(incf tally)
(incf-noop tally 1)
;; but this one will:
(incf-mean mean value tally)))
(let ((accum (make-mean-accumulator :mean 0 :tally 0)))
(update-mean-accumulator accum 10)
(assert (= (mean-accumulator-mean accum) 10)))
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ecls-list mailing list
Ecls-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ecls-list