Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
LOOP discrepancy
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Matthew Danish  
View profile  
 More options Aug 23 2002, 5:37 pm
Newsgroups: comp.lang.lisp
From: Matthew Danish <mdan...@andrew.cmu.edu>
Date: Fri, 23 Aug 2002 17:32:16 -0400
Local: Fri, Aug 23 2002 5:32 pm
Subject: LOOP discrepancy
While testing out a loop on various implementations I came across the
following discrepancy (boiled down):

(loop repeat 3 for x from 0 finally (return x))

=> 2 in CMUCL, SBCL, and Allegro CL
but
=> 3 in CLISP

For the first 3 implementations, x is no longer incremented once the
termination test of repeat has been reached, but for CLISP it is still
incremented (whether before or despite the termination-test I do not
know).

If you change the order of the repeat and the for-from clauses in the
loop, then CMUCL, SBCL, and Allegro give 3 as a result as well.  So my
guess is that those are applying the repeat termination-test in the
order that it appears with the iteration-control clauses.

The Hyperspec, section 6.1.1.6 "Order of Execution", states that:

``* Iteration control clauses implicitly perform the following actions:

-- initialize variables;

-- step variables, generally between each execution of the loop body;

-- perform termination tests, generally just before the execution of the
loop body.''

Section 6.1.4 "Termination-test Clauses" states:

`` Termination-test control constructs can be used anywhere within the
loop body. The termination tests are used in the order in which they
appear.''

Does this mean that all stepping of variables should occur before any
termination-tests are performed--regardless of lexical position--or only
before termination-tests associated with the iteration-control clauses?

--
; Matthew Danish <mdan...@andrew.cmu.edu>
; OpenPGP public key: C24B6010 on keyring.debian.org
; Signed or encrypted mail welcome.
; "There is no dark side of the moon really; matter of fact, it's all dark."


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Aug 24 2002, 1:17 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 24 Aug 2002 05:17:09 +0000
Local: Sat, Aug 24 2002 1:17 am
Subject: Re: LOOP discrepancy
* Matthew Danish
| Does this mean that all stepping of variables should occur before any
| termination-tests are performed--regardless of lexical position--or only
| before termination-tests associated with the iteration-control clauses?

  My understanding is that termination tests should be performed as early as
  possible.  Otherwise, if you loop over a vector and use either "for index
  from start below end" or some equivalent thereof, you would not want to
  access the endth element, not even in the finally clause.

--
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wolfhard Buß  
View profile  
 More options Aug 24 2002, 8:08 am
Newsgroups: comp.lang.lisp
From: wb...@gmx.net (Wolfhard Buß)
Date: 24 Aug 2002 13:59:12 +0200
Local: Sat, Aug 24 2002 7:59 am
Subject: Re: LOOP discrepancy

Matthew Danish <mdan...@andrew.cmu.edu> writes:
> While testing out a loop on various implementations I came across the
> following discrepancy (boiled down):

> (loop repeat 3 for x from 0 finally (return x))

> => 2 in CMUCL, SBCL, and Allegro CL
> but
> => 3 in CLISP

Conforming implementations should complain about illegal forms,
especially about a misplaced repeat termination test clause (ttc).

 (loop for x from 0
       repeat 3
       finally (return x))  is legal Common Lisp.

The repeat iteration control clause (icc) "must precede any other loop
clauses, except initially, with, and named...", [CLHS 6.1.2.1
Iteration Control]. However, [CLHS 6.1.4 Termination Test Clauses]
states, that "Termination-test control constructs can be used anywhere
within the loop body".  Seems a bit inconsistent, for the repeat construct
is both, ttc and icc.

--
"I believe in the horse. The automobile is a passing phenomenon."
                              --  Kaiser Wilhelm II. (1859-1941)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »