unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: jari <jari.aalto@cante.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 7408@debbugs.gnu.org
Subject: bug#7408: Linux patchutils: Development of the project?
Date: Wed, 17 Nov 2010 06:47:29 +0200	[thread overview]
Message-ID: <20101117044729.GG17341@picasso.cante.net> (raw)
In-Reply-To: <jwv4obggbcg.fsf-monnier+emacs@gnu.org>

On 2010-11-16 17:21, Stefan Monnier wrote:
| >> subr.el has had a dolist definition since at least Emacs 21.x; ie 9 years.
| >> Therefore this cannot be a major issue in practice.
| > In my book it is still a bug, no matter how many years ago this bug were
| > introduced:
| 
| >     a: - To have two different implementations of same function.
| >     b: - To not be able to rely on uniform behavior.
| 
| You look at it the wrong way: the problem is not with dolist, it's that
| you use `return' which is a special form that's not defined in standard
| Elisp.

As I understand it, the fact that there are forms like these nowadays:

   unless
   when
   ...
   dolist

was because people used these constructs from CL so many time that
they were "re-introduced" directly in subr.el in order to prevent
loading CL.

However re-implementation of CL equivalent of 'dolist' did not meet
all the criteria. The 'return' has been integral part of 'dolist'
since the start.

| After (require 'cl), `return' gets defined and things work as you
| expect.

The implementation in subr.el::dolist does not have any support for
'return'.

It is not that 'return' gets defined, but what happens is that loading
CL clobbers that current definition pf 'dolist' by overwiting it with
its own implementation:

     Two different implementation, that are not compatible.

    $  diff -u  1.subr.el  2.cl-macs.el | grep -vE ";|declare"

    --- 1.subr.el	2010-11-17 06:31:53.000000000 +0200
    +++ 2.cl-macs.el	2010-11-17 06:32:31.000000000 +0200
    @@ -1,19 +1,15 @@
     (defmacro dolist (spec &rest body)
       "Loop over a list.
    -Evaluate BODY with VAR bound to each car from LIST, in turn.
    +Evaluate BODY with VAR bound to each `car' from LIST, in turn.
     Then evaluate RESULT to get return value, default nil.

     \(fn (VAR LIST [RESULT]) BODY...)"
    -  (let ((temp '--dolist-tail--))
    -    `(let ((,temp ,(nth 1 spec))
    -	   ,(car spec))
    -       (while ,temp
    -	 (setq ,(car spec) (car ,temp))
    -	 ,@body
    -	 (setq ,temp (cdr ,temp)))
    -       ,@(if (cdr (cdr spec))
    -	     `((setq ,(car spec) nil) ,@(cdr (cdr spec)))))))
    +  (let ((temp (make-symbol "--cl-dolist-temp--")))
>>  +    (list 'block nil
    +	  (list* 'let (list (list temp (nth 1 spec)) (car spec))
    +		 (list* 'while temp (list 'setq (car spec) (list 'car temp))
    +			(append body (list (list 'setq temp
    +						 (list 'cdr temp)))))
    +		 (if (cdr (cdr spec))
    +		     (cons (list 'setq (car spec) nil) (cdr (cdr spec)))
    +		   '(nil))))))

Naturally, loading CL also defines other things. But the fundamental
problem is two incompatible dolist implementations.

A possible solution:

  - Make subr.el::dolist repect return-block (nil-block)
  - have 'return' autoloaded

If user uses:

  - Plain dolist, nothing more is loaded (subr.el is used)
  - "return", it triggers autoloading CL (or parts of it).

Jari





  reply	other threads:[~2010-11-17  4:47 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <r6eo4w45.fsf@blue.sea.net>
     [not found] ` <1213200935.4147.62.camel@cyberelk.elk>
2010-10-16 13:42   ` bug#7227: re-search-forward goes infinite loop with dash inside [] Jari Aalto
2010-10-16 13:54     ` Andreas Schwab
2010-11-16 21:25   ` bug#7408: Linux patchutils: Development of the project? Jari Aalto
2010-11-16 21:59     ` Lennart Borgman
2010-11-16 22:21     ` Stefan Monnier
2010-11-17  4:47       ` jari [this message]
2010-11-17  8:25         ` Glenn Morris
2010-11-17 13:39         ` Stefan Monnier
2010-11-17 12:47       ` Štěpán Němec
2010-11-17 13:39         ` Stefan Monnier
2010-11-18 22:02           ` bug#7408: 23.2.1 dolist -- subr.el and cl-macs differ with nil-block return Jari Aalto
2010-11-21  5:45             ` Stefan Monnier
2010-11-21  9:08               ` jari
2010-11-21 17:49                 ` Eli Zaretskii
2010-11-21 18:51                 ` Stefan Monnier
2010-11-17 14:18         ` bug#7408: Linux patchutils: Development of the project? martin rudalics
2010-11-15 10:51 bug#7408: 23.2.1 dolist -- subr.el and cl-macs differ with nil-block return Jari Aalto
2010-11-21 23:19 ` bug#7408: Linux patchutils: Development of the project? MON KEY
  -- strict thread matches above, loose matches on Subject: below --
2010-10-16  9:16 bug#7227: re-search-forward goes infinite loop with dash inside [] Jari Aalto
2010-10-16 11:27 ` Andreas Schwab
2010-10-16 11:39 ` Andreas Röhler
2010-10-22  7:55 ` bug#7227: Close bts:gnu Jari Aalto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101117044729.GG17341@picasso.cante.net \
    --to=jari.aalto@cante.net \
    --cc=7408@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).