Re: Generic functions again

2009-03-25 Thread Cosmin Stejerean
On Tue, Mar 24, 2009 at 5:37 PM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 24.03.2009 um 22:36 schrieb mikel: CLOS says that if two matches are otherwise equally specific, the one on the left wins. Similarly, it says that if two classes define slots with the same name, the one

Running multiple scripts from the Java realm

2009-03-25 Thread BerlinBrown
I know it isn't advised but I have my various reasons. What are some of the best ways to invoke clojure scripts from Java but still maintain the state of the current session. For example, if I run a script from Java, is there a way to ensure that script has already been run...say if I run

Re: Running multiple scripts from the Java realm

2009-03-25 Thread Berlin Brown
On Mar 25, 3:12 am, BerlinBrown berlin.br...@gmail.com wrote: I know it isn't advised but I have my various reasons. What are some of the best ways to invoke clojure scripts from Java but still maintain the state of the current session. For example, if I run a script from Java, is there a

Re: dynamic member-symbol in (.) form

2009-03-25 Thread Laurent PETIT
Hello, No, it's not possible, dot (.) is a special form and disallows this. Search this mailing list for the subject Help with the dot operator special form for a similar discussion on the ways to achieve more dynamic (runtime) method resolution. HTH, -- Laurent 2009/3/25 ninix

Re: oo

2009-03-25 Thread Konrad Hinsen
On 24.03.2009, at 19:29, mikel wrote: I personally like Haskell's philosophy in this area: there is a facility for defining data layouts, and there is a facility for defining protocols, and they are completely separate. You can define a I like that as well, and I have been trying to do

Re: oo

2009-03-25 Thread Mark Engelberg
On Wed, Mar 25, 2009 at 1:44 AM, Konrad Hinsen konrad.hin...@laposte.net wrote: Could you elaborate a bit on this? I haven't met any major obstacles with multimethods yet. The dispatch functions give quite a lot of flexibility in practice. In what situation did you find them inconvenient? To

Re: dynamic member-symbol in (.) form

2009-03-25 Thread Laurent PETIT
Hi, 2009/3/25 ninix nitzan@gmail.com Thanks. 1) The returned exception is misleading. For example, in the following (contrived) case: user= (. obj (toString )) java.lang.IllegalArgumentException: No matching method found: toString for class java.lang.Object Since the member-symbol

Re: file io

2009-03-25 Thread Paul Drummond
2009/3/25 e evier...@gmail.com: For example, slurp is, perhaps, marginally better than read because it may help express that it reads the whole file. Anyone else hate the names 'slurp' and 'spit' as much as me? IMO changing these names would be a great idea whether these functions are moved

Re: oo

2009-03-25 Thread mikel
On Mar 25, 4:13 am, Mark Engelberg mark.engelb...@gmail.com wrote: On Wed, Mar 25, 2009 at 1:44 AM, Konrad Hinsen konrad.hin...@laposte.net wrote: Could you elaborate a bit on this? I haven't met any major obstacles with multimethods yet. The dispatch functions give quite a lot of

Re: file io

2009-03-25 Thread Stephen C. Gilardi
On Mar 25, 2009, at 5:52 AM, Paul Drummond wrote: Anyone else hate the names 'slurp' and 'spit' as much as me? You're not alone there. http://groups.google.com/group/clojure/browse_frm/thread/d8064dbb94c5cd2c/bce36a47121d6faf?lnk=gstq=slurp+name#bce36a47121d6faf IMO changing these names

Re: Generic functions again

2009-03-25 Thread mikel
On Mar 24, 10:51 pm, mikel mev...@mac.com wrote: On Mar 24, 5:37 pm, Meikel Brandmeyer m...@kotka.de wrote: [...snip...] I wanted to call out a point that I made before, but that is maybe buried in a little too much verbiage. The point is that there is maybe a way for me to implement an

Re: Why not sorted-set-by?

2009-03-25 Thread hoeck
Hi hjlee, there is already a filed issue and a patch from Timothy Pratley which adds sorted-set-by to clojure: http://code.google.com/p/clojure/issues/detail?id=76colspec=ID%20Type%20Status%20Priority%20Reporter%20Owner%20Summary But its priority is set tow low. erik

Turning a non-standard iterator into a seq

2009-03-25 Thread Mark Reid
Hi, I am very new to Clojure and I am trying to turn a a href=http:// www.biojava.org/docs/api/org/biojava/bio/seq/SequenceIterator.htmlSequenceIterator/a from the BioJava library into a lazy Clojure seq. The interface has two methods `hasNext()` and `nextSequence()` which have very similar

Re: Trying to get a list of random numbers using repeat

