Re: file io

2009-03-25 Thread Korny Sietsma
Hmm - both literal clojure structures, and JSON, are tempting. JSON is probably my preferred option - but a lot depends on the audience. If the audience is lisp programmers, then literal structures is probably ideal. If the audience is other programmers, I'd probably go for JSON. If the audience is

Re: Proposed Change to str-utils

2009-03-25 Thread Tom Faulhaber
Having great string and regex manipulation is a must for anything that will be used as a scripting language and I think this should be conveniently available in Clojure. So, yes, I agree that these functions are ones that it makes sense to wrap. I'm not (yet, at least) commenting specifically on

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 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 lower level functions, w

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 twe

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 plu

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 funcati

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 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 my functions in a way th

Re: Running multiple scripts from the Java realm

2009-03-25 Thread Berlin Brown
On Mar 25, 3:16 am, Berlin Brown wrote: > On Mar 25, 3:12 am, BerlinBrown 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,

Re: exposing specific functions via namespace

2009-03-25 Thread John D. Hume
On Wed, Mar 25, 2009 at 12:05 PM, Parth 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 :load for loadin

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=gst&q=trace#7479682cdf3a1b97 - Craig McDaniel's trace2.

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

Re: O-R mapping

2009-03-25 Thread pmf
On Mar 25, 11:35 pm, Raoul Duke 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 experience. In FP, yo

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

Re: Why not "sorted-set-by"?

2009-03-25 Thread hjlee
Thank you, hoeck. Thank you Chouser, your code taught me about "proxy". When I saw the patch 1st time, I missed java parts. before I saw your code, I thought if I need that again then I could use the code without affecting core. (What a wrong conclusion ^^; ) ps. I was embarrassed when my 4 post

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 a

Re: Turning a non-standard iterator into a seq

2009-03-25 Thread Allen Rohner
> Calling > >    (def input (BufferedReader. (FileReader. "data/dm4p1/dm4p1.dEID"))) >    (def data (RichSequence$IOTools/readFastaDNA input nil)) >    (doseq [d (bio-iterator-seq data)] (prn 'Sequence (show d))) > > Printed all the sequences from the file, as required. > > Just to be sure, is `d

Re: Turning a non-standard iterator into a seq

2009-03-25 Thread Mark Reid
On Mar 26, 1:10 am, Stuart Sierra wrote: > Hi Mark, > You'll need to work at a lower level using cons and lazy-seq. > Something like this (untested): > > (defn bio-iterator-seq [iterator] >   (lazy-seq >     (when (.hasNextiterator) >       (cons (.nextSequenceiterator) (bio-iterator-seqiterator)

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 message

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 correct

O-R mapping

2009-03-25 Thread Raoul Duke
hi, 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? thanks! --~--~-~--~~~---~--~~ You received this message bec

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 wrote: > 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 p

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

Re: Slime integration

2009-03-25 Thread vseguip
On 24 mar, 05:29, Phil Hagelberg wrote: > Vagif Verdi 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 implemented, or i > > setup something

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

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

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: Why not "sorted-set-by"?

2009-03-25 Thread Chouser
On Wed, Mar 25, 2009 at 7:21 AM, hoeck 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=76&colspec=ID%20Type%20Status%20Priority%20Reporter%20Owner%20Summary > > But its priority i

Re: oo

2009-03-25 Thread mikel
On Mar 25, 2:51 pm, Marko Kocić 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 adapt such a librar

Re: oo

2009-03-25 Thread mikel
On Mar 25, 12:35 pm, Konrad Hinsen 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 the struct.  Some h

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 corr

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 c

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 downcase

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 wrote: > is there something as simple as this in clojure? > > whole python program: > >  

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

Re: exposing specific functions via namespace

2009-03-25 Thread Parth
On Mar 25, 7:04 pm, Parth Malwankar wrote: > 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

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 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 so-called `face

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 Cloju

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

2009-03-25 Thread Paul Drummond
2009/3/25 David Plumpton : > 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 Drive, Houghton-le-Spring,

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 t

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: http://news.ycombinator.com/item?id=5318

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.

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: Turning a non-standard iterator into a seq

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

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 f

Re: dynamic member-symbol in (.) form

2009-03-25 Thread Stuart Sierra
On Mar 24, 8:48 pm, ninix 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. It wouldn't be too

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 to

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 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/ ;-) --~--~-~--~~~---~--~~ You received

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 SequenceIterator from the BioJava library into a lazy Clojure seq. The interface has two methods `hasNext()` and `nextSequence()` which have very similar semantics to `hasNext()` and `next()` for the standard Java Iterator interface. I have

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=76&colspec=ID%20Type%20Status%20Priority%20Reporter%20Owner%20Summary But its priority is set tow "low". erik --~--~-~--~---

Re: Generic functions again

2009-03-25 Thread mikel
On Mar 24, 10:51 pm, mikel wrote: > On Mar 24, 5:37 pm, Meikel Brandmeyer 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 automated and predictable answe

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=gst&q=slurp+name#bce36a47121d6faf IMO changing these names w

Re: oo

2009-03-25 Thread mikel
On Mar 25, 4:13 am, Mark Engelberg wrote: > On Wed, Mar 25, 2009 at 1:44 AM, Konrad Hinsen > > 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 di

Re: file io

2009-03-25 Thread Paul Drummond
2009/3/25 e : > 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 up to core or

Re: dynamic member-symbol in (.) form

2009-03-25 Thread Laurent PETIT
Hi, 2009/3/25 ninix > > 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 is not eva

Re: dynamic member-symbol in (.) form

2009-03-25 Thread ninix
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 is not evaluated, shouldn't the exception be (at

Re: oo

2009-03-25 Thread Mark Engelberg
On Wed, Mar 25, 2009 at 1:44 AM, Konrad Hinsen 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 summarize, I think th

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 som

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

Re: Running multiple scripts from the Java realm

2009-03-25 Thread Berlin Brown
On Mar 25, 3:12 am, BerlinBrown 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 way to ensure >

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 anothe