all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* loop macro tutorial
@ 2009-06-17 16:06 Michal
  2009-06-17 16:26 ` Pascal J. Bourguignon
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Michal @ 2009-06-17 16:06 UTC (permalink / raw)
  To: help-gnu-emacs


Hallo group members.

with C-h f loop, i get:
Valid clauses are:
  for VAR from/upfrom/downfrom NUM to/upto/downto/above/below NUM by NUM,
  for VAR in LIST by FUNC, for VAR on LIST by FUNC, for VAR = INIT then EXPR,
  for VAR across ARRAY, repeat NUM, with VAR = INIT, while COND, until COND,
  always COND, never COND, thereis COND, collect EXPR into VAR,
  append EXPR into VAR, nconc EXPR into VAR, sum EXPR into VAR,
  count EXPR into VAR, maximize EXPR into VAR, minimize EXPR into VAR,
  if COND clause [and clause]... else clause [and clause...],
  unless COND clause [and clause]... else clause [and clause...],
  do EXPRS..., initially EXPRS..., finally EXPRS..., return EXPR,
  finally return EXPR, named NAME.


I does not tell me anything.
Do You know any sites that would explain 'loop' in more clear way?

best regards,
Michal


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: loop macro tutorial
  2009-06-17 16:06 loop macro tutorial Michal
@ 2009-06-17 16:26 ` Pascal J. Bourguignon
  2009-06-17 17:20   ` Drew Adams
                     ` (2 more replies)
  2009-06-17 18:18 ` Johan Bockgård
       [not found] ` <mailman.812.1245262811.2239.help-gnu-emacs@gnu.org>
  2 siblings, 3 replies; 7+ messages in thread
From: Pascal J. Bourguignon @ 2009-06-17 16:26 UTC (permalink / raw)
  To: help-gnu-emacs

Michal <rabbitko@tenbit.pl> writes:

> Hallo group members.
>
> with C-h f loop, i get:
> Valid clauses are:
>   for VAR from/upfrom/downfrom NUM to/upto/downto/above/below NUM by NUM,
>   for VAR in LIST by FUNC, for VAR on LIST by FUNC, for VAR = INIT then EXPR,
>   for VAR across ARRAY, repeat NUM, with VAR = INIT, while COND, until COND,
>   always COND, never COND, thereis COND, collect EXPR into VAR,
>   append EXPR into VAR, nconc EXPR into VAR, sum EXPR into VAR,
>   count EXPR into VAR, maximize EXPR into VAR, minimize EXPR into VAR,
>   if COND clause [and clause]... else clause [and clause...],
>   unless COND clause [and clause]... else clause [and clause...],
>   do EXPRS..., initially EXPRS..., finally EXPRS..., return EXPR,
>   finally return EXPR, named NAME.
>
>
> I does not tell me anything.
> Do You know any sites that would explain 'loop' in more clear way?

It comes from CLtL LOOP, which we find in Common Lisp too:

   http://www.lispworks.com/reference/HyperSpec/Body/m_loop.htm
   http://www.lispworks.com/documentation/HyperSpec/Body/06_a.htm


   http://www.gigamonkeys.com/book/loop-for-black-belts.html

There are some small differences between CLtL LOOP and Common Lisp
LOOP (eg CL LOOP doesn't accept finally return EXPR, you have to write
in CL finally (return EXPR)), and of course, there are the
restrictions of emacs lisp (only dynamic bindings, no lexical
binding), and you cannot use keywords for the loop key words, but
otherwise they're quite similar, so you can use the above documents to
learn how to use emacs lisp loop.

-- 
__Pascal Bourguignon__


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: loop macro tutorial
  2009-06-17 16:26 ` Pascal J. Bourguignon
@ 2009-06-17 17:20   ` Drew Adams
  2009-06-23 14:40   ` Michal
       [not found]   ` <mailman.805.1245259242.2239.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 7+ messages in thread
From: Drew Adams @ 2009-06-17 17:20 UTC (permalink / raw)
  To: 'Pascal J. Bourguignon', help-gnu-emacs

> > C-h f loop does not tell me anything.
> > Do You know any sites that would explain 'loop' in more clear way?
> 
> It comes from CLtL LOOP, which we find in Common Lisp too:
> 
>    http://www.lispworks.com/reference/HyperSpec/Body/m_loop.htm
>    http://www.lispworks.com/documentation/HyperSpec/Body/06_a.htm
>    http://www.gigamonkeys.com/book/loop-for-black-belts.html


Yes, but don't loop; iterate:

