## clisp-list

 [clisp-list] bug in loop? From: - 2011-01-16 09:46:46 ```I think the examples below should compute the same thing. The difference is the position of the with clause. Have I misunderstood something? The first (which I think is wrong) worked as of 2.35 (2005-08-29) but seems not to work in current cvs or in 2.47++ (2009-06-15). (setf ht (make-hash-table)) (setf (gethash 1 ht) 2) > (loop for k being the hash-keys of ht as v being the hash-values of ht with ut = 3 count t) 0 > (loop with ut = 3 for k being the hash-keys of ht as v being the hash-values of ht count t) 1 > (loop for k being the hash-keys of ht with ut = 3 as v being the hash-values of ht count t) 1 ```
 [clisp-list] bug in loop? From: - 2011-01-22 19:07:31 ```I sent this about a week ago and have not seen any replies. Since I usually see replies to such questions very promptly, it occurs to me that maybe I should resend. Don Cohen writes: > > I think the examples below should compute the same thing. > The difference is the position of the with clause. > Have I misunderstood something? > The first (which I think is wrong) worked as of 2.35 (2005-08-29) > but seems not to work in current cvs or in 2.47++ (2009-06-15). > > > (setf ht (make-hash-table)) > (setf (gethash 1 ht) 2) > > (loop for k being the hash-keys of ht as v being the > hash-values of ht with ut = 3 count t) > 0 > > (loop with ut = 3 for k being the hash-keys of ht as v > being the hash-values of ht count t) > 1 > > (loop for k being the hash-keys of ht with ut = 3 as v > being the hash-values of ht count t) > 1 ```
 Re: [clisp-list] bug in loop? From: Arseny Slobodyuk - 2011-01-25 09:02:18 ```Hello Don, Sunday, January 16, 2011, 7:46:55 PM, you wrote: > I think the examples below should compute the same thing. > The difference is the position of the with clause. > Have I misunderstood something? I see the same results in current clisp (cygwin and mingw), but I believe that there's nothing wrong with the loop form. macroexpand gives meaningless code, the condition is always NIL: (macroexpand (loop for k being the hash-keys of ht as v being the hash-values of ht2 with ut = 3 count t)) ; I separated HT and HT2 -> (MACROLET ((LOOP-FINISH NIL (SYSTEM::LOOP-FINISH-ERROR))) (BLOCK NIL (LET ((#:WHTI-3201 (SYSTEM::HASH-TABLE-ITERATOR HT))) (MULTIPLE-VALUE-BIND (#:MORE?3202 #:HASH-KEY-3203 #:HASH-VALUE-3204) (SYSTEM::HASH-TABLE-ITERATE #:WHTI-3201) (DECLARE (IGNORE #:HASH-VALUE-3204)) (LET ((K NIL)) (LET ((#:WHTI-3205 NIL)) > (LET ((#:MORE?3206 NIL) (#:HASH-KEY-3207 NIL) (#:HASH-VALUE-3208 NIL)) (DECLARE (IGNORE #:HASH-KEY-3207)) (LET ((V NIL)) (LET ((UT 3)) (LET ((#:ACCUNUM-VAR-3209 0)) (MACROLET ((LOOP-FINISH NIL '(GO SYSTEM::END-LOOP))) (TAGBODY (UNLESS #:MORE?3202 (LOOP-FINISH)) (SETQ K #:HASH-KEY-3203) (SETQ #:WHTI-3205 (SYSTEM::HASH-TABLE-ITERATOR HT2)) > (UNLESS #:MORE?3206 (LOOP-FINISH)) (MULTIPLE-VALUE-SETQ (#:MORE?3206 #:HASH-KEY-3207 #:HASH-VALUE-3208) (SYSTEM::HASH-TABLE-ITERATE #:WHTI-3205)) SYSTEM::BEGIN-LOOP (SETQ V #:HASH-VALUE-3208) (PROGN (WHEN T (INCF #:ACCUNUM-VAR-3209))) (MULTIPLE-VALUE-SETQ (#:MORE?3202 #:HASH-KEY-3203 #:HASH-VALUE-3204) (SYSTEM::HASH-TABLE-ITERATE #:WHTI-3201)) (UNLESS #:MORE?3202 (LOOP-FINISH)) (SETQ K #:HASH-KEY-3203) (MULTIPLE-VALUE-SETQ (#:MORE?3206 #:HASH-KEY-3207 #:HASH-VALUE-3208) (SYSTEM::HASH-TABLE-ITERATE #:WHTI-3205)) (UNLESS #:MORE?3206 (LOOP-FINISH)) (GO SYSTEM::BEGIN-LOOP) SYSTEM::END-LOOP (MACROLET ((LOOP-FINISH NIL (SYSTEM::LOOP-FINISH-WARN) '(GO SYSTEM::END-LOOP))) (RETURN-FROM NIL #:ACCUNUM-VAR-3209)))))))))))))) ; -- Arseny ```
 Re: [clisp-list] bug in loop? From: Sam Steingold - 2011-01-25 15:24:50 ```> * Don Cohen [2011-01-16 01:46:55 -0800]: > > I think the examples below should compute the same thing. > The difference is the position of the with clause. > Have I misunderstood something? > The first (which I think is wrong) worked as of 2.35 (2005-08-29) > but seems not to work in current cvs or in 2.47++ (2009-06-15). > > (setf ht (make-hash-table)) > (setf (gethash 1 ht) 2) >> (loop for k being the hash-keys of ht as v being the > hash-values of ht with ut = 3 count t) > 0 the form is wrong: "with" forms should come _before_ the "for" forms. I think we should reject this. Do other lisps accept it? >> (loop with ut = 3 for k being the hash-keys of ht as v > being the hash-values of ht count t) > 1 looks good. >> (loop for k being the hash-keys of ht with ut = 3 as v > being the hash-values of ht count t) > 1 same as 1 - invalid form. please file a bug report. thanks. -- Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final) http://ffii.org http://dhimmi.com http://palestinefacts.org http://pmw.org.il http://thereligionofpeace.com http://truepeace.org http://honestreporting.com You can have it good, soon or cheap. Pick two... ```
 Re: [clisp-list] bug in loop? From: - 2011-01-25 15:54:14 ```Sam Steingold writes: > the form is wrong: "with" forms should come _before_ the "for" forms. > I think we should reject this. Is that in the spec? (Where?) > Do other lisps accept it? The few replies I've seen suggest they do. If you think with's should precede for's then at least you could output a warning, or perhaps better, an error for noncompliant code. ```
 Re: [clisp-list] bug in loop? From: Fred Cohen - 2011-01-25 16:20:54 ```Not that I am particularly an expert, but I don't understand why the ordering should be picky in this regard. As i understand it these sets of things (for i in j with k in l where m is p and Q likes R) (the "likes" being a user defined function) seems like the ordering reflects the order in which the interpretation should be done and not a syntactic limit on what can be accepted. Note that efficiency may be driven by ordering of the various conditionals... FC On 1/25/11 7:54 AM, Don Cohen wrote: > Sam Steingold writes: > > > the form is wrong: "with" forms should come _before_ the "for" forms. > > I think we should reject this. > Is that in the spec? (Where?) > > Do other lisps accept it? > The few replies I've seen suggest they do. > If you think with's should precede for's then at least you could > output a warning, or perhaps better, an error for noncompliant > code. > > ------------------------------------------------------------------------------ > Special Offer-- Download ArcSight Logger for FREE (a \$49 USD value)! > Finally, a world-class log management solution at an even better price-free! > Download using promo code Free_Logger_4_Dev2Dev. Offer expires > February 28th, so secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsight-sfd2d > _______________________________________________ > clisp-list mailing list > clisp-list@... > https://lists.sourceforge.net/lists/listinfo/clisp-list -- -This is confidential to the parties I intend it to serve- Fred Cohen & Associates tel/fax: 925-454-0171 http://all.net/ 572 Leona Drive Livermore, CA 94550 Follow us via RSS at blog.all.net for aperiodic updates ```
 Re: [clisp-list] bug in loop? From: Sam Steingold - 2011-01-25 16:20:41 ```> * Don Cohen [2011-01-25 07:54:10 -0800]: > > Sam Steingold writes: > > > the form is wrong: "with" forms should come _before_ the "for" forms. > > I think we should reject this. > Is that in the spec? (Where?) no, sorry, I got confused with `while': > (loop while t for i in () ) WARNING: LOOP: FOR clauses should occur before the loop's main body please file a bug report. -- Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final) http://ffii.org http://honestreporting.com http://truepeace.org http://thereligionofpeace.com http://memri.org http://palestinefacts.org Any connection between your reality and mine is purely coincidental. ```
 Re: [clisp-list] bug in loop? From: Dan Becker - 2011-01-25 18:58:51 ```On Tue, Jan 25, 2011 at 9:20 AM, Sam Steingold wrote: >> * Don Cohen [2011-01-25 07:54:10 -0800]: >> >> Sam Steingold writes: >> >>  > the form is wrong: "with" forms should come _before_ the "for" forms. >>  > I think we should reject this. >> Is that in the spec?  (Where?) > > no, sorry, I got confused with `while': > Of course it would be nice to be able to put WITH forms anywhere, and I think that it would be much better to signal an error or warning instead of returning 0 as in the above example ... But doesn't this page of the clhs make it clear that all WITH forms must appear at the start of the loop: http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/mac_loop.html ? Dan -- Dan Becker ```
 Re: [clisp-list] bug in loop? From: - 2011-01-25 17:40:50 ```Sam Steingold writes: > > * Don Cohen [2011-01-25 07:54:10 -0800]: > > > > Sam Steingold writes: > > > > > the form is wrong: "with" forms should come _before_ the "for" forms. > > > I think we should reject this. > > Is that in the spec? (Where?) > > no, sorry, I got confused with `while': > > > (loop while t for i in () ) > WARNING: LOOP: FOR clauses should occur before the loop's main body I don't understand that either. I'd view the main body in this example as being the empty space between the two right parens. I don't see anything in the spec that suggests that the form above is illegal or even problematic. I do see one problem. The while condition has to be evaluated in a place where i is bound by the for. If it refers to i, as in (loop while (p i) for i in l count t) Maybe the i in the condition should refer to an outer i. The while construct allows iteration to continue until the supplied form evaluates to false. The supplied form is reevaluated at the location of the while clause. It's not all that clear how to interpret the location of a clause in a macro expansion. Clearly the condition is to be tested in the loop so it must be inside the binding of i. Perhaps it's the interpretation of the for clause that is problematic, since it expands to three different things in different places, a binding, an update and a test. I suppose this has all been discussed on the common lisp list. ```
 Re: [clisp-list] bug in loop? From: Sam Steingold - 2011-01-25 20:07:39 ```> * Don Cohen [2011-01-25 09:40:46 -0800]: > > Sam Steingold writes: > > > (loop while t for i in () ) > > WARNING: LOOP: FOR clauses should occur before the loop's main body > I don't understand that either. http://www.lispworks.com/documentation/HyperSpec/Body/m_loop.htm loop [name-clause] {variable-clause}* {main-clause}* => result* variable-clause::= with-clause | initial-final | for-as-clause main-clause::= unconditional | accumulation | conditional | termination-test | initial-final i.e., with (which is a variable-clause) must come before while (which is a termination-test) -- Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final) http://memri.org http://ffii.org http://mideasttruth.com http://jihadwatch.org http://truepeace.org http://thereligionofpeace.com Never succeed from the first try - if you do, nobody will think it was hard. ```
 Re: [clisp-list] bug in loop? From: Dan Becker - 2011-01-25 23:07:34 ```On Tue, Jan 25, 2011 at 12:41 PM, Kaz Kylheku wrote: > The BNF syntax clearly uses alternation, so that the > sequence of variable-clause forms can contain with > and for-as in any order: > Oh, of course you are right! I did not read carefully enough. Dan -- Dan Becker ```