all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Anaphoric lambda macro doesn't work anymore?
@ 2015-12-11 14:07 Constantin Kulikov
  2015-12-12 23:11 ` John Wiegley
  0 siblings, 1 reply; 8+ messages in thread
From: Constantin Kulikov @ 2015-12-11 14:07 UTC (permalink / raw
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 556 bytes --]

https://github.com/rolandwalker/anaphora/blob/master/anaphora.el#L337

```
(defmacro anaphoric-lambda (args &rest body)
  "Like `lambda', but the function may refer to itself as `self'.
ARGS and BODY are otherwise as documented for `lambda'."
  (declare (debug lambda)
           (indent defun))
  `(labels ((self ,args ,@body))
     #'self))
```

Some versions ago it was working(it seems to me that for 24.4 it works).
(With cl-labels and lexical-binding I can do it, but it is not compatible
with older emacses.)

My current emacs-version is 25.0.50.1.

[-- Attachment #2: Type: text/html, Size: 881 bytes --]

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

* Re: Anaphoric lambda macro doesn't work anymore?
  2015-12-11 14:07 Anaphoric lambda macro doesn't work anymore? Constantin Kulikov
@ 2015-12-12 23:11 ` John Wiegley
  2016-01-18  7:36   ` Constantin Kulikov
  0 siblings, 1 reply; 8+ messages in thread
From: John Wiegley @ 2015-12-12 23:11 UTC (permalink / raw
  To: Constantin Kulikov; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 417 bytes --]

>>>>> Constantin Kulikov <zxnotdead@gmail.com> writes:

> https://github.com/rolandwalker/anaphora/blob/master/anaphora.el#L337

I think your question should go to Roland Walker at GitHub, Constantin, until
you discover a bug in Emacs that we can address.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 629 bytes --]

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

* Re: Anaphoric lambda macro doesn't work anymore?
  2015-12-12 23:11 ` John Wiegley
@ 2016-01-18  7:36   ` Constantin Kulikov
  2016-01-18  9:10     ` Alexis
  0 siblings, 1 reply; 8+ messages in thread
From: Constantin Kulikov @ 2016-01-18  7:36 UTC (permalink / raw
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 860 bytes --]

> your question should go to Roland Walker at GitHub

I don't think so, I used that link to show that this(anaphoric lambda with
labels) pattern is used by someone other than me(actually it came from
common lisp of course https://en.wikipedia.org/wiki/Anaphoric_macro).
And it was working. Now it's broken. It happened because of changes in
emacs, so Roland Walker unlikely will be able to do something about it.
It's breaking change in emacs.

If someone interested -- here is the more/less working version that I use
now:

(when (version< emacs-version "24.4")
  (unless (fboundp 'self)
    (fset 'self nil)))
(defmacro alambda (args &rest body)
  "Anaphoric lambda."
  (declare (indent defun))
  `(lexical-let ((self))
     (setq self #'(lambda ,args
                    (cl-letf (((symbol-function 'self) self))
                      ,@body)))
     self))

[-- Attachment #2: Type: text/html, Size: 1241 bytes --]

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

* Re: Anaphoric lambda macro doesn't work anymore?
  2016-01-18  7:36   ` Constantin Kulikov
@ 2016-01-18  9:10     ` Alexis
  2016-01-18  9:32       ` Constantin Kulikov
  0 siblings, 1 reply; 8+ messages in thread
From: Alexis @ 2016-01-18  9:10 UTC (permalink / raw
  To: Constantin Kulikov; +Cc: emacs-devel


Constantin Kulikov <zxnotdead@gmail.com> writes:

>> your question should go to Roland Walker at GitHub
>
> I don't think so, I used that link to show that this(anaphoric 
> lambda with labels) pattern is used by someone other than 
> me(actually it came from common lisp of course 
> https://en.wikipedia.org/wiki/Anaphoric_macro).  And it was 
> working. Now it's broken. It happened because of changes in 
> emacs,

What do you mean by "it's broken"? Can you please provide a 
recipe, starting from 'emacs -Q', that demonstrates the problem 
you're encountering?


Alexis.



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

* Re: Anaphoric lambda macro doesn't work anymore?
  2016-01-18  9:10     ` Alexis
@ 2016-01-18  9:32       ` Constantin Kulikov
  2016-01-18 10:02         ` Alexis
  2016-01-23  4:38         ` Stefan Monnier
  0 siblings, 2 replies; 8+ messages in thread
From: Constantin Kulikov @ 2016-01-18  9:32 UTC (permalink / raw
  To: Alexis; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 288 bytes --]

emacs -version
GNU Emacs 25.0.50.1

emacs -Q

M-: (require 'cl) RET
M-: (defmacro alambda (args &rest body) `(labels ((self ,args ,@body))
#'self)) RET
M-: (funcall (alambda (a b) (if (a > b) (message "%s %s" a b) (self b a)))
1 2) RET

Debugger entered--Lisp error: (void-function self)

[-- Attachment #2: Type: text/html, Size: 416 bytes --]

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

* Re: Anaphoric lambda macro doesn't work anymore?
  2016-01-18  9:32       ` Constantin Kulikov
@ 2016-01-18 10:02         ` Alexis
  2016-01-18 10:41           ` Constantin Kulikov
  2016-01-23  4:38         ` Stefan Monnier
  1 sibling, 1 reply; 8+ messages in thread
From: Alexis @ 2016-01-18 10:02 UTC (permalink / raw
  To: Constantin Kulikov; +Cc: emacs-devel


Constantin Kulikov <zxnotdead@gmail.com> writes:

> emacs -version GNU Emacs 25.0.50.1
>
> emacs -Q
>
> M-: (require 'cl) RET M-: (defmacro alambda (args &rest body) 
> `(labels ((self ,args ,@body)) #'self)) RET M-: (funcall 
> (alambda (a b) (if (a > b) (message "%s %s" a b) (self b a))) 1 
> 2) RET
>
> Debugger entered--Lisp error: (void-function self)

Try using:

    (require 'cl-lib)

instead.

(Your if-condition should be:

    (> a b)

.)


Alexis.



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

* Re: Anaphoric lambda macro doesn't work anymore?
  2016-01-18 10:02         ` Alexis
@ 2016-01-18 10:41           ` Constantin Kulikov
  0 siblings, 0 replies; 8+ messages in thread
From: Constantin Kulikov @ 2016-01-18 10:41 UTC (permalink / raw
  To: Alexis; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 577 bytes --]

> Try using: (require 'cl-lib)
Hmm... I think it has issues and inconsistency with old behavior, however I
can not clearly remember why I don't like cl-labels.
One reason is that it will not work in old emacses and if I remember
correctly in files without -*- lexical-binding: t -*- header.

M-: (require 'cl-lib)
M-: (defmacro alambda (args &rest body) `(cl-labels ((self ,args ,@body))
#'self))
M-: (setq lexical-binding t)
M-: (funcall (alambda (a b) (cl-flet ((a (b c) (> b c))) (let ((> a)) (if
(a > b) (message "%s %s %s" a b (symbol-function 'self)) (self b a))))) 1 2)

[-- Attachment #2: Type: text/html, Size: 891 bytes --]

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

* Re: Anaphoric lambda macro doesn't work anymore?
  2016-01-18  9:32       ` Constantin Kulikov
  2016-01-18 10:02         ` Alexis
@ 2016-01-23  4:38         ` Stefan Monnier
  1 sibling, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2016-01-23  4:38 UTC (permalink / raw
  To: emacs-devel

> emacs -version
> GNU Emacs 25.0.50.1

> emacs -Q

> M-: (require 'cl) RET
> M-: (defmacro alambda (args &rest body) `(labels ((self ,args ,@body))
> #'self)) RET
> M-: (funcall (alambda (a b) (if (a > b) (message "%s %s" a b) (self b a)))
> 1 2) RET

> Debugger entered--Lisp error: (void-function self)

Indeed, looks like a plain bug: the #'self is not being replaced with
a reference to the `labels' defined function for some reason.
Can you make a proper bug report for it (i.e. send the above recipe
with M-x report-emacs-bug), so we get a tracking number?


        Stefan




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

end of thread, other threads:[~2016-01-23  4:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-11 14:07 Anaphoric lambda macro doesn't work anymore? Constantin Kulikov
2015-12-12 23:11 ` John Wiegley
2016-01-18  7:36   ` Constantin Kulikov
2016-01-18  9:10     ` Alexis
2016-01-18  9:32       ` Constantin Kulikov
2016-01-18 10:02         ` Alexis
2016-01-18 10:41           ` Constantin Kulikov
2016-01-23  4:38         ` Stefan Monnier

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.