2009-03-25 Thread David Plumpton
On Mar 24, 12:43 pm, Paul Drummond paul.drumm...@iode.co.uk wrote: Hi all, user= (repeat 10 (rand-int 49)) (4 4 4 4 4 4 4 4 4 4) Can someone please tell me why this doesn't work? I think this explains your problem: http://xkcd.com/221/ ;-)

Re: Generic functions again

2009-03-25 Thread Laurent PETIT
Could possibly clojure multimethods be enhanced to support more general use cases (enabling to e.g. define generic functions on top of it), while still be fast for the current behavior ? It seems to me that being able to redefine the function that matches the computed dispatch-value of the call

Re: dynamic member-symbol in (.) form

2009-03-25 Thread Stuart Sierra
On Mar 24, 8:48 pm, ninix nitzan@gmail.com wrote: Is there any way to get a dynamic member-symbol for use in the (.) special form? Nope. Your options are 1) use the Java reflection API; or 2) use Clojure's internal reflection methods. I recommend (1), because that's a well-defined API.

exposing specific functions via namespace

2009-03-25 Thread Parth Malwankar
Hello, I am trying to organise my code in namespaces and needed a little help. Basically I have created the following namespaces similar to the following: src/org/ppm/foo.clj - org.ppm.foo src/org/ppm/foo/ src/org/ppm/foo/bar.clj - org.ppm.foo.bar src/org/ppm/foo/baz.clj - org.ppm.foo.baz

Re: Turning a non-standard iterator into a seq

2009-03-25 Thread Stuart Sierra
On Mar 25, 1:55 am, Mark Reid mark.r...@gmail.com wrote: I am very new to Clojure and I am trying to turn a a href=http://www.biojava.org/docs/api/org/biojava/bio/seq/SequenceIterator.html;SequenceIterator/a from the BioJava library into a lazy Clojure seq. The interface has two methods

Using proxy with new method being added

