[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New assoc-let package
From: |
Stefan Monnier |
Subject: |
Re: New assoc-let package |
Date: |
Wed, 03 Dec 2014 22:54:50 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) |
>>>>> "Artur" == Artur Malabarba <address@hidden> writes:
> Hi All,
> As part of another project, which involves excessive handing of
> alists, I wrote up a little macro which has turned out to be
> stupendously useful. I'm just checking whether this functionality is
> already offered somewhere, because if it isn't I'll make an Elpa
> package for it.
> Simply put, the macro takes an alist and a body, and makes the data of
> the alist accessible by just writing the car of the desired cell
> preceded by a dot.
> For instance, the following:
> (assoc-let alist
> (if (and .title .body)
> .body
> .site))
I don't know of any package that does something like that, no.
The way I'd have done it is
(cl-macrolet (((a field) `(cdr (assq ,field alist))))
(if (and (a title) (a body))
(a body)
(a site)))
-- Stefan
- New assoc-let package, Artur Malabarba, 2014/12/03
- Re: New assoc-let package,
Stefan Monnier <=
- 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, 2014/12/06
- Re: New assoc-let package, Artur Malabarba, 2014/12/06