On Mon, May 18, 2009 at 9:47 AM, Mark Engelberg
<mark.engelb...@gmail.com> wrote:
>
> On Sun, May 17, 2009 at 11:48 PM, Konrad Hinsen
> <konrad.hin...@laposte.net> wrote:
>>  It's the approach of "cloning and
>> mutating" something that smells of "quick and dirty", although I
>> agree it is quite convenient in the prototyping phase.
>
> I disagree that incremental extension of a module is a "quick and
> dirty" prototyping technique, and would argue that this is a
> fundamentally desirable feature.
>
> As an example, I authored clojure.contrib.math.  Someone came up with
> a slightly faster algorithm for one of the functions (which is used in
> turn by other functions in the library), but I can't include it unless
> he signs a contributor agreement.  If he wants to create his own
> version of the module for his own personal use, in which he swaps out
> my function for his faster one, there appears to be no good way to do
> this, short of copying my entire file, commenting out my function, and
> replacing it with his.  Clearly this is not an acceptable solution,
> because then he won't benefit from any future updates I make to the
> module.  He can't use the "load" trick, all because of the (ns
> clojure.contrib.math) declaration at the top of the file.
>
> Based on this discussion, it sounds like I (and all library authors)
> should have provided all of my math functions in one file (say,
> math_functions.clj), and then had a separate file (math.clj)
> containing:
> (ns clojure.contrib.math
>  (:load "math_functions"))
>
> just to make it possible for users to get at my code in its
> uncompiled, unlinked-to-clojure.contrib.math-namespace form for the
> purposes of incremental extension.

What's wrong with this:

user=> (ns test (:use [clojure.contrib.math :exclude (lcm)]))
nil
test=> (sqrt 2)
1.4142135623730951
test=> (lcm 3 6)
java.lang.Exception: Unable to resolve symbol: lcm in this context
(NO_SOURCE_FILE:3)
test=> (defn lcm [a b] 1)
#'test/lcm
test=> (lcm 3 6)
1
test=>

It doesn't solve your problem with global vars, of course.

-- 
Michael Wood <esiot...@gmail.com>

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

Reply via email to