2009-03-25 Thread billh04
I want to use proxy to add a new method to a Java class rather than just overriding an existing method in the Java class. Here is what I have: (def #^Object bar (proxy [Object] [ ] (foo [number] (* 3 number (def fooFn ((proxy-mappings

Re: Using proxy with new method being added

2009-03-25 Thread Krešimir Šojat
(def #^Object bar (proxy [Object] [ ] (foo [number] (* 3 number (def fooFn ((proxy-mappings bar) foo))  ;; kludge  ;; succeeds (def bar4 (fooFn bar 4)) ;; fails with No matching method found: foo for class

Clojure Talk @ Philly ETE

2009-03-25 Thread Kyle R. Burton
Clojure and The Robot Apocalypse Also, I posed those to hackernews in the hope of increasing advocacy for both that event (which it turns out I can't make) and for Clojure. The main site is: http://www.phillyemergingtech.com/ The hackernews posts are:

Re: STM and useful concurrency

2009-03-25 Thread cliffc
A bunch of separate real concerns here: --- On the issue of STM Slowdown: - Clojure is typically slower than Java by an interesting amount when doing Plain Olde Java Stuff, unless great care is taken (it's possible to take great care). Such a slowdown matters less than the ability

Re: Trying to get a list of random numbers using repeat

2009-03-25 Thread Paul Drummond
2009/3/25 David Plumpton david.plump...@gmail.com: I think this explains your problem: http://xkcd.com/221/ There is something to be said for that function. At least it has no side-effects ;) -- Iode Software Ltd, registered in England No. 6299803. Registered Office Address: 12 Sancroft

Clojure + Java compilation and IntelliJ IDEA plugin

2009-03-25 Thread Ilya Sergey
Hello, all. I've just uploaded new version of La Clojure plugin for IntelliJ IDEA. Among several bugfixes and minor changes I have to note several essential moments. 1. Now Clojure support is added as so-called `facet', which may be attached to every module. Creating new module, just choose

Re: Clojure + Java compilation and IntelliJ IDEA plugin

2009-03-25 Thread Christian Vest Hansen
Sounds great :) On Wed, Mar 25, 2009 at 4:42 PM, Ilya Sergey ilyas...@gmail.com wrote: Hello, all. I've just uploaded new version of La Clojure plugin for IntelliJ IDEA. Among several bugfixes and minor changes I have to note several essential moments. 1. Now Clojure support is added as

Re: oo

2009-03-25 Thread Konrad Hinsen
On 25.03.2009, at 10:13, Mark Engelberg wrote: 1. Structs don't inherently have a type. If you want to dispatch on type (a common use-case), you have to make a constructor that inserts the type information as part of the struct. Some have expressed And/or in the metadata. concern that it

Re: file io

2009-03-25 Thread Rayne
I wrote a simple, small configuration file parser and reader that uses the duck-streams library. You might find some of the examples interesting. http://paste.pocoo.org/show/109498/ On Mar 24, 11:20 am, e evier...@gmail.com wrote: is there something as simple as this in clojure? whole python

Re: Proposed Change to str-utils

2009-03-25 Thread Perry Trolard
Whatever it's worth as a datum, my experience is that I usually find myself writing upcase, downcase, titlecase functions in most applications, because (1) they're prettier more succinct when passed as first-class (downcase vs. #(.toLowerCase %)) (2) I can add type hints once, in the

Re: oo

2009-03-25 Thread Marko Kocić
Does anybody know of some minimal clos implementation that is easily portable? I suppose that it contain base functions that are implemented in CL, and the rest of clos built on top of that. It might be interesting to try to adapt such a library to clojure. I remember people mentioning PCL and

Re: Clojure + Java compilation and IntelliJ IDEA plugin

2009-03-25 Thread Stuart Halloway
Hi Ilya, I would like to be able to demo the sample code from the book in IDEA. Here are a few things I am seeing so far: (1) When I set a breakpoint, I get a warning icon that says no executable code found at... but the breakpoint does in fact seem to work. (2) The variable window

Re: oo

2009-03-25 Thread mikel
On Mar 25, 12:35 pm, Konrad Hinsen konrad.hin...@laposte.net wrote: On 25.03.2009, at 10:13, Mark Engelberg wrote: 1. Structs don't inherently have a type.  If you want to dispatch on type (a common use-case), you have to make a constructor that inserts the type information as part of

Re: oo

2009-03-25 Thread mikel
On Mar 25, 2:51 pm, Marko Kocić marko.ko...@gmail.com wrote: Does anybody know of some minimal clos implementation that is easily portable? I suppose that it contain base functions that are implemented in CL, and the rest of clos built on top of that. It might be interesting to try to

Re: Why not sorted-set-by?

2009-03-25 Thread Chouser
On Wed, Mar 25, 2009 at 7:21 AM, hoeck i_am_wea...@kittymail.com wrote: there is already a filed issue and a patch from Timothy Pratley which adds sorted-set-by to clojure: http://code.google.com/p/clojure/issues/detail?id=76colspec=ID%20Type%20Status%20Priority%20Reporter%20Owner%20Summary

Re: Proposed Change to str-utils

2009-03-25 Thread Sean
Perry, 1. Thanks for the tip on using type hints! I just added them to my code and pushed it to github 2. If you take a close look at my re- * methods, I actually tried to enforce an arity of 2 on as many methods as I could. This way the methods would read like so (re-split input-sting

Re: file io

2009-03-25 Thread Korny Sietsma
ooh - that's precisely why I was looking into duck-streams myself; thanks for that! Mind you, after a while in the Ruby world, I'd highly recommend looking at YAML for config files - it's human readable and fairly easily writeable, and lets you add arrays, nested structures, etc. fairly easily.

Re: file io

2009-03-25 Thread Laurent PETIT
And why not just use clojure source code literal datastructures as the persistence format ? With the pretty print function released by Tom Faulhaber, it's even possible to painlessly write configuration back while keeping it clear (though not currently possible to maintain things such as

Re: Slime integration

2009-03-25 Thread vseguip
On 24 mar, 05:29, Phil Hagelberg p...@hagelb.org wrote: Vagif Verdi vagif.ve...@gmail.com writes: When i use slime with lisp, it shows me function parameters, when cursor is on a function name. But with clojure it only shows me Evaluation Aborted. Is this because that feature not

Re: Proposed Change to str-utils

2009-03-25 Thread linh
Hi, I would generally agree with Stuart that wrapping Java functions is not a good idea. However, string functions come up so often that I think that this is one area where the rule should be broken, if only for readablility. I agree, I use these string functions frequently. Maybe these

Re: file io

2009-03-25 Thread Mark McGranaghan
+ 1 for literal using literal Clojure data structures for configuration. On Wed, Mar 25, 2009 at 5:50 PM, Laurent PETIT laurent.pe...@gmail.com wrote: And why not just use clojure source code literal datastructures as the persistence format ? With the pretty print function released by Tom

Re: Slime integration

2009-03-25 Thread vseguip
Just responding to myself, the issue seems to have been fixed by itself. OTOH compiler errors don't popup like before. I can see them in the *SLIME Compilation* buffer but clicking on them doesn't lead to the source code. The faulty lines are also not highlighted in anyway way now. Is this

Re: Clojure + Java compilation and IntelliJ IDEA plugin

2009-03-25 Thread Mark Engelberg
If we've already downloaded the first plugin, what's the best way to upgrade? Do you have to delete the first one, or just install the second on top? Is there a way to update the plugin from within the IDE? Thanks. --~--~-~--~~~---~--~~ You received this

Re: Clojure + Java compilation and IntelliJ IDEA plugin

2009-03-25 Thread Ilya Sergey
Hello, Mark. The easiest way to updae plugin from within the idea is to use plugin manager (see File - Settings - Plugins), find Clojure plugin in the list, right-click on it and hit update. AFAIK, you also must see kind of blinking gear in the bottom right corener of IDEA main screen, which

Re: Clojure + Java compilation and IntelliJ IDEA plugin

2009-03-25 Thread Ilya Sergey
Hello, Christian Could you explain the reasoning behind compiling the Clojure code before the Java code? It's very good question, and to be honest I don't know exact question for it. I may imagine both cases from Clojure to Java and vise versa. Making first variant default I was followed by

Re: Clojure + Java compilation and IntelliJ IDEA plugin

2009-03-25 Thread Ilya Sergey
Hi, Stuart. I would like to be able to demo the sample code from the book in IDEA That's great, I'm really happy to hear it. As for all three issues you've mentioned, all of them have same origin and related to so-called evaluator API. What you can see now using debugger is nothing but vanilla

Re: O-R mapping

2009-03-25 Thread pmf
On Mar 25, 11:35 pm, Raoul Duke rao...@gmail.com wrote: if one doesn't have to convert the db into objects, then is there less impedance mismatch? what is a nice setup in a functional language for working with a db schema? what is your experience/thought? Somewhat less, at least in my

Re: file io

2009-03-25 Thread e
clojure file sounds good to me, but who am I? now, a JSON file that would sound good to a whole LOT of people . . . .and is compatible with many many languages ... even looks lispy. JSON is a good thing to get behind because it has a chance of killing xml. On Wed, Mar 25, 2009 at 6:19 PM,

Yet another trace library.

2009-03-25 Thread hjlee
While searching usable trace libray in clojure, I found 3 pieces of codes. - Stuart Sierra's clojure.contrib.trace - Rich Hickey's posting http://groups.google.com/group/clojure/browse_thread/thread/fd315d9dfdb8c32c/7479682cdf3a1b97?lnk=gstq=trace#7479682cdf3a1b97 - Craig McDaniel's

Re: exposing specific functions via namespace

2009-03-25 Thread John D. Hume
On Wed, Mar 25, 2009 at 12:05 PM, Parth parth.malwan...@gmail.com wrote: I have split up the foo namespace across multiple files. So, I have the following now: src/org/ppm/foo.clj - org.ppm.foo src/org/ppm/bar.clj - org.ppm.foo src/org/ppm/baz.clj - org.ppm.foo With foo.clj using the ns

Re: Running multiple scripts from the Java realm

2009-03-25 Thread Berlin Brown
On Mar 25, 3:16 am, Berlin Brown berlin.br...@gmail.com wrote: On Mar 25, 3:12 am, BerlinBrown berlin.br...@gmail.com wrote: I know it isn't advised but I have my various reasons. What are some of the best ways to invoke clojure scripts from Java but still maintain the state of the

Re: Is Clojure's lack of support for forward referencing a feature or a bug?

2009-03-25 Thread Mark Engelberg
On Wed, Mar 11, 2009 at 5:18 PM, Timothy Pratley timothyprat...@gmail.com wrote: It is also quite trivial to patch the compiler to auto-def symbols as it finds them instead of throwing an error. I would be interested in knowing how to do such a patch. When I work on code, I like to organize

Re: Clojure + Java compilation and IntelliJ IDEA plugin

2009-03-25 Thread AlamedaMike
It's very good question, and to be honest I don't know exact question for it. I may imagine both cases from Clojure to Java and vise versa. Making first variant default I was followed by one letter I had received. It was about some project written in IDEA, where Clojure is used for core

Re: Is Clojure's lack of support for forward referencing a feature or a bug?

2009-03-25 Thread Timothy Pratley
Hi Mark, A fuller discussion can be found here: http://groups.google.com/group/clojure/browse_thread/thread/a99b420d5ee0aa40/47f8c2ab6845e9ae Which has links to the simple patch I tried, and discusses the more advanced technique Laurent experimented with. Elena subsequently developed an emacs

Re: Is Clojure's lack of support for forward referencing a feature or a bug?

2009-03-25 Thread David Nolen
For what it's worth I'm a big fan of the wishful thinking programming style. I write some functions how I think they should look, declare the functions I haven't defined yet. Then I implement the lower level functions, write some tests- then usually the higher level stuff works without too much

Re: Is Clojure's lack of support for forward referencing a feature or a bug?

2009-03-25 Thread Timothy Pratley
:) I like that description! :) On Mar 26, 4:47 pm, David Nolen dnolen.li...@gmail.com wrote: For what it's worth I'm a big fan of the wishful thinking programming style. I write some functions how I think they should look, declare the functions I haven't defined yet. Then I implement the