user=> (source special-symbol?)
(defn special-symbol?
  "Returns true if s names a special form"
  {:added "1.0"
   :static true}
  [s]
    (contains? (. clojure.lang.Compiler specials) s))
nil

user=> (keys (. clojure.lang.Compiler specials))
(& monitor-exit case* try reify* finally loop* do letfn* if
clojure.core/import* new deftype* let* fn* recur set! . var quote catch
throw monitor-enter def)




On Wed, Jun 18, 2014 at 8:02 PM, Mark P <pierh...@gmail.com> wrote:

> Interesting - thanks!
>
> Looks like doing `symbol is a good way of telling whether something is a
> special symbol or not.  If syntax-quote results in namespace-qualification
> it then it *is not* special (with the exception of import*); if it does
> not namespace qualify it, then it *is* special.
>
> Previously I've been using the fact that (source symbol) comes up with
> "Source not found" to indicate that a symbol might be special.  But not
> sure how reliable this method is.  I imagine there might be other
> situations where the source code cannot be found.
>
> Cheers,
>
> Mark.
>
>
> On Wednesday, June 18, 2014 6:26:04 PM UTC+9:30, Ambrose Bonnaire-Sergeant
> wrote:
>
>> Hi Mark,
>>
>> Here's a brief doc on special forms: http://clojure-doc.org/
>> articles/language/macros.html#special-forms-in-detail
>>
>> Thanks,
>> Ambrose
>>
>>
>> On Wed, Jun 18, 2014 at 12:13 PM, Mark P <pier...@gmail.com> wrote:
>>
>>> Thanks Tassilo for the explanation - much appreciated!
>>>
>>> I have been searching the web and searching clojure text books for the
>>> last two hours trying to find the answer to this same question.  Finally I
>>> stumbled onto this thread!
>>>
>>> I realize that hiding the complexity of distinctions between fn / fn*
>>> and let / let* etc might make the documentation more accessible for some
>>> users, but for others (like me and presumably also Plínio) it makes it
>>> really hard to track down what is *really* going on.  I wish this
>>> distinction was part of the formal documentation.
>>>
>>> Does anyone know of documentation anywhere that does include these kinds
>>> of distinction?
>>>
>>> Thanks,
>>>
>>> Mark.
>>>
>>> On Thursday, 6 March 2014 02:27:26 UTC+10:30, Tassilo Horn wrote:
>>>
>>>> Plínio Balduino <pbal...@gmail.com> writes:
>>>>
>>>> Hi Plínio,
>>>>
>>>> > Clojure.org says fn and let are special forms, but using the macro
>>>> > sourceshows that both are macros calling fn* and let* respectivelly.
>>>> >
>>>> > So fn and let are "special special forms", or clojure.org is
>>>> > incorrect/outdated?
>>>>
>>>> Well, they are correct from a user's point of view.  One never uses the
>>>> real special forms fn* and let*.
>>>>
>>>> > If fn and let are really special forms and not macros, could you
>>>> > explain why?
>>>>
>>>> fn and let (and also loop) are macros around the real special forms fn*
>>>> and let* (and loop*) that add support for destructuring.  For example,
>>>>
>>>> (let [[a b] [1 2]]
>>>>   (+ a b))
>>>>
>>>> expands to
>>>>
>>>> (let*
>>>>   [vec__8592 [1 2]
>>>>    a (clojure.core/nth vec__8592 0 nil)
>>>>    b (clojure.core/nth vec__8592 1 nil)]
>>>>   (+ a b))
>>>>
>>>> where the destructuring has been transformed to "normal" code already.
>>>>
>>>> Bye,
>>>> Tassilo
>>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> 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/d/optout.
>

-- 
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/d/optout.

Reply via email to