[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)))
(macroexpand-all
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.
- New assoc-let package, Artur Malabarba, 2014/12/03
- Re: New assoc-let package, Ted Zlatanov, 2014/12/04
- Re: New assoc-let package, Artur Malabarba, 2014/12/04
- Re: New assoc-let package, Ted Zlatanov, 2014/12/04
- Re: New assoc-let package, Artur Malabarba, 2014/12/05
- Re: New assoc-let package, Artur Malabarba, 2014/12/05
- Re: New assoc-let package,
Christopher Schmidt <=
- Re: New assoc-let package, Artur Malabarba, 2014/12/06
- Re: New assoc-let package, Christopher Schmidt, 2014/12/06
- Re: New assoc-let package, Ted Zlatanov, 2014/12/07
- Re: New assoc-let package, Ted Zlatanov, 2014/12/05
- Re: New assoc-let package, Stefan Monnier, 2014/12/05
- Re: New assoc-let package, Ted Zlatanov, 2014/12/08
- Re: New assoc-let package, Artur Malabarba, 2014/12/08
- Re: New assoc-let package, Ted Zlatanov, 2014/12/08
- Re: New assoc-let package, Stefan Monnier, 2014/12/08
- Re: New assoc-let package, Stefan Monnier, 2014/12/08