Re: Datatypes and Protocols - early experience program

2009-11-13 Thread Stuart Sierra
On Nov 13, 3:42 pm, Laurent PETIT laurent.pe...@gmail.com wrote: Very simple example here:http://paste.lisp.org/display/90329 Why not have used add/sub/... instead of +/-/... in the extension of Arithmetic for ::Complex ? :-p Just a little simpler, that's all. This example has maybe a

Re: Continuous Integration Server Maven/Ivy Repo

2009-11-04 Thread Stuart Sierra
I don't think that URL works as a Maven/Ivy repository, because http://build.clojure.org/org/clojure doesn't exist. -SS On Nov 3, 10:10 pm, dysinger t...@dysinger.net wrote: Hello, Today Phil Hagelberg, Rich Hickey and myself setup a CI server for clojure contrib

Re: Continuous Integration Server Maven/Ivy Repo

2009-11-04 Thread Stuart Sierra
since http://build.clojure.org/org/clojure/clojure-lang/maven-metadata.xml is accessible. Roman 2009/11/4 Stuart Sierra the.stuart.sie...@gmail.com: I don't think that URL works as a Maven/Ivy repository, because http://build.clojure.org/org/clojuredoesn't exist. -SS On Nov 3, 10

Re: Write big numbers with thousands grouping.

2009-11-02 Thread Stuart Sierra
On Oct 31, 12:37 pm, John Harrop jharrop...@gmail.com wrote: For some reason though changing defmacro here to definline doesn't work. It says #CompilerException java.lang.Exception: Unable to resolve symbol: in this context (NO_SOURCE_FILE:129) definline doesn't support variable arities.

Re: Clojure contrib http-agent hangs when making a POST request

2009-11-02 Thread Stuart Sierra
I've pushed a slightly different fix; (string...) now waits for the HTTP request to finish. -SS On Oct 31, 6:00 am, Alex alexspurl...@gmail.com wrote: Rob, that's perfect. Thanks very much for looking into that and supplying the patch. Hopefully we can get that applied to the source in git.

Re: Write big numbers with thousands grouping.

2009-10-31 Thread Stuart Sierra
For even more fun, you can take advantage of the fact that commas are whitespace, and use a macro to do it at compile time: (defmacro bignum [ parts] (read-string (apply str parts))) (bignum 99,871,142) 99871142 -SS --~--~-~--~~~---~--~~ You received this

Re: Embedding Clojure in NetKernel

2009-10-31 Thread Stuart Sierra
On Oct 28, 7:43 am, Tony Butterfield t...@1060.org wrote: 1) start and stop the Clojure runtime on demand. Clojure runtime is a bit of a misnomer; Clojure has no runtime other than the compiler. That's why all the methods of clojure.lang.RT are static. there a way to cleanly shutdown. I.e.

Re: Generating Java and C# wrappers

2009-10-30 Thread Stuart Sierra
On Oct 30, 6:18 am, John Ky newho...@gmail.com wrote: I've been wondering if there was a way to specify the Java and C# wrapper classes/interfaces to wrap Clojure code in Clojure, and then writing out them to a file so that they can ge compiled by their respective compilers. I'm not sure I

Re: add-watch's functions' first argument

2009-10-27 Thread Stuart Sierra
On Oct 26, 5:18 pm, samppi rbysam...@gmail.com wrote: Well, that's how the key itself is useful. What I'm wondering is why it is useful for the key to be passed to the watching function every time it's called. I suppose you could use the same watching function with different keys for

Re: Writing binary data using http.agent and duck-streams

2009-10-26 Thread Stuart Sierra
On Oct 23, 2:16 pm, Baishampayan Ghose b.gh...@ocricket.com wrote: Is there any way to use duck-streams to write data as binary? No, duck-streams only does text. For binary I/O, you need the InputStream and OutputStream classes. -SS --~--~-~--~~~---~--~~ You

Re: Measuring code complexity

2009-10-26 Thread Stuart Sierra
On Oct 25, 11:56 pm, MarkSwanson mark.swanson...@gmail.com wrote: I'd like to run count-nodes against a compiled fn that I've previously defined, but I could not get an existing fn into quoted form Can't be done. Once a fn is compiled, it's just Java bytecode. -SS

Re: data structures for efficient range queries

2009-10-20 Thread Stuart Sierra
On Oct 20, 3:15 am, Volkan YAZICI volkan.yaz...@gmail.com wrote: I think what you are after is an interval tree[1] data structure. You might find a suitable Java library or implement yours easily. Regards. [1]http://en.wikipedia.org/wiki/Interval_tree Yes, I think an interval tree is what

