fn and let are macros in the clojure.core namespace; & is technically not a
valid character in a symbol, but the Clojure reader is quite lenient on
that front. As far as I know, it is not treated as anything special at the
level of the language, it is just interpreted by the destructuring macros.

On the other hand, real "special forms" in the Lispy sense are not macros -
they are "hard coded".

Think of the interpreter as doing something akin to:

(defn eval [form)
  (if (list? form)
    (cond
      (= 'let* (first form))  (...))
      (= 'fn* (first form)) (...))
      ;; same for all special forms
      (fn? (get-in-env (first form))) (apply (first form) (map eval (rest
form)))
      (macro? (get-in-env (first form))) (apply (first form) (rest
form))))))

This is of course highly sketchy, but you get the idea: functions and
macros are looked-up in the environment and executed from their definition,
so you can rebind them in the local environment, but special forms are just
executed directly.

(At least, this is how it works in toy implementations à la SICP & little
schemer - I'm not at all familiar with the Clojure source code, but this is
a working mental model for explaining the observed behavior.)


On 24 June 2013 00:43, Ben Wolfson <wolf...@gmail.com> wrote:

> Well, when used as the first element of a list. (And I certainly wouldn't
> use them as local names, since that would be extremely confusing; I was
> trying to verify the correctness of some code I'm working on.)
>
> But I called these "extra-special" because, in my understanding of the
> term, "special form" generically just refers to something with non-normal
> evaluation order (or special evaluation semantics generally). "when", in
> this definition, is a special form, as are "fn" and "let" (both of which
> are listed as special forms on http://clojure.org/special_forms). But
> neither "fn" nor "let" is special the way "let*", "fn*", "do", or the other
> *extra*-special forms are:
>
> user> (let [fn (fn [x] x)] (fn 4))
> 4
> user> (let [let (fn [x] x)] (let 4))
> 4
>
> Thinking about it more, I suppose you're thinking of what's returned by
> clojure.lang.Compiler/specials, except several of them can be used just
> fine in this pattern:
>
> user> (let [& (fn [x] x)] (& 1))
> 1
>
> The above also works for finally and catch.
>
> Anyway, I'm surprised one can establish local bindings for these guys at
> all.
>
> On Sun, Jun 23, 2013 at 2:46 PM, Ambrose Bonnaire-Sergeant <
> abonnaireserge...@gmail.com> wrote:
>
>> Special forms are special when used in a list. IMO it's a bad idea to use
>> special forms
>> as local names, a caveat which is surprisingly under-documented.
>>
>> Thanks,
>> Ambrose
>>
>>
>> On Mon, Jun 24, 2013 at 5:38 AM, Ben Wolfson <wolf...@gmail.com> wrote:
>>
>>> This strikes me as pretty odd:
>>>
>>> user> (let [z 1
>>>             try 2
>>>             fn* 3]
>>>         (try (let [x (fn* ([a b c] [a b c]))]
>>>                (x z try fn*))
>>>              (catch Exception e e)))
>>> [1 2 3]
>>>
>>>
>>> --
>>> Ben Wolfson
>>> "Human kind has used its intelligence to vary the flavour of drinks,
>>> which may be sweet, aromatic, fermented or spirit-based. ... Family and
>>> social life also offer numerous other occasions to consume drinks for
>>> pleasure." [Larousse, "Drink" entry]
>>>
>>>  --
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clojure@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>>  --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
> Ben Wolfson
> "Human kind has used its intelligence to vary the flavour of drinks, which
> may be sweet, aromatic, fermented or spirit-based. ... Family and social
> life also offer numerous other occasions to consume drinks for pleasure."
> [Larousse, "Drink" entry]
>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to