http://common-lisp.net/project/iterate/doc/Don_0027t-Loop-Iterate.html
http://common-lisp.net/project/iterate/doc/index.html#Top

From "Don't Loop, Iterate":

"`loop''s Pascalish syntax creates several problems.

1. First, many dyed-in-the-wool Lisp hackers simply find it ugly.

2. Second, it requires learning the syntax of a whole new sublanguage.

3. Third, the absence of parens makes it hard to parse, both by machine and,
more importantly, by human.

4. Fourth, one often has to consult the manual to recall lesser-used aspects of
the strange syntax.

5. Fifth, there is no good interface with the rest of Lisp, so `loop' clauses
cannot appear inside Lisp forms, and macros cannot expand to pieces of `loop'.

6. Sixth, pretty-printers and indenters that don't know about `loop' will
invariably display it wrongly.

This [6] is particularly a problem with program-editor indenters. A reasonably
clever indenter, like that of Gnu Emacs, can indent nearly any normal Lisp form
correctly, and can be easily customized for most new forms. But it can't at
present handle `loop'. The syntax of `iterate' was designed to keep parens to a
minimum, but conform close enough to Lisp so as not to confuse code-display
tools. Gnu Emacs indents `iterate' reasonably with no modifications.

Indenting is a mere annoyance; `loop''s lack of extensibility is a more serious
problem. The original `loop' was completely extensible, but the Symbolics
version only provides for the definition of new iteration-driving clauses, and
the Common Lisp specification does not have any extension mechanism."

(On the flip side, `loop' is built into Common Lisp, including the
byte-compiler. `iterate' is not.)

No, I don't know of an Emacs-Lisp implementation of `iterate'. But maybe the CL
implementation will work or can be made to work with Emacs Lisp's `cl.el'.
Dunno.

Personally, I use `while', `dolist', and `dotimes' (and `mapcar'...). ;-)





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: loop macro tutorial
  2009-06-17 16:06 loop macro tutorial Michal
  2009-06-17 16:26 ` Pascal J. Bourguignon
@ 2009-06-17 18:18 ` Johan Bockgård
       [not found] ` <mailman.812.1245262811.2239.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 7+ messages in thread
From: Johan Bockgård @ 2009-06-17 18:18 UTC (permalink / raw)
  To: help-gnu-emacs

Michal <rabbitko@tenbit.pl> writes:

> Do You know any sites that would explain 'loop' in more clear way?

(info "(cl) Loop Facility")  <-- C-x C-e





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: loop macro tutorial
       [not found] ` <mailman.812.1245262811.2239.help-gnu-emacs@gnu.org>
@ 2009-06-23 14:39   ` Michal
  0 siblings, 0 replies; 7+ messages in thread
From: Michal @ 2009-06-23 14:39 UTC (permalink / raw)
  To: help-gnu-emacs

bojohan+news@dd.chalmers.se (Johan Bockgård) writes:

> (info "(cl) Loop Facility")  <-- C-x C-e

Thank You for Your answer.
best regards
Michal


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: loop macro tutorial
  2009-06-17 16:26 ` Pascal J. Bourguignon
  2009-06-17 17:20   ` Drew Adams
@ 2009-06-23 14:40   ` Michal
       [not found]   ` <mailman.805.1245259242.2239.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 7+ messages in thread
From: Michal @ 2009-06-23 14:40 UTC (permalink / raw)
  To: help-gnu-emacs

pjb@informatimago.com (Pascal J. Bourguignon) writes:

> __Pascal Bourguignon__

Thank You for your answer


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: loop macro tutorial
       [not found]   ` <mailman.805.1245259242.2239.help-gnu-emacs@gnu.org>
@ 2009-06-23 14:41     ` Michal
  0 siblings, 0 replies; 7+ messages in thread
From: Michal @ 2009-06-23 14:41 UTC (permalink / raw)
  To: help-gnu-emacs

"Drew Adams" <drew.adams@oracle.com> writes:


Thank YOu Drew for Your answer


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-06-23 14:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-17 16:06 loop macro tutorial Michal
2009-06-17 16:26 ` Pascal J. Bourguignon
2009-06-17 17:20   ` Drew Adams
2009-06-23 14:40   ` Michal
     [not found]   ` <mailman.805.1245259242.2239.help-gnu-emacs@gnu.org>
2009-06-23 14:41     ` Michal
2009-06-17 18:18 ` Johan Bockgård
     [not found] ` <mailman.812.1245262811.2239.help-gnu-emacs@gnu.org>
2009-06-23 14:39   ` Michal

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.