Re: sequence manipulation question

2009-10-20 Thread Stuart Sierra
On Oct 20, 1:25 am, Alex Osborne a...@meshy.org wrote: Because cons always creates a list (which construct at the front), while conj adds it in the natural (ie fastest) way for that collection type, vectors add at the end. In fact, all the generic sequence functions (cons, concat, map,

Re: Multimethods and dispatch function

2009-10-17 Thread Stuart Sierra
On Oct 17, 4:02 pm, pmf phil.fr...@gmx.de wrote: (declare my-dispatch-fn) (defmulti my-multi my-dispatch-fn) ; throws exception due to unbound I think this is intentional, because the multifn doesn't call the dispatch function by name. Common usage is to use an anonymous fn for the dispatch.

Re: - vs comp

2009-10-17 Thread Stuart Sierra
On Oct 16, 10:22 pm, Sean Devlin francoisdev...@gmail.com wrote: In order to generate closures, every function should take parameters first, and data at the end, so that they work well with partial. It's really hard to come up with a consistent practice that works well for all scenarios. Even

Re: is there a cannonical way to create executable jar files?

2009-10-16 Thread Stuart Sierra
On Oct 16, 8:12 am, Folcon fol...@gmail.com wrote: my namespace contains   (:gen-class :main true) with the main function I want to declare called -main. and I have tried telling my manifest file to call my namespace and clojure.main and both fail. That should be the correct approach. Not

Re: Circular dependencies (Clojure and Java)

2009-10-15 Thread Stuart Sierra
On Oct 15, 7:56 am, Laurent PETIT laurent.pe...@gmail.com wrote: if the clojure classes depend on the java classes in the implementation and not in their interfaces ( extends, implements, methods signatures ), then you can write your gen-class with a separate namespace for the implementation

Re: crash observed compiling when ns declaration spans more than one line

2009-10-14 Thread Stuart Sierra
On Oct 14, 10:30 am, B Smith-Mannschott bsmith.o...@gmail.com wrote: This appears to have been a bug in clojure-maven-plugin 1.0, as editing pom.xml to use clojure-maven-plugin 1.1 fixed the problem. :o) So, what can we conclude from this? That version 1.0 parsed the clj file with a parser

Re: clojureshell-maven-plugin - easier clojure startup with maven

2009-10-14 Thread Stuart Sierra
On Oct 14, 1:03 pm, ngocdaothanh ngocdaoth...@gmail.com wrote: Is there a way to run a .clj file (with classpath correctly set by Maven)? I don't want REPL, I just want to run a .clj file without compiling. Look at the clojure:run target in the clojure-maven-plugin version 1.1:

Re: Dealing with StringTemplate template paths

2009-10-13 Thread Stuart Sierra
On Oct 12, 8:40 am, Stuart Halloway stuart.hallo...@gmail.com wrote: We are using StringTemplate's ability to search the classpath. Yep, that's how I do it. -SS --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Re: Duplicated keys in maps

2009-10-13 Thread Stuart Sierra
On Oct 11, 11:17 pm, John Harrop jharrop...@gmail.com wrote: I just discovered that maps support duplicated keys: I suspect it's a bug. It's been discussed on IRC and declared not a bug. It's officially undefined what happens when you write a literal map with duplicate keys. As soon as you

Re: Is there a standard function transforming a map's vals

