Konrad Hinsen <googlegro...@khinsen.fastmail.net> writes:

> --On 23 janvier 2014 13:08:57 +0000 Phillip Lord
> <phillip.l...@newcastle.ac.uk> wrote:
>
>>> The nstools library lets you do exactly that:
>>>
>>>   https://code.google.com/p/clj-nstools/
>>
>> That looks nice; why not open up the reference-map though, so that it
>> would become extensible.
>
> That's a good idea. Just making it public is risky, as any module could mess
> up the namespace definition system shared by everybody. You'd want something
> like subclassing (sorry for the OO jargon).


You could use ::keyword rather than :keyword, or at least put this as a
suggestion. You can't enforce this, but the :private true is a
suggestion as well, and can be worked around.


> The tricky part is how one would actually use such extensions. Current nstools
> is already a bit messy, since you must put a (clojure.core/use 'nstools.ns) in
> every source file before the (ns+ ...) form. An extension to nstools would
> require a second line before (ns+ ...). What I'd prefer is an extension
> mechanism in Clojure's built-in ns macro, which would permit a much nicer
> implementation of nstools.


Yep, this is true. When I wrote my toy namespace form, I eval'd
arguments sequentially. So, you can then do something like this...

;; in namespace.imports
(defn tawny-read []
  (use-only
   (req tawny.read)
   'defread))


;; in "bob"
(newnamespacet
 bob
 (req namespace.imports)
 (namespace.imports/tawny-read))

The point is that the (req namespace.imports) line requires
namespace.imports before (namespace.imports/tawny-read) is eval'd. So
the second form works as well.

Of course, this gives a very procedural aspects to the form: the same
thing backward:

(newnamespacet
 bob
 (namespace.imports/tawny-read)
 (req namespace.imports))

would fail.

The rest of my examples are here:

https://github.com/phillord/namespace-experiments

Phil

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