Hi,
Attila Lendvai wrote: [sorry to get back that late at you]
i've implemented another version of first-iteration-p and first-time-p as discussed. please find a patch attached with some tests, it's relative to the 1.4 release.
The user API looks ok, however the way you change add-binding removes safety checks: several uses must have the same default initialization and type, etc. This could cause future extensions to break. I think the make-xyz-binding API should be used, that's what they are for, and they also provide for the optional type declarations. I agree the many make-*-binding are confusing. It's also confusing me every time!
You once wrote you had a bad feeling about (setf (cddr entry) ...). But it is the "API" for adding extra information to bindings: "The alist entry is returned. It can be used to store additional info ..."
< (locally (declare (optimize safety ...
(locally (declare (optimize (safety 3)...
While I can indeed remember a bad declaration (revealed by sbcl/cmucl) somewhere in the testsuite fixed on 2005-05-20, the above change is not necessary. SAFETY just means (SAFETY 3). It's been there since CLtL1. See CLHS about OPTIMIZE.
Which Lisp caused you to change all these declarations? Did it generate an error? Please report a conformance error to the implementor.
The error I fixed on 2005-05-20 was an incorrect (declare (safety) ...) instead of (declare (optimize safety ...)).
Regards, Jörg Höhle.
The user API looks ok, however the way you change add-binding removes safety checks: several uses must have the same default initialization and type, etc. This could cause future extensions to break.
I don't really see what you mean here (newbie warning repeated :)
I modified add-binding to accept an optional keyword param, :reuse-existing. It does not change anything anywhere, except you can optionally tell it not to error when such a variable is already defined. And that is exactly what i need for first-iteration-p: i want a lazy added, shared variable for each use of first-iteration-p.
For first-time-p i use the usual make-var-and-binding, because there i need to create a new variable for each uses.
I think the make-xyz-binding API should be used, that's what they are for, and they also provide for the optional type declarations. I agree the many make-*-binding are confusing. It's also confusing me every time!
Maybe a make-shared-binding is what's missing?
< (locally (declare (optimize safety ...
(locally (declare (optimize (safety 3)...
While I can indeed remember a bad declaration (revealed by sbcl/cmucl) somewhere in the testsuite fixed on 2005-05-20, the above change is not necessary. SAFETY just means (SAFETY 3). It's been there since CLtL1. See CLHS about OPTIMIZE.
Right. It is sbcl 0.9.7 complaining, I'll try the newest and report the bug to the developers if it still persists.
IIRC my only useful addition to iterate-tests.lisp was the two tests:
(deftest first-time-p.1 (iter (for i to 5) (if (first-time-p) (collect -1)) (if (first-time-p) (collect -2)) (when (oddp i) (if (first-time-p) nil (collect -1)) (collect i))) (-1 -2 1 -1 3 -1 5))
(deftest first-iteration-p.1 (iter (for i to 5) (if (first-iteration-p) (collect -1)) (if (first-iteration-p) (collect -2)) (when (oddp i) (if (first-iteration-p) nil (collect -1)) (collect i))) (-1 -2 -1 1 -1 3 -1 5))
- attila
(alias 101 on irc &no 'its not lisp code :)