2009-10-11 Thread Stuart Sierra
On Oct 10, 8:40 pm, samppi rbysam...@gmail.com wrote: (defn transform-map [f a-map] (into {} (map #(vector (key %) (f (val %))) a-map))) I always find map transformations easier to write with reduce: (defn transform-map [f mm] (reduce (fn [m [k v]] (assoc m k (f v))) {} mm)) -SS

Re: Opinions/Suggestions needed for dependency syntax

2009-10-10 Thread Stuart Sierra
On Oct 10, 11:43 am, James Reeves weavejes...@googlemail.com wrote: I'm working on a Clojure package manager called Capra, and I need some opinions on the syntax for specifying dependencies. You know my opinion, which is that we should use Maven to manage dependencies. Maven 3, due soonish,

Re: Data structure design question

2009-10-09 Thread Stuart Sierra
Honestly, this sounds like a problem for a full-fledged database. With Clojure/datalog, you'll need to persist your records to disk manually. At some point, your thousands of references will start to look like a mini-database anyway. If you can fit your data into a relational schema, use that;

Re: Basic questions

2009-10-08 Thread Stuart Sierra
On Oct 8, 1:49 am, vishy vishalsod...@gmail.com wrote: How can I find out all the namespaces in a library like clojure.contrib.find-namespaces has functions to discover namespaces on the classpath. -SS --~--~-~--~~~---~--~~ You received this message because you

Re: Does OSGi make sense for Clojure?

2009-10-05 Thread Stuart Sierra
It's possible to modify Clojure to run under OSGi (search the list archives) but fundamentally they don't fit. OSGi assumes that it has sole control of class loading. But Clojure needs its own classloader. To make them cooperate, I think you would need to integrate Clojure with the OSGi

Re: apply for macros?

2009-10-02 Thread Stuart Sierra
On Oct 2, 12:47 pm, b2m b2monl...@googlemail.com wrote: Is there a simple way to 'apply' the macro to a list of arguments like it works for functions: (apply + '(1 2 3)) ? Nope, no can do. For an example of why, check out clojure.contrib.apply-macro -- the warnings are there for a reason.

Re: immutable defs?

2009-10-02 Thread Stuart Sierra
On Oct 2, 11:52 am, Mark Tomko mjt0...@gmail.com wrote: However, outside the scope of a function, it seems that it's possible for bindings to be redefined later in a file without causing an immediate error.  This could easily lead to mistakes that would manifest as silent and potentially

Re: re-sub / re-gsub with back-reference?

2009-09-29 Thread Stuart Sierra
Hi Jung, Look at clojure.contrib.str-utils2/replace -- you can pass a function as the replacement parameter and make any substitutions you want. -SS On Sep 28, 6:51 pm, Jung Ko koj...@gmail.com wrote: Does anyone know how I can replace a string with back-reference? I'd like something like

Re: Testing - verbosity - method

2009-09-29 Thread Stuart Sierra
On Sep 29, 4:00 am, Timothy Pratley timothyprat...@gmail.com wrote: Secondly I'd like to know how to invoke my tests conveniently. Options I've explored: 1) put (run-tests) at the bottom of the file. Great for while I'm coding, bad when including as a library. 2) at the REPL (load-file

Re: Mocking?

2009-09-28 Thread Stuart Sierra
On Sep 27, 9:18 pm, John Harrop jharrop...@gmail.com wrote: Isn't (binding [foo bar] ...) already such a mechanism? Or does the fixtures feature let you specify such a binding for a whole group of tests obviating the need to repeat the binding form in multiple test functions, Yes. A fixture

2 upcoming NYC talks

2009-09-28 Thread Stuart Sierra
Hi folks, I'm doing two talks about Clojure and Hadoop, one at Hadoop World NYC on Friday, October 2, and the other at the NoSQL meetup on Monday, October 5. Details, links, and follow-ups at http://stuartsierra.com/ -SS --~--~-~--~~~---~--~~ You received this

Re: Mocking?

2009-09-27 Thread Stuart Sierra
On Sep 27, 12:55 am, Mark Derricutt m...@talios.com wrote: How are people handling mocking/stubbing in clojure?  Google finds me some old posts about a called? function/macro as part of test-is which looks like it'd do what I need but I can't seem to find any trace of it under

Re: Getting REPL transcript

2009-09-25 Thread Stuart Sierra
On Sep 23, 1:09 pm, John Harrop jharrop...@gmail.com wrote: Actually, that suggests a more general point: that we can have programmatic access to the REPL's backlog if we modify the REPL process's Java code somewhat. The REPL is written in Clojure, so it's quite easy to modify. Look at

Re: test.clj / test/tap.clj error

2009-09-25 Thread Stuart Sierra
. -Stuart Sierra --~--~-~--~~~---~--~~ 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

Re: where is the contrib?

2009-09-23 Thread Stuart Sierra
Clojure-contrib is available on Github: http://github.com/richhickey/clojure-contrib/ -SS On Sep 23, 5:14 am, ELaN mr.y...@gmail.com wrote: I run a clj script file and get a FileNotFoundException. The message is Could not locate clojure/contrib/ import_static__init.class or

Re: trouble running clojure.test

2009-09-23 Thread Stuart Sierra
On Sep 23, 2:51 am, MarkSwanson mark.swanson...@gmail.com wrote: I'm having trouble unit testing clojure code. To be sure I'm just testing clojure.test, I'm trying to test clojure.contrib.json.read. I'm sure I've missed it. test.clj contains defmethod report ... that has the FAIL println in

Re: Can anyone here give a comparison between Clojure and Erlang on concurrent programming?

2009-09-18 Thread Stuart Sierra
On Sep 17, 6:54 pm, dongbo dongb.w...@gmail.com wrote: Can any one give a comparison between Clojure and Erlang on concurrent programming? Erlang supports one concurrency model, Actors. Clojure supports several -- Agents, which are similar to Actors; Refs, which have ACI (not D) transactional

Re: Modeling question multimethods or methodmaps?

2009-09-18 Thread Stuart Sierra
On Sep 17, 4:02 pm, Philipp Meier phme...@gmail.com wrote: Not your question, I know, but the Restlet framework for Java does exactly this. I know ;-) And it's using object oriented inheritance. In common lisp I'd use CLOS and an object hierachy but in clojure I'm unsure. I just use

Re: Modeling question multimethods or methodmaps?

2009-09-17 Thread Stuart Sierra
On Sep 17, 7:50 am, Philipp Meier phme...@gmail.com wrote: I'm building a REST server library on top of compojure loosely modeled after the ideas of erlangs webmachine. The idea is to describe a resource using a couple of function which server as decision makers for the different stages of

Re: Is knowing Java a prerequisite for using Clojure?

2009-09-17 Thread Stuart Sierra
On Sep 16, 10:46 pm, Hugh Aguilar hugoagui...@rosycrew.com wrote: My concern right now is that I don't know Java. Is this a prerequisite for learning Clojure? Can I program in Clojure without delving into Java, or are there certain things that will require Java? Yes, you can learn Clojure the

Re: Cells for Clojure

2009-09-17 Thread Stuart Sierra
On Sep 11, 7:55 pm, Fogus mefo...@gmail.com wrote: Even more information here: https://www.assembla.com/spaces/clojure-contrib/tickets/19-Re-add-auto-agent-clj I should point out that auto-agents, which I wrote, is NOT Cells. It's just a quick hack that I whipped up as an example of using

Re: Redefining Special Forms

2009-09-17 Thread Stuart Sierra
On Sep 17, 12:33 pm, Gorsal s...@tewebs.com wrote: Basically i need to redefine the meaning of a special form. This depends on what you want to redefine. True special forms in Clojure -- def if do let quote var fn loop recur throw try . new set! -- cannot be redefined, period. Anything else

Re: Redefining Special Forms

2009-09-17 Thread Stuart Sierra
On Sep 17, 12:40 pm, Gorsal s...@tewebs.com wrote: Oh. And just as a quick other question, do global bindings affect threads which are started in the same ns? I think threads inherit the bindings in effect when they are created. -SS --~--~-~--~~~---~--~~ You

Re: Unwind-protect?

2009-09-15 Thread Stuart Sierra
unwind-protect is indeed a Common Lisp form, not Clojure. It ensures that a given piece of code is always executed, even when an error or some other condition causes the code to exit early. In Clojure (and Java), the nearest equivalent is the try-catch-finally block. It looks like this: (try

Re: Modeling Data Associations in Clojure?

2009-09-15 Thread Stuart Sierra
On Sep 15, 6:54 am, Dragan Djuric draga...@gmail.com wrote: Ha, ha, some object-oriented lessons are being rediscovered :))) Precisely! Just because the language doesn't enforce information hiding doesn't mean you can't do it. -SS --~--~-~--~~~---~--~~ You

