[Top][All Lists]

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

Re: New assoc-let package

From: Christopher Schmidt
Subject: Re: New assoc-let package
Date: Sat, 6 Dec 2014 06:36:31 -0500 (EST)

Artur Malabarba <address@hidden> writes:
> ;;;###autoload
> (defmacro assoc-let (alist &rest body)
>   "Let-bind dotted symbols to their cdrs in ALIST and execute BODY.
> Dotted symbol is any symbol starting with a `.'.  Only those
> present in BODY are let-bound and this search is done at compile
> time.
> For instance, the following code
>   (assoc-let alist
>     (if (and .title .body)
>         .body
>       .site))
> expands to
>   (let ((.title (cdr (assoc 'title alist)))
>         (.body (cdr (assoc 'body alist)))
>         (.site (cdr (assoc 'site alist))))
>     (if (and .title .body)
>         .body
>       .site))"
>   (declare (indent 1) (debug t))
>   `(let ,(mapcar (lambda (x) `(,(car x) (cdr (assoc ',(cdr x) ,alist))))
                                          (alist-get ',(cdr x) ,alist)
>                  (delete-dups (assoc-let--deep-dot-search body)))
body) ?
>      ,@body))

I do not think adding assoc-let (assq-let?) to the core is a good idea.
The inability to meaningfully nest different assoc-let forms makes the
macro inflexible.  It is probably a good idea to make the dotvars
generalized variables.

reply via email to

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