emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs]


From: Göktuğ Kayaalp
Subject: Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs]
Date: Thu, 14 May 2020 19:30:37 +0300
User-agent: mu4e 0.9.18; emacs 28.0.50

On 2020-05-14 10:26 +03, Adrián Medraño Calvo wrote:
>> On 13. May 2020, at 23:03, Jonas Bernoulli <address@hidden> wrote:
>>
>> Stefan Monnier <address@hidden> writes:
>>
>>>> You said that there is a macro like this already in Emacs?
>>>
>>> I don't think it's in Emacs, but I remember seeing something like
>>> that somewhere.
>>
>> You were probably thinking of Oleh Krehel's short-lambda package.
>>
>> https://github.com/abo-abo/short-lambda
>
> There’s also dollar.el, by Göktuğ Kayaalp (CC’d):
>
>       https://github.com/cadadr/elisp/blob/devel/dollar.el

Hi, I’m the author of this package.  The parent poster has asked me
earlier today if I’d consider dollar.el being incorporated to Emacs. I’m
totally on board with it and can help to make it happen if you guys do
like it.

This whole thread is way too big for me to read in a timely manner, but
from what I get there’s an inclination towards the Clojure-like reader
macro syntax for this. Personally, I’m not that fond of it both
aesthetically and because it seems to be potentially a breaking change
in the parser. A macro that spits out a closure is better IMHO.

Below are some examples of usage from my init.el:

($ (with-current-buffer buf
     (hl-line-mode -1)))
---
;; If the explicit argument was omitted, this would throw because the
;; arglist of the generated closure would empty (no $... in body).
(let ((compilation-buffer-name-function ($ [_] "*Build Emacs Master*")))
  (compile "build-emacs-master.sh" t)))
---
(mapcar
 ($ (cons (buffer-name (window-buffer $1)) $1))
 (window-list))
---
;; A named argument
(add-to-list 'compilation-finish-functions
             ($ [_ status]
                (gk-send-desktop-notification "Compilation finished" status)))
---
;; Empty function (i.e. (lambda ())
(setf ring-bell-function ($))


The one trouble with dollar.el is that it currently doesn’t filter out
quoted expressions, so something like

($ ’($1))

expands to

(lambda
  ($1 &rest $_)
  (let
      (($*
        (cons
         (vector $1)
         $_)))
    '
    ($1)))

which is undesirable. I’ve been too lazy to fix it because it wouldn’t
really come up in practical use (WCGW...), but it shouldn’t be that
difficult to implement.

It also uses -flatten from dash.el, but adding a seq-flatten function
should be trivial.


> At first glance, I’d do away with &rest $_ and collecting the
> arguments in the $* variable, for better performance.  The former
> could be left to the named arguments mechanism.

It should be possible to get those arguments set up in the macroexpand
phase in order to minimise runtime impact.

We could’ve a simpler $ and a $$ which supports $* and $_ too.

> Göktuğ Kayaalp, would you be willing to include dollar.el in Emacs or
> GNU ELPA?

I’d love that to happen, and I’d prefer Emacs proper because IMHO this
is such an elementary and small feature that you wouldn’t want to need a
third party package for it.

If it’ll be ELPA nevertheless tho, could I use that version as the
upstream (i.e. push commits to the file on ELPA)? I don’t use package.el
so I’m not very up to date on how things are done on ELPA.


Cheers,
        -gk.

--
İ. Göktuğ Kayaalp / @cadadr / <https://www.gkayaalp.com/>
pgp:   024C 30DD 597D 142B 49AC 40EB 465C D949 B101 2427



reply via email to

[Prev in Thread] Current Thread [Next in Thread]