Re: Modeling Data Associations in Clojure?

2009-09-14 Thread Stuart Sierra
Hi Brenton, I think the simplest solution to this problem is to use functions instead of maps. That is, instead of defining your API in terms of maps with specific keys, define it in terms of functions that read/ write individual fields. For example, you would have an opaque Person object,

Re: Matlab for Lisp programmers?

2009-09-12 Thread Stuart Sierra
On Sep 12, 12:17 pm, Max Suica max.su...@gmail.com wrote: You might look at Octave, which is an open source clone of matlab, but with nothing like simulink :/ . Still, for pretty involved number crunching and plotting, Octave can do what matlab can, and its language is similar (it might try

Problem with clojure-maven-plugin and ns metadata

2009-09-07 Thread Stuart Sierra
Hi Mark, I like your clojure-maven-plugin, but I discovered a problem with 1.0. If a namespace declaration has metadata, like this: (ns #^{:doc This is my namespace.} my.namespace) The the plugin fails to read the ns name. You get an error message like Cannot find file __init.class

Re: Problem with clojure-maven-plugin and ns metadata

2009-09-07 Thread Stuart Sierra
I've not used too much yet.. I'll take a look at it tonight... -- Pull me down under... On Tue, Sep 8, 2009 at 11:10 AM, Stuart Sierra the.stuart.sie...@gmail.com wrote: Hi Mark, I like your clojure-maven-plugin, but I discovered a problem with 1.0. If a namespace declaration has

Re: clojure-mode survey

2009-09-07 Thread Stuart Sierra
On Sep 7, 8:36 pm, Phil Hagelberg p...@hagelb.org wrote: ... I don't know if the built-in subprocess features are worth keeping around any more. Personally I have never used them or heard of anyone using them; I wonder if they are just legacy baggage. Never used them; only use SLIME. Never

Re: Problem with clojure-maven-plugin and ns metadata

2009-09-07 Thread Stuart Sierra
On Mon, Sep 7, 2009 at 8:54 PM, Mark Derricuttm...@talios.com wrote: Initially I didn't like that as people -may- not stick to good convention and use a different namespace than filename, but I think failing and making them conform to a good standard is acceptable. I think if the namespace

Re: Clojure quickstart maven archetype

2009-09-07 Thread Stuart Sierra
Also look at the ClojureShell Maven plugin, http://github.com/fred-o/clojureshell-maven-plugin/tree/master which runs a REPL or Swank server. -SS On Sep 7, 10:41 pm, Mark Derricutt m...@talios.com wrote: Most definitely - I did have a repl goal for awhile but had issues with the input/output

Re: Eval troubles

2009-09-04 Thread Stuart Sierra
On Sep 4, 1:55 am, Miron Brezuleanu mbr...@gmail.com wrote: I'm not sure this is an interpreter/compiler issue :-) I think it is more of a resource allocation problem, i.e. what features to add to Clojure and when. True, it's that Clojure does not have first-class environments, either dynamic

Re: Fixing production systems on-the-fly

2009-09-04 Thread Stuart Sierra
On Sep 4, 4:22 am, Krukow karl.kru...@gmail.com wrote: I was thinking about the capability of changing production systems on the fly. E.g. by having an accessible repl in a running production system. This is a popular list question. The short answer is no. It might work for correcting a

Re: clojureshell-maven-plugin - easier clojure startup with maven

2009-09-04 Thread Stuart Sierra
On Sep 3, 12:40 pm, Fredrik Appelberg fredrik.appelb...@gmail.com wrote: I've just released the first tentative version of Clojureshell. It's a simple maven plugin that allows you to easily start a clojure REPL or run a Swank server in the context of any maven project. Here's a

Re: Backporting clojure.contrib.logging

2009-09-03 Thread Stuart Sierra
yes. -SS On Sep 2, 5:27 pm, Phil Hagelberg p...@hagelb.org wrote: Hello! I've backported contrib's logging.clj library to work with Clojure 1.0. It was just a handful of modifications wrt how the import function worked. I'd like to get it included in the clojure-1.0-compat branch of

Re: Lazy binding

2009-09-03 Thread Stuart Sierra
Check out www.stringtemplate.org, a Java template library with a functional design. -SS On Sep 3, 8:42 am, ngocdaothanh ngocdaoth...@gmail.com wrote: Hi, In Rails you can create a view like this: my_view.erb: %= hello + @name % I'm new to Clojure. I want to create something like the

Re: Importing All from java package?

2009-09-03 Thread Stuart Sierra
On Sep 3, 6:31 pm, Gorsal s...@tewebs.com wrote: Hello! I was just wandering if it was possible to import all from a java package . For example, in java i can do import org.eclipse.jface.text.*; This is not supported right now. I don't think it's likely in the future, either. -SS

Re: No line information in debugger

2009-09-03 Thread Stuart Sierra
I don't know about JSwat, but I know that code entered directly at the REPL (or eval'ed from SLIME) doesn't have line numbers. -SS On Sep 3, 5:25 pm, Bokeh Sensei bokeh.sen...@gmail.com wrote: I can't get JSwat to display and break on lines in my Clojure code. Does anybody knows how this

Re: clojureshell-maven-plugin - easier clojure startup with maven

2009-09-03 Thread Stuart Sierra
On Sep 3, 9:15 pm, ngocdaothanh ngocdaoth...@gmail.com wrote: What do you mean Swank server? Could you explain about that? Swank is the back-end of SLIME, the interactive Lisp programming environment for Emacs. SLIME is written in Emacs Lisp and runs inside the Emacs process. Swank runs in

Re: Interactive heuristic

2009-09-03 Thread Stuart Sierra
The problem is, I think, that everyone will have a slightly different definition of interactive environment. If I run java ... clojure.main path/to/file.clj does that count? What about java ... my.compiled.namespace ? Or what about a REPL thread inside another application? Or a

Re: Eval troubles

2009-09-03 Thread Stuart Sierra
On Sep 3, 9:26 am, Konrad Hinsen konrad.hin...@fastmail.net wrote: I don't think so. Python and Clojure are quite different languages.   Python is much more dynamic, with variable lookup happening at   runtime. Or, more simply, Python is an interpreter, Clojure is a compiler. So Clojure's

Re: How to represents a Big text file using sequence?

2009-08-31 Thread Stuart Sierra
On Aug 31, 10:44 am, wangzx wangzaixi...@gmail.com wrote: I just want to learn clojure by using it to parse log file and generate reports. and one question is: for a large text file, can we use it as a sequence effectively? for example, for a 100M log file, we need to check each line for some

Re: Easily add a Java Listener

2009-08-31 Thread Stuart Sierra
That's a clever trick. How does the block know which interface method was invoked? -SS On Aug 31, 2:41 pm, rb raphi...@gmail.com wrote: Hi, After using Jwt from Clojure, I did it with Jruby and discovered that Jruby has what they call Closure Conversion (http://kenai.com/projects/

Re: Clojure for game programming?

2009-08-29 Thread Stuart Sierra
On Aug 30, 12:01 am, Elliott Slaughter elliottslaugh...@gmail.com wrote: If anyone has suggestions on simulating interactions between trees of objects (especially on the Clojure way to do it), I'd appreciate it. Check out Clojure Agents. A bunch of agents can interact by sending messages, in

Re: I18n

2009-08-28 Thread Stuart Sierra
My recommendation would be to keep your localized strings separate from your source code, either in properties files or using a text template system such as stringtemplate.org -SS On Aug 28, 1:16 am, ngocdaothanh ngocdaoth...@gmail.com wrote: Hi all, Is there an i18n library for Clojure?

Re: How about write clojure code like python mode?

2009-08-26 Thread Stuart Sierra
On Aug 24, 11:23 pm, wangzx wangzaixi...@gmail.com wrote: I think clojure may mix both the parenthese and python-like indent together. This has been attempted about every six months ever since Lisp was invented. It never caught on. -SS --~--~-~--~~~---~--~~

Re: Weird namespace behavior when reloading code

2009-08-23 Thread Stuart Sierra
load is a low-level file loading function; it does not reload dependent namespaces. Use the higher-level require and use functions with the :reload- all option, which will reload dependent namespaces. -SS On Aug 23, 2:48 pm, Conrad drc...@gmail.com wrote: Hi- I have a bug in my code related

Re: clojure success story ... hopefully :-)

