There are only, I think, four reasons for making things a macro rather
than a function. The one that seems to apply to the ns macro is that it
saves typing -- that is, you don't have to sprinkle quoted symbols
everywhere. And you can ignore the difference between lists and vectors.

Compare...

(ns my-name-space
  (:use [their-name])

with this...

(ns 'my-name-space
  [:use ['their-name-space]])

The disadvantage is that the ns macro is not extensible (not strictly a
consequence of it being a macro, but in practice it is so). So I wrote a
new namespace declaration that was a function. This lets me program the
ns declaration so, for example, I can share a set of imports between
namespaces.

https://github.com/phillord/namespace-experiments/blob/master/src/namespace/examples.clj

Not a serious project, and just something I was playing at, but I still
think that the idea is sound (unlike the implementation).

Phil


Angel Java Lopez <ajlopez2...@gmail.com> writes:

> Hi!
>
> My first guess: a normal function evaluates all its arguments. ns uses
> (:require ....) (:use.. ) (:import ..) that should be not evaluated at ns
> apply. The alternative is to make ns an special form, but macro should be
> more flexible.
>
> Instead, in-ns is simpler, and it can be implemented as a normal function.
>
> Angel "Java" Lopez
> @ajlopez
>
>
> On Tue, Dec 30, 2014 at 5:30 AM, Petr <petrg...@gmail.com> wrote:
>
>> Hello.
>>
>> Does anyone know why clojure.core/ns macro is not implemented as function?
>> It seems that it should work that way except that probably it would be
>> nicer to have in-ns call at the top level.
>>
>> --
>> 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.
>>

-- 
Phillip Lord,                           Phone: +44 (0) 191 208 7827
Lecturer in Bioinformatics,             Email: phillip.l...@newcastle.ac.uk
School of Computing Science,            
http://homepages.cs.ncl.ac.uk/phillip.lord
Room 914 Claremont Tower,               skype: russet_apples
Newcastle University,                   twitter: phillord
NE1 7RU                                 

-- 
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