From: Helmut Eller <eller.helmut@gmail.com>
To: Philipp Stephani <p.stephani2@gmail.com>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: let-alias
Date: Wed, 06 May 2020 23:27:40 +0200 [thread overview]
Message-ID: <m27dxo21pv.fsf@gmail.com> (raw)
In-Reply-To: <CAArVCkRMWtQ0bm7TjJG-Ra-UnCpGy9b0ZUuD8T3-hav3+RO=ew@mail.gmail.com> (Philipp Stephani's message of "Wed, 6 May 2020 22:31:57 +0200")
On Wed, May 06 2020, Philipp Stephani wrote:
>> Inside BODY, wherever NEW-NAME is used as function name it should
>> produce the same result as using OLD-NAME would. E.g.
>>
>> (let-alias ((c car)) (c x)) === (car x)
>> (let-alias ((c car)) #'c) === #'car
>> (let-alias ((c car)) (setf (c x) y)) === (setf (car x) y)
>> (let-alias ((when-not unless)) (when-not x y)) === (unless x y)
>>
>> Would somebody be opposed to such a new special form? Or better yet, is
>> there already some way to achieve this?
>
>
> If you don't mind the quoting, you can use (cl-flet ((c #'car)) ...)
Hmm, didn't even know that cl-flet had this feature. But the
bytecode for
(defun foo (x)
(cl-flet ((c #'car))
(c x)))
is
byte code for foo:
doc: ...
args: (arg1)
0 constant car
1 dup
2 stack-ref 2
3 call 1
4 return
while the bytecdoe for
(defun bar (x)
(car x))
is
byte code for bar:
doc: ...
args: (arg1)
0 dup
1 car
2 return
So it's obviously not doing what one would expect from an (zero cost)
alias. cl-flet also doesn't seem to work for the (setf (c x) ...)
example.
Helmut
prev parent reply other threads:[~2020-05-06 21:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-06 18:50 let-alias Helmut Eller
2020-05-06 20:31 ` let-alias Philipp Stephani
2020-05-06 20:39 ` let-alias Daniel Colascione
2020-05-06 21:29 ` let-alias Helmut Eller
2020-05-06 21:30 ` let-alias Daniel Colascione
2020-05-06 21:34 ` let-alias Helmut Eller
2020-05-06 21:27 ` Helmut Eller [this message]
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=m27dxo21pv.fsf@gmail.com \
--to=eller.helmut@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=p.stephani2@gmail.com \
/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).