2009-08-21 Thread Stuart Sierra
On Aug 21, 5:55 pm, Michel Salim michael.silva...@gmail.com wrote: Is there a performance hit with this style (due to using multimethods) or will this be optimized away in practice? There is a slight performance penalty over a normal function call. I think the dispatching takes one function

Re: New string utilities library ready

2009-08-20 Thread Stuart Sierra
Seems like opinion is pretty evenly divided here. I'll leave the library as-is for now, give it some time to see how things play out. In the mean time, as a compromise, I've added str-utils2/partial, which is like clojure.core/partial for functions that take their primary argument first.

New string utilities library ready

2009-08-19 Thread Stuart Sierra
the old clojure.contrib.str-utils. Let me know what you think. -Stuart Sierra --~--~-~--~~~---~--~~ 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

Re: New string utilities library ready

2009-08-19 Thread Stuart Sierra
On Aug 19, 3:09 pm, Howard Lewis Ship hls...@gmail.com wrote: Have you considered splitting the str-utils2 into two namespaces, one that can be imported, and another that needs to be required with a namespace? Hi Howard, Hadn't thought of that, actually. There are 9 conflicts, out of 32

Re: New string utilities library ready

2009-08-19 Thread Stuart Sierra
On Aug 19, 5:16 pm, Sean Devlin francoisdev...@gmail.com wrote: I suspect I am in the minority with my next concern.  The library takes the string as the first argument, so that it works well with the - macro.  When I originally wrote my string library, I favored this type of signature too.

