[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Clojure-like syntactic sugar for an anonymous function liter
From: |
Phillip Lord |
Subject: |
Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal |
Date: |
Fri, 23 Jan 2015 11:53:35 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
Oleh <address@hidden> writes:
>>> Maybe we could introduce a more limited form of reader macros.
>>> E.g. allow #<letter><sexp> and make the reader return
>>>
>>> (funcall (cdr (assq <letter> reader-macro-alist)) <sexp>)
>>
>> Would it not be possible to have the reader return a macro which could
>> do the cdr and assq at compile time and obviate the need for funcall?
>> This would be faster. It means that changes to reader-macro-alist
>> wouldn't be reflected in code till it was re-evaled.
>>
>> My main concern with this as a proposal is that <letter> is a fairly
>> small namespace. There is a lot of possibility for pretty disasterous
>> clashes if this gets used in the wild.
>
> How about this:
>
> #a(...) is (reader-macro-a ...)
> #b(...) is (reader-macro-b ...)
>
> ...
>
> #z(...) is (reader-macro-z ...)
>
> This would be easy to implement, since this is just an extension of
> the `backquote' and `short-lambda' method to 26 reader macros.
That would work, but I don't think it's necessary -- if there is a
compile time lookup, it's just as efficient. More over, it's not
necessarily 26 macros -- if emacs is multi-byte then there are a lot of
potential macros.
It would even be possible to do
#symbol <form>
where symbol is any length, which would help to avoid the namespace
problem -- this is pretty much the expressivity of tagged literals in
Clojure. Although, my experience in Clojure is that few people use them,
because they must be namespaced so take too long to type (and for other
reasons I think).
> The core could take over some of them, and leave the rest open to the
> public.
I'd agree that single (and probably two) letter symbols would have to be
restricted to the core by convention.
Phil
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, (continued)
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Stefan Monnier, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Oleh, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Daniel Colascione, 2015/01/22
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Stefan Monnier, 2015/01/22
- Reader macros (Was: Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal), Daniel Colascione, 2015/01/22
- Re: Reader macros, David Kastrup, 2015/01/23
- Re: Reader macros, Daniel Colascione, 2015/01/23
- Re: Reader macros, David Kastrup, 2015/01/23
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Phillip Lord, 2015/01/23
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Oleh, 2015/01/23
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal,
Phillip Lord <=
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Daniel Colascione, 2015/01/23
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Daniel Colascione, 2015/01/23
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Phillip Lord, 2015/01/23
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Stefan Monnier, 2015/01/23
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Stefan Monnier, 2015/01/23
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Phillip Lord, 2015/01/23
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Oleh, 2015/01/23
- Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Stefan Monnier, 2015/01/22
Re: [PATCH] Clojure-like syntactic sugar for an anonymous function literal, Artur Malabarba, 2015/01/22