Quelqu'un peut-il me rappeler ce que signifie la notation #' ?
J'ai chercher la notation #' dans les 868 page du « GNU Emacs Lisp
Reference Manual » sans rien trouver.
Par exemple, on trouve dans pas mal de code la notation #'(lambda et il
me semble bien que le #' ne sert à rien dans ce cas.
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Damien Wyart
* Ph. Ivaldi in fr.comp.applications.emacs:
Quelqu'un peut-il me rappeler ce que signifie la notation #' ? J'ai chercher la notation #' dans les 868 page du « GNU Emacs Lisp Reference Manual » sans rien trouver.
Elle est expliquée dans ce paragraphe : http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Anonymous-Functions
En gros, ' c'est (quote et #' c'est (function.
Par exemple, on trouve dans pas mal de code la notation #'(lambda et il me semble bien que le #' ne sert à rien dans ce cas.
En effet, je n'ai pas joué avec ça depuis longtemps mais le paragraphe cité indique que lambda implique function.
-- DW
* Ph. Ivaldi <invalid@dev.null> in fr.comp.applications.emacs:
Quelqu'un peut-il me rappeler ce que signifie la notation #' ?
J'ai chercher la notation #' dans les 868 page du « GNU Emacs Lisp
Reference Manual » sans rien trouver.
Elle est expliquée dans ce paragraphe :
http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Anonymous-Functions
En gros, ' c'est (quote et #' c'est (function.
Par exemple, on trouve dans pas mal de code la notation #'(lambda et
il me semble bien que le #' ne sert à rien dans ce cas.
En effet, je n'ai pas joué avec ça depuis longtemps mais le paragraphe
cité indique que lambda implique function.
Quelqu'un peut-il me rappeler ce que signifie la notation #' ? J'ai chercher la notation #' dans les 868 page du « GNU Emacs Lisp Reference Manual » sans rien trouver.
Elle est expliquée dans ce paragraphe : http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Anonymous-Functions
En gros, ' c'est (quote et #' c'est (function.
Par exemple, on trouve dans pas mal de code la notation #'(lambda et il me semble bien que le #' ne sert à rien dans ce cas.
En effet, je n'ai pas joué avec ça depuis longtemps mais le paragraphe cité indique que lambda implique function.
-- DW
Ph. Ivaldi
Le 22 février 2010, Damien Wyart écrivit :
* Ph. Ivaldi in fr.comp.applications.emacs:
Quelqu'un peut-il me rappeler ce que signifie la notation #' ? J'ai chercher la notation #' dans les 868 page du « GNU Emacs Lisp Reference Manual » sans rien trouver.
Elle est expliquée dans ce paragraphe : http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Anonymous-Functions
Merci. J'avais bêtement cherché #' dans le pdf avec xpdf qui ne trouve rien. Avec Acroread ça marche.
Il est quand même étonnant que des programmeurs très compétents écrivent #'(lambda…). -- Philippe Ivaldi. http://www.piprime.fr/
Le 22 février 2010, Damien Wyart écrivit :
* Ph. Ivaldi <invalid@dev.null> in fr.comp.applications.emacs:
Quelqu'un peut-il me rappeler ce que signifie la notation #' ?
J'ai chercher la notation #' dans les 868 page du « GNU Emacs Lisp
Reference Manual » sans rien trouver.
Elle est expliquée dans ce paragraphe :
http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Anonymous-Functions
Merci.
J'avais bêtement cherché #' dans le pdf avec xpdf qui ne trouve rien.
Avec Acroread ça marche.
Il est quand même étonnant que des programmeurs très compétents écrivent
#'(lambda…).
--
Philippe Ivaldi.
http://www.piprime.fr/
Quelqu'un peut-il me rappeler ce que signifie la notation #' ? J'ai chercher la notation #' dans les 868 page du « GNU Emacs Lisp Reference Manual » sans rien trouver.
Elle est expliquée dans ce paragraphe : http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Anonymous-Functions
Merci. J'avais bêtement cherché #' dans le pdf avec xpdf qui ne trouve rien. Avec Acroread ça marche.
Il est quand même étonnant que des programmeurs très compétents écrivent #'(lambda…). -- Philippe Ivaldi. http://www.piprime.fr/
Damien Wyart
* Ph. Ivaldi in fr.comp.applications.emacs:
Il est quand m¨ºme ¨¦tonnant que des programmeurs tr¨¨s comp ¨¦tents ¨¦crivent #'(lambda¡).
Je me suis replong¨¦ dans ce que j'avais archiv¨¦ ¨¤ ce sujet ( je n'en ai pas eu le temps hier soir), et le th¨¨me est quand m¨ºme assez ¨ ¦pineux, avec des querelles d'expert revenant p¨¦riodiquement.
Voici quelques liens pour approfondir la question :
http://www.emacswiki.org/emacs/QuotedLambda http://groups.google.fr/group/fr.comp.applications.emacs/browse_thread/thre ad/68adc05bdf1b5c5/ http://groups.google.fr/group/comp.lang.lisp/browse_thread/thread/e16b9409b 49a8f42/ http://groups.google.fr/group/comp.lang.lisp/browse_thread/thread/1e8797055 c4e1c45/ http://www.gigamonkeys.com/book/functions.html (la note 13, tout en bas de la page)
-- DW
* Ph. Ivaldi <invalid@dev.null> in fr.comp.applications.emacs:
Il est quand m¨ºme ¨¦tonnant que des programmeurs tr¨¨s comp ¨¦tents
¨¦crivent #'(lambda¡).
Je me suis replong¨¦ dans ce que j'avais archiv¨¦ ¨¤ ce sujet ( je n'en ai
pas eu le temps hier soir), et le th¨¨me est quand m¨ºme assez ¨ ¦pineux,
avec des querelles d'expert revenant p¨¦riodiquement.
Voici quelques liens pour approfondir la question :
http://www.emacswiki.org/emacs/QuotedLambda
http://groups.google.fr/group/fr.comp.applications.emacs/browse_thread/thre ad/68adc05bdf1b5c5/
http://groups.google.fr/group/comp.lang.lisp/browse_thread/thread/e16b9409b 49a8f42/
http://groups.google.fr/group/comp.lang.lisp/browse_thread/thread/1e8797055 c4e1c45/
http://www.gigamonkeys.com/book/functions.html (la note 13, tout en bas de la page)
Il est quand m¨ºme ¨¦tonnant que des programmeurs tr¨¨s comp ¨¦tents ¨¦crivent #'(lambda¡).
Je me suis replong¨¦ dans ce que j'avais archiv¨¦ ¨¤ ce sujet ( je n'en ai pas eu le temps hier soir), et le th¨¨me est quand m¨ºme assez ¨ ¦pineux, avec des querelles d'expert revenant p¨¦riodiquement.
Voici quelques liens pour approfondir la question :
http://www.emacswiki.org/emacs/QuotedLambda http://groups.google.fr/group/fr.comp.applications.emacs/browse_thread/thre ad/68adc05bdf1b5c5/ http://groups.google.fr/group/comp.lang.lisp/browse_thread/thread/e16b9409b 49a8f42/ http://groups.google.fr/group/comp.lang.lisp/browse_thread/thread/1e8797055 c4e1c45/ http://www.gigamonkeys.com/book/functions.html (la note 13, tout en bas de la page)
-- DW
Ph. Ivaldi
Le 23 février 2010, Damien Wyart écrivit :
Voici quelques liens pour approfondir la question : […]
Voici ce que j'en ai rapidement extraits/compris.
http://www.emacswiki.org/emacs/QuotedLambda : So the moral of the story seems to be: Use (lambda …) or #’(lambda …) for fastest possible byte-compiled lambda expressions, but avoid ’(lambda …).
#'(lambda ...) => bien, mais compliqué '(lambda ...) => mal (lambda ...) => bien et simple.
Oui. Mais '(lambda ...) n'est pas forcément mal. Ça dépend de ce qu'on veut faire. '(lambda (x) (+ 3 x)) est une list (facile à modifier) #'(lambda (x) (+ 3 x)) est une function
http://groups.google.fr/group/comp.lang.lisp/browse_thread/thread/1e8797055c4e1c45/ : (lambda…) ne sait pas toujours développé en (function (lambda…)), donc historiquement on utilise #'(lambda…) « #'(lambda ...) it is the same as (function (lambda ...)) » sauf que « ((lambda (x) (+ x 5)) 10) => 15 ((function (lambda (x) (+ x 5))) 10) => illegal function call error »
Là ça semble important mais je ne comprends strictement rien, à part que j'ai intérêt à m'en souvenir :D 8<------8<------8<------8<------8<------8<------8<------8<------ The former is a macro which expands into the latter. The latter includes the #' _reader macro_ that expands to (function (lambda (x) (+ 3 x))). FUNCTION is a special form. Once you've grokked how this can work when it seems 'obvious' that the second form recursively expands itself, you'll understand a great bit more about CL's evaluation model.
This is also one of the most FAQs in c.l.l, so try the archives next time first. :) 8<------8<------8<------8<------8<------8<------8<------8<------
http://www.gigamonkeys.com/book/functions.html (la note 13, tout en bas de la page): In other words, it's pure syntactic sugar. Most folks either always use #' before LAMBDA expressions in value positions or never do. In this book, I always use #'.
Mais d'un point de vue logique (funcall (lambda (...) ...)) et incorrect. « the symbol LAMBDA was a special syntactic construct that Lisp recognized as a kind of function name. (funcall (lambda (...) ...)) would be illegal because FUNCALL is a function and the normal evaluation rule for a function call would require that the LAMBDA expression be evaluated »
Autrement dit, pour respecter le standard, (funcall (lambda (...) ...)) devrait d'abord évaluer (lambda…) et donc la syntaxe ne fait plus sens.
Merci pour ces liens, -- Philippe Ivaldi. http://www.piprime.fr/
Le 23 février 2010, Damien Wyart écrivit :
Voici quelques liens pour approfondir la question :
[…]
Voici ce que j'en ai rapidement extraits/compris.
http://www.emacswiki.org/emacs/QuotedLambda :
So the moral of the story seems to be: Use (lambda …) or #’(lambda …)
for fastest possible byte-compiled lambda expressions, but avoid
’(lambda …).
#'(lambda ...) => bien, mais compliqué
'(lambda ...) => mal
(lambda ...) => bien et simple.
Oui. Mais '(lambda ...) n'est pas forcément mal. Ça dépend de ce
qu'on veut faire.
'(lambda (x) (+ 3 x)) est une list (facile à modifier)
#'(lambda (x) (+ 3 x)) est une function
http://groups.google.fr/group/comp.lang.lisp/browse_thread/thread/1e8797055c4e1c45/ :
(lambda…) ne sait pas toujours développé en (function (lambda…)), donc
historiquement on utilise #'(lambda…)
« #'(lambda ...) it is the same as (function (lambda ...)) » sauf que
« ((lambda (x) (+ x 5)) 10) => 15
((function (lambda (x) (+ x 5))) 10) => illegal function call error »
Là ça semble important mais je ne comprends strictement rien, à part que
j'ai intérêt à m'en souvenir :D
8<------8<------8<------8<------8<------8<------8<------8<------
The former is a macro which expands into the latter. The latter
includes the #' _reader macro_ that expands to (function (lambda (x)
(+ 3 x))). FUNCTION is a special form. Once you've grokked how this
can work when it seems 'obvious' that the second form recursively
expands itself, you'll understand a great bit more about CL's
evaluation model.
This is also one of the most FAQs in c.l.l, so try the archives next
time first. :)
8<------8<------8<------8<------8<------8<------8<------8<------
http://www.gigamonkeys.com/book/functions.html (la note 13, tout en bas
de la page):
In other words, it's pure syntactic sugar. Most folks either always use
#' before LAMBDA expressions in value positions or never do. In this
book, I always use #'.
Mais d'un point de vue logique (funcall (lambda (...) ...)) et incorrect.
« the symbol LAMBDA was a special syntactic construct that Lisp
recognized as a kind of function name.
(funcall (lambda (...) ...)) would be illegal because FUNCALL is a
function and the normal evaluation rule for a function call would
require that the LAMBDA expression be evaluated »
Autrement dit, pour respecter le standard, (funcall (lambda (...) ...))
devrait d'abord évaluer (lambda…) et donc la syntaxe ne fait plus sens.
Merci pour ces liens,
--
Philippe Ivaldi.
http://www.piprime.fr/
Voici quelques liens pour approfondir la question : […]
Voici ce que j'en ai rapidement extraits/compris.
http://www.emacswiki.org/emacs/QuotedLambda : So the moral of the story seems to be: Use (lambda …) or #’(lambda …) for fastest possible byte-compiled lambda expressions, but avoid ’(lambda …).
#'(lambda ...) => bien, mais compliqué '(lambda ...) => mal (lambda ...) => bien et simple.
Oui. Mais '(lambda ...) n'est pas forcément mal. Ça dépend de ce qu'on veut faire. '(lambda (x) (+ 3 x)) est une list (facile à modifier) #'(lambda (x) (+ 3 x)) est une function
http://groups.google.fr/group/comp.lang.lisp/browse_thread/thread/1e8797055c4e1c45/ : (lambda…) ne sait pas toujours développé en (function (lambda…)), donc historiquement on utilise #'(lambda…) « #'(lambda ...) it is the same as (function (lambda ...)) » sauf que « ((lambda (x) (+ x 5)) 10) => 15 ((function (lambda (x) (+ x 5))) 10) => illegal function call error »
Là ça semble important mais je ne comprends strictement rien, à part que j'ai intérêt à m'en souvenir :D 8<------8<------8<------8<------8<------8<------8<------8<------ The former is a macro which expands into the latter. The latter includes the #' _reader macro_ that expands to (function (lambda (x) (+ 3 x))). FUNCTION is a special form. Once you've grokked how this can work when it seems 'obvious' that the second form recursively expands itself, you'll understand a great bit more about CL's evaluation model.
This is also one of the most FAQs in c.l.l, so try the archives next time first. :) 8<------8<------8<------8<------8<------8<------8<------8<------
http://www.gigamonkeys.com/book/functions.html (la note 13, tout en bas de la page): In other words, it's pure syntactic sugar. Most folks either always use #' before LAMBDA expressions in value positions or never do. In this book, I always use #'.
Mais d'un point de vue logique (funcall (lambda (...) ...)) et incorrect. « the symbol LAMBDA was a special syntactic construct that Lisp recognized as a kind of function name. (funcall (lambda (...) ...)) would be illegal because FUNCALL is a function and the normal evaluation rule for a function call would require that the LAMBDA expression be evaluated »
Autrement dit, pour respecter le standard, (funcall (lambda (...) ...)) devrait d'abord évaluer (lambda…) et donc la syntaxe ne fait plus sens.
Merci pour ces liens, -- Philippe Ivaldi. http://www.piprime.fr/
Vincent Belaïche
Salut Philippe,
juste pour préciser que lambda étant une macro qui s'auto-quote
(c'est à dire que l'évaluation de (lamda (x) x) donne la même chose que celle de (quote (lambda (x) x)) )
tu n'es pas obligé que quoter une lambda expression lorsque tu la passes à un funcall.
Sinon je ne suis pas d'accord qu'il faut absolument éviter
`(lambda (...) ....)
tout dépend de ce que tu veux faire: dans certains cas on peut vouloir construire une fonction à partir de l'évaluation de certaines expressions...
À+, Vincent.
Ph. Ivaldi a écrit :
Le 23 février 2010, Damien Wyart écrivit :
Voici quelques liens pour approfondir la question : […]
Voici ce que j'en ai rapidement extraits/compris.
http://www.emacswiki.org/emacs/QuotedLambda : So the moral of the story seems to be: Use (lambda …) or #’(lambda …) for fastest possible byte-compiled lambda expressions, but avoid ’(lambda …).
#'(lambda ...) => bien, mais compliqué '(lambda ...) => mal (lambda ...) => bien et simple.
Oui. Mais '(lambda ...) n'est pas forcément mal. Ça dépend de ce qu'on veut faire. '(lambda (x) (+ 3 x)) est une list (facile à modifier) #'(lambda (x) (+ 3 x)) est une function
http://groups.google.fr/group/comp.lang.lisp/browse_thread/thread/1e8797055c4e1c45/ : (lambda…) ne sait pas toujours développé en (function (lambda…)), donc historiquement on utilise #'(lambda…) « #'(lambda ...) it is the same as (function (lambda ...)) » sauf que « ((lambda (x) (+ x 5)) 10) => 15 ((function (lambda (x) (+ x 5))) 10) => illegal function call error »
Là ça semble important mais je ne comprends strictement rien, à part que j'ai intérêt à m'en souvenir :D 8<------8<------8<------8<------8<------8<------8<------8<------ The former is a macro which expands into the latter. The latter includes the #' _reader macro_ that expands to (function (lambda (x) (+ 3 x))). FUNCTION is a special form. Once you've grokked how this can work when it seems 'obvious' that the second form recursively expands itself, you'll understand a great bit more about CL's evaluation model.
This is also one of the most FAQs in c.l.l, so try the archives next time first. :) 8<------8<------8<------8<------8<------8<------8<------8<------
http://www.gigamonkeys.com/book/functions.html (la note 13, tout en bas de la page): In other words, it's pure syntactic sugar. Most folks either always use #' before LAMBDA expressions in value positions or never do. In this book, I always use #'.
Mais d'un point de vue logique (funcall (lambda (...) ...)) et incorrect. « the symbol LAMBDA was a special syntactic construct that Lisp recognized as a kind of function name. (funcall (lambda (...) ...)) would be illegal because FUNCALL is a function and the normal evaluation rule for a function call would require that the LAMBDA expression be evaluated »
Autrement dit, pour respecter le standard, (funcall (lambda (...) ...)) devrait d'abord évaluer (lambda…) et donc la syntaxe ne fait plus sens.
Merci pour ces liens,
Salut Philippe,
juste pour préciser que lambda étant une macro qui s'auto-quote
(c'est à dire que l'évaluation de (lamda (x) x) donne la même chose que
celle de (quote (lambda (x) x)) )
tu n'es pas obligé que quoter une lambda expression lorsque tu la passes
à un funcall.
Sinon je ne suis pas d'accord qu'il faut absolument éviter
`(lambda (...) ....)
tout dépend de ce que tu veux faire: dans certains cas on peut vouloir
construire une fonction à partir de l'évaluation de certaines expressions...
À+,
Vincent.
Ph. Ivaldi a écrit :
Le 23 février 2010, Damien Wyart écrivit :
Voici quelques liens pour approfondir la question :
[…]
Voici ce que j'en ai rapidement extraits/compris.
http://www.emacswiki.org/emacs/QuotedLambda :
So the moral of the story seems to be: Use (lambda …) or #’(lambda …)
for fastest possible byte-compiled lambda expressions, but avoid
’(lambda …).
#'(lambda ...) => bien, mais compliqué
'(lambda ...) => mal
(lambda ...) => bien et simple.
Oui. Mais '(lambda ...) n'est pas forcément mal. Ça dépend de ce
qu'on veut faire.
'(lambda (x) (+ 3 x)) est une list (facile à modifier)
#'(lambda (x) (+ 3 x)) est une function
http://groups.google.fr/group/comp.lang.lisp/browse_thread/thread/1e8797055c4e1c45/ :
(lambda…) ne sait pas toujours développé en (function (lambda…)), donc
historiquement on utilise #'(lambda…)
« #'(lambda ...) it is the same as (function (lambda ...)) » sauf que
« ((lambda (x) (+ x 5)) 10) => 15
((function (lambda (x) (+ x 5))) 10) => illegal function call error »
Là ça semble important mais je ne comprends strictement rien, à part que
j'ai intérêt à m'en souvenir :D
8<------8<------8<------8<------8<------8<------8<------8<------
The former is a macro which expands into the latter. The latter
includes the #' _reader macro_ that expands to (function (lambda (x)
(+ 3 x))). FUNCTION is a special form. Once you've grokked how this
can work when it seems 'obvious' that the second form recursively
expands itself, you'll understand a great bit more about CL's
evaluation model.
This is also one of the most FAQs in c.l.l, so try the archives next
time first. :)
8<------8<------8<------8<------8<------8<------8<------8<------
http://www.gigamonkeys.com/book/functions.html (la note 13, tout en bas
de la page):
In other words, it's pure syntactic sugar. Most folks either always use
#' before LAMBDA expressions in value positions or never do. In this
book, I always use #'.
Mais d'un point de vue logique (funcall (lambda (...) ...)) et incorrect.
« the symbol LAMBDA was a special syntactic construct that Lisp
recognized as a kind of function name.
(funcall (lambda (...) ...)) would be illegal because FUNCALL is a
function and the normal evaluation rule for a function call would
require that the LAMBDA expression be evaluated »
Autrement dit, pour respecter le standard, (funcall (lambda (...) ...))
devrait d'abord évaluer (lambda…) et donc la syntaxe ne fait plus sens.
juste pour préciser que lambda étant une macro qui s'auto-quote
(c'est à dire que l'évaluation de (lamda (x) x) donne la même chose que celle de (quote (lambda (x) x)) )
tu n'es pas obligé que quoter une lambda expression lorsque tu la passes à un funcall.
Sinon je ne suis pas d'accord qu'il faut absolument éviter
`(lambda (...) ....)
tout dépend de ce que tu veux faire: dans certains cas on peut vouloir construire une fonction à partir de l'évaluation de certaines expressions...
À+, Vincent.
Ph. Ivaldi a écrit :
Le 23 février 2010, Damien Wyart écrivit :
Voici quelques liens pour approfondir la question : […]
Voici ce que j'en ai rapidement extraits/compris.
http://www.emacswiki.org/emacs/QuotedLambda : So the moral of the story seems to be: Use (lambda …) or #’(lambda …) for fastest possible byte-compiled lambda expressions, but avoid ’(lambda …).
#'(lambda ...) => bien, mais compliqué '(lambda ...) => mal (lambda ...) => bien et simple.
Oui. Mais '(lambda ...) n'est pas forcément mal. Ça dépend de ce qu'on veut faire. '(lambda (x) (+ 3 x)) est une list (facile à modifier) #'(lambda (x) (+ 3 x)) est une function
http://groups.google.fr/group/comp.lang.lisp/browse_thread/thread/1e8797055c4e1c45/ : (lambda…) ne sait pas toujours développé en (function (lambda…)), donc historiquement on utilise #'(lambda…) « #'(lambda ...) it is the same as (function (lambda ...)) » sauf que « ((lambda (x) (+ x 5)) 10) => 15 ((function (lambda (x) (+ x 5))) 10) => illegal function call error »
Là ça semble important mais je ne comprends strictement rien, à part que j'ai intérêt à m'en souvenir :D 8<------8<------8<------8<------8<------8<------8<------8<------ The former is a macro which expands into the latter. The latter includes the #' _reader macro_ that expands to (function (lambda (x) (+ 3 x))). FUNCTION is a special form. Once you've grokked how this can work when it seems 'obvious' that the second form recursively expands itself, you'll understand a great bit more about CL's evaluation model.
This is also one of the most FAQs in c.l.l, so try the archives next time first. :) 8<------8<------8<------8<------8<------8<------8<------8<------
http://www.gigamonkeys.com/book/functions.html (la note 13, tout en bas de la page): In other words, it's pure syntactic sugar. Most folks either always use #' before LAMBDA expressions in value positions or never do. In this book, I always use #'.
Mais d'un point de vue logique (funcall (lambda (...) ...)) et incorrect. « the symbol LAMBDA was a special syntactic construct that Lisp recognized as a kind of function name. (funcall (lambda (...) ...)) would be illegal because FUNCALL is a function and the normal evaluation rule for a function call would require that the LAMBDA expression be evaluated »
Autrement dit, pour respecter le standard, (funcall (lambda (...) ...)) devrait d'abord évaluer (lambda…) et donc la syntaxe ne fait plus sens.