Re: New string utilities library ready

2009-08-19 Thread Stuart Sierra
On Aug 19, 9:56 pm, CuppoJava patrickli_2...@hotmail.com wrote: If I were to have my way, I would redefine all the clojure.core functions to assume the data is the last argument instead of the first. (this includes -) This way they would play nice with both partial and -. That's a really

Re: http-agent

2009-08-12 Thread Stuart Sierra
Fixed; thanks. -SS On Aug 12, 2:46 am, Anniepoo annie6...@yahoo.com wrote: using http-agent threw (#IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: setFixedLenghtStreamingMode for class sun.net.www.protocol.http.HttpURLConnection) notice the

Re: Can Clojure be as fast as Java?

2009-08-11 Thread Stuart Sierra
On Aug 11, 4:35 pm, Chas Emerick cemer...@snowtide.com wrote: Maybe others will disagree, but I don't think that standard can ever   be met.  There will always be tasks for which clojure is slower than   java, just as there are tasks where java is slower than assembly. I suspect that those

Re: Test a random function

2009-08-07 Thread Stuart Sierra
Generally, if you're testing something that is supposed to be truly random (like shuffle and rand-elt), you do a large sample and make sure the distribution of results is truly (close to) uniform. -SS On Aug 7, 9:17 pm, Sean Devlin francoisdev...@gmail.com wrote: Ok, I need some help.  I'm

Re: combining methods

2009-08-07 Thread Stuart Sierra
There isn't an equivalent right now. The simplest workaround is to factor out the common code into an ordinary function, and call it from your multimethods. -SS On Aug 7, 2:55 pm, Andy Chambers achambers.h...@googlemail.com wrote: Hey All, Does clojure have an equivalent of either CLOS's

Re: JSR 223

2009-07-31 Thread Stuart Sierra
Someone's working on it: http://github.com/pmf/clojure-jsr223/tree/master -SS On Jul 31, 12:04 pm, Mike cki...@gmail.com wrote: Sorry if this is a FAQ; couldn't find it on the main site nor in the group. Are there plans for Clojure to work in JSR-223 (Java Scripting Framework)?  I see a

Re: struct-map niggle

2009-07-30 Thread Stuart Sierra
On Jul 30, 5:03 pm, Chouser chou...@gmail.com wrote: Are you aware of *print-dup* ?  It causes the printer to preserve more of the specific type information than normal printing: user= (binding [*print-dup* true] (prn (hash-map :a 1, :b 2))) {:a 1, :b 2} nil user= (binding [*print-dup*

Re: a regular expression for matching and for generating?

2009-07-29 Thread Stuart Sierra
Look at clojure.contrib.str-utils2/replace. It accepts a function -- the fn will be called on each match, and its return value will be inserted into the result string. But that may not be quite what you want. If you want true string generation, you'd need a template library. -SS On Jul 29,

Re: java 1.4 class files

2009-07-29 Thread Stuart Sierra
The Clojure runtime classes target Java 1.5. Compiled clojure source files still require clojure.jar. So the answer is probably no, it's not possible. -SS On Jul 29, 9:26 am, Frank frakoe.koe...@googlemail.com wrote: Hi there, is it possible to compile clojure source to Java 1.4 class

Re: RT and namespaces

2009-07-28 Thread Stuart Sierra
I think the compiler defaults to the user namespace. -SS On Jul 28, 11:09 am, Jeff Brown jeffscottbr...@gmail.com wrote: If I have a clojure script that looks like this... (ns foo) (defn myfunc [n]   ...) I can call that function from Groovy using something like this... Compile.load

Re: Java based DocDB

2009-07-27 Thread Stuart Sierra
It's not exactly a document database, but I have used Solr to store retrieve text documents. It's pure Java, runs either embedded in your app or as a standalone HTTP service. Using the Java API from Clojure is easy. It's stable, but you should keep a backup copy of your files in case the

Re: Basic hadoop example in clojure.

2009-07-27 Thread Stuart Sierra
Hi rdsr, The problem is that you're trying to use the maxtemperature as a class name before it's finished compiling. To work around that, use (Class/forName maxtemperature) instead. You can also see my (very task-specific) Hadoop/Clojure integration at http://tinyurl.com/mqv2os and

Re: Thread local data structures

2009-07-27 Thread Stuart Sierra
That sounds really, really hard. Because even if the structure is used in only one thread, you have to check that there's never a reference to an older version. You could theoretically re-implement the Persistent List/Map/Set interfaces with mutable implementations, but I don't know where to go

Re: Very minor problem in the REPL

2009-07-25 Thread Stuart Sierra
That's a general problem with multiple threads printing to the same stream, and not something that can be easily avoided. -Stuart On Jul 25, 12:48 pm, ronen nark...@gmail.com wrote: Iv stumbled this also when using Threads, (http://

Re: Where Is Documentation for Compiling Clojure Files from the Command Line Using Something Like javac?

2009-07-24 Thread Stuart Sierra
clojure.lang.Compile your.namespace.name Note that your compiled .class file will still need clojure.jar on the classpath in order to run. Clojure cannot compile files that run independently of the Clojure runtime. You can see an example in the build.xml file for clojure-contrib. -Stuart Sierra

Re: OutOfMemoryError using coljure.contrib.duck-streams

2009-07-24 Thread Stuart Sierra
line breaks, or that it has extremely long lines. In that case, you'll have to increase the Java heap size or manually read the file in smaller chunks. -Stuart Sierra On Jul 24, 10:28 am, Alexander Stoddard alexander.stodd...@gmail.com wrote: I am a very new clojure user but I believe I have

Re: OutOfMemoryError using coljure.contrib.duck-streams

2009-07-24 Thread Stuart Sierra
I should admit that there may be something else I'm missing here. write-lines is not a lazy sequence function, so it may be responsible for holding the head of the sequence. I can't reproduce the error, though. -SS On Jul 24, 11:29 am, Stuart Sierra the.stuart.sie...@gmail.com wrote: I'm

Re: Can (genclass) be changed to operate when not compiling?

2009-07-22 Thread Stuart Sierra
On Jul 21, 6:55 pm, Howard Lewis Ship hls...@gmail.com wrote: It would be nice if (gen-class), when not in compile mode, would still create a class in memory that could be referenced by class name elsewhere in Clojure. The gen-class function does nothing unless the *compile-files* var is

Re: Function of clojure.templates

2009-07-21 Thread Stuart Sierra
Hi Tim, Samppi, clojure.contrib.template (since renamed clojure.template) has gone through a couple of different forms. Basically, do-template does something similar to map but at compile time. This was necessary for the are macro in clojure.contrib.test- is (since renamed clojure.test). Look

Re: sizeof in Clojure

2009-07-21 Thread Stuart Sierra
Hi Jan, Short answer: no, because Java has no sizeof operator. You can use Java profiling tools to examine the memory usage of your app if needed. Since all of clojure's data structures are persistent (reusable), they won't necessarily meet your expectations for memory usage based on the

Re: thread-pool scope

2009-07-21 Thread Stuart Sierra
Hi Dan, I'm not sure, but closures actually sound like the way to go here. That would be the traditional functional-programming solution to this problem. It's true the Java equivalent is ugly, but that's because Java doesn't have real closures. :) -SS On Jul 20, 3:30 pm, Dan Fichter

Re: Loop, Recur, and Binding

2009-07-18 Thread Stuart Sierra
Hi, Tim, I'm not 100% certain what is going on here, but I do know that, in general, binding and loop/recur should not be mixed. recur is not true recursion -- it's more like a GOTO. The binding macro establishes thread-local bindings using the static methods

Re: clojure.test - Test fixtures and ordering

2009-07-14 Thread Stuart Sierra
] `(... set-up ... ~...@body ... tear-down ...))) (deftest foo (with-db ...)) That way you can decide exactly where the fixture should be run. This is how I used to do fixtures before implementing them in the testing library. -Stuart Sierra

Re: binding issue

2009-07-14 Thread Stuart Sierra
On Jul 14, 3:01 pm, bgray graybran...@gmail.com wrote: Ok, so *if* this is intended behavior, what have people been doing to bind variables dependant on other bindings?  I can't be the first to run into this. Just nest multiple binding forms: (binding [a ...] (binding [b ...] ...))

Re: clojure.test - Test fixtures and ordering

2009-07-14 Thread Stuart Sierra
On Jul 14, 1:23 pm, Jarkko Oranen chous...@gmail.com wrote: Perhaps it would be best to consider test-ns-hook a low-level construct that can do whatever it wants with the defined tests and fixtures, and provide some other means for specifying which tests will be run. Yes, I'm leaning this

classloaders, modularity, packaging

2009-07-13 Thread Stuart Sierra
on the Java side (Maven, Ivy). I especially want to look at the Java module-loading frameworks like OSGI and Java EE. So I'm asking for suggestions of things you think I should research, especially any Clojure integration stuff that people are working on. Thanks, -Stuart Sierra

<    4   5   6   7   8   9   10   11   12   13   >