unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#16353: 24.3.50; cl-position fails in 23.4.1
@ 2014-01-05 18:39 João Távora
  2014-01-06  1:14 ` Glenn Morris
  2014-01-25  5:20 ` Stefan Monnier
  0 siblings, 2 replies; 11+ messages in thread
From: João Távora @ 2014-01-05 18:39 UTC (permalink / raw)
  To: 16353

Hi,

This is GNU Emacs 23.4.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10)
 of 2012-09-08 on trouble, modified by Debian

Using that emacs and cl-lib-0.3.el this fails

/usr/bin/emacs --batch -Q -l cl-lib.el \
               --eval "(princ (cl-position 2 '(1 2 3)))"

where it should have printed "1". This works

/usr/bin/emacs --batch -Q -l cl-lib.el \
               --eval "(princ (cl-position-if #'(lambda (n) (eq n 2)) '(1 2 3)))"

All other cl-lib functions seem ok. This might be a debian bug.

João





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

* bug#16353: 24.3.50; cl-position fails in 23.4.1
  2014-01-05 18:39 bug#16353: 24.3.50; cl-position fails in 23.4.1 João Távora
@ 2014-01-06  1:14 ` Glenn Morris
  2014-01-06  1:16   ` Glenn Morris
  2014-01-06  4:08   ` Stefan Monnier
  2014-01-25  5:20 ` Stefan Monnier
  1 sibling, 2 replies; 11+ messages in thread
From: Glenn Morris @ 2014-01-06  1:14 UTC (permalink / raw)
  To: João Távora; +Cc: 16353

João Távora wrote:

> This is GNU Emacs 23.4.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10)
>  of 2012-09-08 on trouble, modified by Debian
>
> Using that emacs and cl-lib-0.3.el this fails
>
> /usr/bin/emacs --batch -Q -l cl-lib.el \
>                --eval "(princ (cl-position 2 '(1 2 3)))"

Namespace clash. cl-seq.el used to contain an internal function called
"cl-position". It was renamed to cl--position in 24.3.





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

* bug#16353: 24.3.50; cl-position fails in 23.4.1
  2014-01-06  1:14 ` Glenn Morris
@ 2014-01-06  1:16   ` Glenn Morris
  2014-01-06  4:08   ` Stefan Monnier
  1 sibling, 0 replies; 11+ messages in thread
From: Glenn Morris @ 2014-01-06  1:16 UTC (permalink / raw)
  To: João Távora; +Cc: 16353


PS you can expect the same issue with at least cl-adjoin.





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

* bug#16353: 24.3.50; cl-position fails in 23.4.1
  2014-01-06  1:14 ` Glenn Morris
  2014-01-06  1:16   ` Glenn Morris
@ 2014-01-06  4:08   ` Stefan Monnier
  2014-01-06 22:49     ` João Távora
  1 sibling, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2014-01-06  4:08 UTC (permalink / raw)
  To: Glenn Morris; +Cc: João Távora, 16353

>> This is GNU Emacs 23.4.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10)
>> of 2012-09-08 on trouble, modified by Debian
>> Using that emacs and cl-lib-0.3.el this fails
>> /usr/bin/emacs --batch -Q -l cl-lib.el \
>> --eval "(princ (cl-position 2 '(1 2 3)))"
> Namespace clash. cl-seq.el used to contain an internal function called
> "cl-position". It was renamed to cl--position in 24.3.

Indeed, thanks.  We need to adjust elpa's cl-lib.el accordingly (not
sure how best to do that, tho).


        Stefan





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

* bug#16353: 24.3.50; cl-position fails in 23.4.1
  2014-01-06  4:08   ` Stefan Monnier
@ 2014-01-06 22:49     ` João Távora
  2014-01-07  0:42       ` Stefan Monnier
  0 siblings, 1 reply; 11+ messages in thread
From: João Távora @ 2014-01-06 22:49 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16353

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>> This is GNU Emacs 23.4.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10)
>>> of 2012-09-08 on trouble, modified by Debian
>>> Using that emacs and cl-lib-0.3.el this fails
>>> /usr/bin/emacs --batch -Q -l cl-lib.el \
>>> --eval "(princ (cl-position 2 '(1 2 3)))"
>> Namespace clash. cl-seq.el used to contain an internal function called
>> "cl-position". It was renamed to cl--position in 24.3.
>
> Indeed, thanks.  We need to adjust elpa's cl-lib.el accordingly (not
> sure how best to do that, tho).

