On 9 May 2010, at 04:44, Mark Engelberg wrote:
In Python, let's say I have a library "mylibrary.py", and from various
files I say "from mylibrary import *".
If I want to split mylibrary.py into two parts, say, library1.py and
library2.py, then I can just change mylibrary.py to say:
from library1
I spent the past half-hour experimenting with what happens in Clojure if the
ns declaration doesn't match the file name, and what happens if the ns
declaration is not at the top of the file.
Here's what I've found so far:
1. When you require/use/load a file, Clojure finds it by the filename.
2.
Some time ago I experimented with migrating definitions between
namespaces. Here's a post from then that covers some lower-level
detail regarding namespaces.
http://groups.google.com/group/clojure/msg/f00a82b747c1636f
-Hth, Adrian.
On Mon, May 10, 2010 at 12:15 AM, Mark Engelberg
wrote:
> The m
Hi,
On 10 Mai, 00:15, Mark Engelberg wrote:
> The more I think about this, the more I feel like I don't have a good mental
> model of what's going on with namespaces/loading/reading/compiling. What is
> happening when you "load" a file without reading/compiling it (e.g.,
> load-reader or load-f
The more I think about this, the more I feel like I don't have a good mental
model of what's going on with namespaces/loading/reading/compiling. What is
happening when you "load" a file without reading/compiling it (e.g.,
load-reader or load-file)? How does referring/using match up with those
low
On 9 May 2010 19:02, Laurent PETIT wrote:
> 2010/5/9 Stuart Sierra :
>>> http://www.google.com/url?sa=D&q=http://richhickey.github.com/clojure-contrib/ns-utils-api.html%23clojure.contrib.ns-utils/immigrate
>>
>> 'immigrate' is bad, it creates new Vars instead of new mappings to
>> existing Vars, l
> Unfortunately, this seems to break my consumer code. Although
> mylibrary can see the functions from library1 and library2, consumers
> of mylibrary cannot. So I end up manually having to go to all my
> consumer files and changing them to:
> (ns a-random-file-that-consumes-my-library
> (:use
On Sun, May 9, 2010 at 8:01 AM, David Nolen wrote:
> If you just need to break up your code into smaller files another technique
> is:
>
> ; me/lib.clj
> (ns me.lib)
> (load "me/foo")
> (load "me/bar")
>
> ; me/foo.clj
> (in-ns 'me.lib)
>
> ; me/bar.clj
> (in-ns 'me.lib)
>
>
I think this solves p
2010/5/9 Stuart Sierra :
>> http://www.google.com/url?sa=D&q=http://richhickey.github.com/clojure-contrib/ns-utils-api.html%23clojure.contrib.ns-utils/immigrate
>
> 'immigrate' is bad, it creates new Vars instead of new mappings to
> existing Vars, leading to very subtle and difficult-to-fix bugs.
> http://www.google.com/url?sa=D&q=http://richhickey.github.com/clojure-contrib/ns-utils-api.html%23clojure.contrib.ns-utils/immigrate
'immigrate' is bad, it creates new Vars instead of new mappings to
existing Vars, leading to very subtle and difficult-to-fix bugs.
-S
--
You received this mess
If you just need to break up your code into smaller files another technique
is:
; me/lib.clj
(ns me.lib)
(load "me/foo")
(load "me/bar")
; me/foo.clj
(in-ns 'me.lib)
; me/bar.clj
(in-ns 'me.lib)
On Sat, May 8, 2010 at 10:44 PM, Mark Engelberg wrote:
> I've seen people say here that it's relati
Maybe this could help:
http://richhickey.github.com/clojure-contrib/ns-utils-api.html#clojure.contrib.ns-utils/immigrate
HTH,
--
Laurent
2010/5/9 Mark Engelberg :
> I've seen people say here that it's relatively easy to break up a
> namespace into smaller components, so I'm wondering if I'm mi
I've seen people say here that it's relatively easy to break up a
namespace into smaller components, so I'm wondering if I'm missing
something. I'd appreciate some guidance about how to keep namespaces
well-organized.
In Python, let's say I have a library "mylibrary.py", and from various
files I
13 matches
Mail list logo