From: Jonathan LF King
Subject: Seeking a LOOP macro that doesn't loop
Date: 
Message-ID: <xndvgrhk3c8.fsf@maxwell.math.ufl.edu>
Dear All.  (I am a relative newcomer to CL.)  I have used the `loop'
macro, and mostly like its syntax.  I am wondering if someone has
written -or is willing to write- an eviscerated version (maybe called
PROGRAM) which retains keywords `with' `return' `when' `do' ..., but
removes all looping words `for' `collect' and so on.  
  [I suppose this is like BLOCK, but with different syntax.]

Of course, I could alias PROGRAM to LOOP, but I would like words such
as `for' to signal an error, to protect me from myself.
	Sincerely, -Jonathan King
-- 
Prof. Jonathan LF King	  Mathematics dept, Univ. of Florida
<······@math.ufl.edu>,	  <http://www.math.ufl.edu/~squash/>

From: Kent M Pitman
Subject: Re: Seeking a LOOP macro that doesn't loop
Date: 
Message-ID: <sfwn1cte63e.fsf@world.std.com>
Jonathan LF King <······@math.ufl.edu> writes:

> Dear All.  (I am a relative newcomer to CL.)  I have used the `loop'
> macro, and mostly like its syntax.  I am wondering if someone has
> written -or is willing to write- an eviscerated version (maybe called
> PROGRAM) which retains keywords `with' `return' `when' `do' ..., but
> removes all looping words `for' `collect' and so on.  
>   [I suppose this is like BLOCK, but with different syntax.]
> 
> Of course, I could alias PROGRAM to LOOP, but I would like words such
> as `for' to signal an error, to protect me from myself.
> 	Sincerely, -Jonathan King

Maybe something like this will suffice.  No, I didn't test it:

 (defvar *program-non-keywords* '(for collect)) ;etc.

 (defun program-non-keyword-p (x)
   (member x *program-non-keywords* :test #'string-equal))

 (defmacro program (&rest program-text)
   (dolist (program-text-element program-text)
     (check-type program-text-element (not (satisfies program-non-keyword-p))))
   `(loop repeat 1
	  ,@program-text))
From: Jonathan LF King
Subject: Re: Seeking a LOOP macro that doesn't loop
Date: 
Message-ID: <xnditmemo3a.fsf@maxwell.math.ufl.edu>
Kent M Pitman <······@world.std.com> writes:

> Jonathan LF King <······@math.ufl.edu> writes:
> 
> > Dear All.  (I am a relative newcomer to CL.)  I have used the `loop'
> > macro, and mostly like its syntax.  I am wondering if someone has
> > written -or is willing to write- an eviscerated version (maybe called
> > PROGRAM) which retains keywords `with' `return' `when' `do' ..., but
> > removes all looping words `for' `collect' and so on.  
> >   [I suppose this is like BLOCK, but with different syntax.]
> > 
> > Of course, I could alias PROGRAM to LOOP, but I would like words such
> > as `for' to signal an error, to protect me from myself.
> > 	Sincerely, -Jonathan King
> 
> Maybe something like this will suffice.  No, I didn't test it:
> 
>  (defvar *program-non-keywords* '(for collect)) ;etc.
> 
>  (defun program-non-keyword-p (x)
>    (member x *program-non-keywords* :test #'string-equal))
> 
>  (defmacro program (&rest program-text)
>    (dolist (program-text-element program-text)
>      (check-type program-text-element (not (satisfies program-non-keyword-p))))
>    `(loop repeat 1
> 	  ,@program-text))


Thank you cognoscenti Erik Naggum, Marco Antoniotti and Kent M Pitman for
your suggestions.
  You all seemed to suggest a wrapper *around* LOOP, rather than an actual
eviscerated LOOP.  Is producing a diminished LOOP
implementation-dependent?  --I had presumed that LOOP was a conventional
CL macro (albeit really complicated), written by some hard-working
public-spirited fellow.  Is there more than one LOOP, depending on which
CL one is running?

  Both Messieurs Naggum and Antoniotti mentioned that inserting a "repeat
1" might not be a good idea.  Other than the wasted variable and time it
takes to check it, what are the disadvantages?
	Sincerely, -Jonathan
-- 
Prof. Jonathan LF King	  Mathematics dept, Univ. of Florida
<······@math.ufl.edu>,	  <http://www.math.ufl.edu/~squash/>
From: Lieven Marchand
Subject: Re: Seeking a LOOP macro that doesn't loop
Date: 
Message-ID: <m3n1bqcm1u.fsf@localhost.localdomain>
Jonathan LF King <······@math.ufl.edu> writes:

>   You all seemed to suggest a wrapper *around* LOOP, rather than an actual
> eviscerated LOOP.  Is producing a diminished LOOP
> implementation-dependent?  --I had presumed that LOOP was a conventional
> CL macro (albeit really complicated), written by some hard-working
> public-spirited fellow.  Is there more than one LOOP, depending on which
> CL one is running?

It is a macro required by the standard. Redefining it in the
COMMON-LISP package isn't allowed, shadowing in CL-USER and redefining
is. The original implementation was mixed MIT/Symbolics I think. This
one is used by a lot of implementations and has a number of features
that didn't make the standard. Some implementations have one rewritten
from scratch.

It just seems easier to wrap loop than to write, debug and maintain
one's own version.

-- 
Lieven Marchand <···@wyrd.be>
Gla�r ok reifr skyli gumna hverr, unz sinn b��r bana.
From: Marco Antoniotti
Subject: Re: Seeking a LOOP macro that doesn't loop
Date: 
Message-ID: <y6cpuhopqjf.fsf@octagon.mrl.nyu.edu>
Erik Naggum <····@naggum.net> writes:

> * Jonathan LF King <······@math.ufl.edu>
> | I have used the `loop' macro, and mostly like its syntax.  I am wondering
> | if someone has written -or is willing to write- an eviscerated version
> | (maybe called PROGRAM) which retains keywords `with' `return' `when' `do'
> | ..., but removes all looping words `for' `collect' and so on.
> 
>   Well, you _may_ write (loop repeat 1 ...) and be guaranteed that at most
>   one iteration is performed.  I'm not sure this is a good idea in general.
> 

I agree with Erik, that this may not be a good idea, but you can write
somenthing along the lines of

	(defmacro program (&body forms)
	  `(loop ,@(extract-declarations-from forms)
                 repeat 1
                 ,@(extract-statements-from forms)))

Cheers

-- 
Marco Antoniotti =============================================================
NYU Bioinformatics Group			 tel. +1 - 212 - 998 3488
719 Broadway 12th Floor                          fax  +1 - 212 - 995 4122
New York, NY 10003, USA				 http://galt.mrl.nyu.edu/valis
             Like DNA, such a language [Lisp] does not go out of style.
			      Paul Graham, ANSI Common Lisp