Can it be done so that it I can still use cl-position in emacs 23.4.1?
Maybe by including in cl-lib-0.4 some byte-recompilation of the
cl-seq.el functions that Glenn mentions:

   (defun remove* (cl-item cl-seq &rest cl-keys)
   (defun delete* (cl-item cl-seq &rest cl-keys)
   (defun cl-delete-duplicates (cl-seq cl-keys cl-copy)
   (defun substitute (cl-new cl-old cl-seq &rest cl-keys)
   (defun position (cl-item cl-seq &rest cl-keys)
   (defun search (cl-seq1 cl-seq2 &rest cl-keys)

This was only for cl-position.





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

* bug#16353: 24.3.50; cl-position fails in 23.4.1
  2014-01-06 22:49     ` João Távora
@ 2014-01-07  0:42       ` Stefan Monnier
  2014-01-07  9:21         ` João Távora
  0 siblings, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2014-01-07  0:42 UTC (permalink / raw)
  To: João Távora; +Cc: 16353

>>>> This is GNU Emacs 23.4.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10)
>>>> of 2012-09-08 on trouble, modified by Debian
>>>> Using that emacs and cl-lib-0.3.el this fails
>>>> /usr/bin/emacs --batch -Q -l cl-lib.el \
>>>> --eval "(princ (cl-position 2 '(1 2 3)))"
>>> Namespace clash. cl-seq.el used to contain an internal function called
>>> "cl-position". It was renamed to cl--position in 24.3.
>> Indeed, thanks.  We need to adjust elpa's cl-lib.el accordingly (not
>> sure how best to do that, tho).
> Can it be done so that it I can still use cl-position in emacs 23.4.1?

That would be best, yes.

> Maybe by including in cl-lib-0.4 some byte-recompilation of the
> cl-seq.el functions that Glenn mentions:

Could be.  It'd be good to first get a list of the all conflicting functions.


        Stefan





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

* bug#16353: 24.3.50; cl-position fails in 23.4.1
  2014-01-07  0:42       ` Stefan Monnier
@ 2014-01-07  9:21         ` João Távora
  2014-01-07 10:03           ` Helmut Eller
  0 siblings, 1 reply; 11+ messages in thread
From: João Távora @ 2014-01-07  9:21 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16353

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>>>> This is GNU Emacs 23.4.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10)
>>>>> of 2012-09-08 on trouble, modified by Debian
>>>>> Using that emacs and cl-lib-0.3.el this fails
>>>>> /usr/bin/emacs --batch -Q -l cl-lib.el \
>>>>> --eval "(princ (cl-position 2 '(1 2 3)))"
>>>> Namespace clash. cl-seq.el used to contain an internal function called
>>>> "cl-position". It was renamed to cl--position in 24.3.
>>> Indeed, thanks.  We need to adjust elpa's cl-lib.el accordingly (not
>>> sure how best to do that, tho).
>> Can it be done so that it I can still use cl-position in emacs 23.4.1?
>
> That would be best, yes.
>
>> Maybe by including in cl-lib-0.4 some byte-recompilation of the
>> cl-seq.el functions that Glenn mentions:
>
> Could be.

Can it be done without including the full definitions, e.g. via some
bytecode-changing trick? I'm asking because I could include this
workaround

> It'd be good to first get a list of the all conflicting functions.

Here's what I found

using cl-position:

   (defun remove* (cl-item cl-seq &rest cl-keys)
   (defun delete* (cl-item cl-seq &rest cl-keys)
   (defun cl-delete-duplicates (cl-seq cl-keys cl-copy)
   (defun cl-delete-duplicates (cl-seq cl-keys cl-copy)
   (defun cl-delete-duplicates (cl-seq cl-keys cl-copy)
   (defun substitute (cl-new cl-old cl-seq &rest cl-keys)
   (defun position (cl-item cl-seq &rest cl-keys)
   (defun search (cl-seq1 cl-seq2 &rest cl-keys)

these are all in cl-seq.el. using cl-adoing:
    
   (defun adjoin (cl-item cl-list &rest cl-keys)    in cl.el

using cl-delete-duplicates:

   (defun remove-duplicates (cl-seq &rest cl-keys) in cl-seq.el
   (defun delete-duplicates (cl-seq &rest cl-keys) in cl-seq.el

There are more internal functions prefixed with "cl-", but I don't think
they clash with aliases exported by cl-lib.

There's cl-macroexpand and cl-macroexpand-all, but I think these were
exported functions even back in 23.4.1.

João








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

* bug#16353: 24.3.50; cl-position fails in 23.4.1
  2014-01-07  9:21         ` João Távora
@ 2014-01-07 10:03           ` Helmut Eller
  2014-01-08  3:59             ` Stefan Monnier
  0 siblings, 1 reply; 11+ messages in thread
From: Helmut Eller @ 2014-01-07 10:03 UTC (permalink / raw)
  To: 16353

On Tue, Jan 07 2014, João Távora wrote:

> Can it be done without including the full definitions, e.g. via some
> bytecode-changing trick? I'm asking because I could include this
> workaround

Here's an idea for a solution: unintern the existing symbol, say
cl-postion, then intern "cl-position" again to create a second symbol.
defalias the second symbol.  Code loaded before the unintern dance, will
call the function of the uninterned symbols and code loaded afterwards
calls the function of the second symbol.  To make this work it's
important to load all code that must call uninterned symbols into
memory.  In practice that seems to be cl-seq.elc.

--- cl-lib-0.3.el.orig	2014-01-07 10:47:47.508299389 +0100
+++ cl-lib-0.3.el	2014-01-07 10:48:57.436296376 +0100
@@ -299,9 +299,20 @@
                dolist
                dotimes
                ))
-  (let ((new (if (consp fun) (prog1 (cdr fun) (setq fun (car fun)))
-               (intern (format "cl-%s" fun)))))
-    (unless (fboundp new) (defalias new fun))))
+  (let* ((old (cond ((consp fun) (car fun))
+		    (t fun)))
+	 (new (cond ((consp fun) (cdr fun))
+		    (t (intern (format "cl-%s" fun)))))
+	 (f (symbol-function old))
+	 (autoload (and (consp f) (eq (car f) 'autoload))))
+    (when autoload
+      (load (cadr f)))
+    (let ((new2 (cond ((fboundp new)
+		       (message "Conflict: %s" new)
+		       (unintern new)
+		       (intern (symbol-name new)))
+		      (t new))))
+      (defalias new2 old))))
 
 ;; `cl-labels' is not 100% compatible with `labels' when using dynamic scoping
 ;; (mostly because it does not turn lambdas that refer to those functions into






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

* bug#16353: 24.3.50; cl-position fails in 23.4.1
  2014-01-07 10:03           ` Helmut Eller
@ 2014-01-08  3:59             ` Stefan Monnier
  0 siblings, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2014-01-08  3:59 UTC (permalink / raw)
  To: Helmut Eller; +Cc: 16353

> Here's an idea for a solution: unintern the existing symbol, say
> cl-postion, then intern "cl-position" again to create a second symbol.

That was my initial idea as well, but there's the risk some code that
wants the cl-lib version of cl-position has already been `read' and
hence already refers to the incorrect symbol.

IOW, it's too hackish and fraught with problems.


        Stefan





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

* bug#16353: 24.3.50; cl-position fails in 23.4.1
  2014-01-05 18:39 bug#16353: 24.3.50; cl-position fails in 23.4.1 João Távora
  2014-01-06  1:14 ` Glenn Morris
@ 2014-01-25  5:20 ` Stefan Monnier
  2014-01-28  9:31   ` João Távora
  1 sibling, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2014-01-25  5:20 UTC (permalink / raw)
  To: João Távora; +Cc: 16353

> Using that emacs and cl-lib-0.3.el this fails
> /usr/bin/emacs --batch -Q -l cl-lib.el \
>                --eval "(princ (cl-position 2 '(1 2 3)))"
> where it should have printed "1". This works

I have pushed a cl-lib v0.4 (to appear hopefully to morrow) which should
resolve this problem, along with two other similar issues (with
cl-member and cl-delete-duplicates).  Thank you,


        Stefan





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

* bug#16353: 24.3.50; cl-position fails in 23.4.1
  2014-01-25  5:20 ` Stefan Monnier
@ 2014-01-28  9:31   ` João Távora
  0 siblings, 0 replies; 11+ messages in thread
From: João Távora @ 2014-01-28  9:31 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16353

> I have pushed a cl-lib v0.4 (to appear hopefully to morrow) which should
> resolve this problem, along with two other similar issues (with
> cl-member and cl-delete-duplicates).  Thank you,

Thank you!





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

end of thread, other threads:[~2014-01-28  9:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-05 18:39 bug#16353: 24.3.50; cl-position fails in 23.4.1 João Távora
2014-01-06  1:14 ` Glenn Morris
2014-01-06  1:16   ` Glenn Morris
2014-01-06  4:08   ` Stefan Monnier
2014-01-06 22:49     ` João Távora
2014-01-07  0:42       ` Stefan Monnier
2014-01-07  9:21         ` João Távora
2014-01-07 10:03           ` Helmut Eller
2014-01-08  3:59             ` Stefan Monnier
2014-01-25  5:20 ` Stefan Monnier
2014-01-28  9:31   ` João Távora

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).