simple-peg, sharing my experience and looking for advice, forks, patches, or anything I can get

2010-01-29 Thread Brent Millare
A few days ago, I posted my unfinished rendition of a PEG parser generator on github, accessible at http://github.com/bmillare/simple-peg/ (Note, if you are looking for a working lib for parsing expression grammars (PEGs), please refer to http://www.lithinos.com/clj-peg/ ) I find writing parsers to

Re: idiom question: infinite sequence as data source for many threads?

2010-01-29 Thread Timothy Pratley
Below I present 'submit-future' which is similar to the existing 'future' call in that it spawns a thread to execute a task, but differs in that it will block if n submitted futures are already running, where n is the number of available processors. I think this could be quite handy for the produce

Re: Standard Practice for a Canned Lexer, Parser, Analyzer?

2010-01-29 Thread Michael Wood
On 30 January 2010 01:18, Alex Osborne wrote: > Liam writes: > >> Could someone educate me about what developers normally do when faced >> with having to create a lexer / parser / analyzer, say for clojure? > > For parsing something like Clojure I would probably do it by hand, as > the syntax is

Re: Exception handling functional style

2010-01-29 Thread Konrad Hinsen
Lukas Lehner a écrit : Now, imagine the chain of calling functions is relatively big. Here it can all fall down on access-external-source causing an exception, but further up, maybe the message is scrambled, or pretty much anything. The question is, wrapping all function in try - catch does n

Re: idiom question: infinite sequence as data source for many threads?

2010-01-29 Thread free_variation
Thank you Meikel, I was aware of the nil issue but it's good that you made that explicit. I got rid of the 'symbol per your suggestion, and factored the closure to take the stream as an input: (defn init-features [stream] (let [feature-stream (ref stream)] (dosync (ref-set

c.c.logging patches

2010-01-29 Thread ataggart
Could someone with the necessary rights please apply the patches for contrib tickets 44 and 58. http://www.assembla.com/spaces/clojure-contrib/tickets/44 http://www.assembla.com/spaces/clojure-contrib/tickets/58 -- You received this message because you are subscribed to the Google Groups "Cloju

Re: return value of use, requires?

2010-01-29 Thread Timothy Pratley
>> in the repl when i (use 'foo) vs. (use :foo) they both return nil, so >> it doesn't help me know that the former is right and the latter isn't. >> i think. would it be sensible for use to return true or something more >> positive than nil if it successfully brings in a namespace? > Ok. Ticket (a

Re: update-in and get-in why no default?

2010-01-29 Thread Timothy Pratley
2010/1/30 Rich Hickey : > Patches welcome for get-in, and my fnil. Groovy! uploaded to: https://www.assembla.com/spaces/clojure/tickets/256-get-in-optional-default-value https://www.assembla.com/spaces/clojure/tickets/257-add-fnil-for-wrapping-functions-to-handle-nil Regards, Tim. -- You recei

Re: Standard Practice for a Canned Lexer, Parser, Analyzer?

2010-01-29 Thread Liam
Roberto and Alex, thanks for your feedback. This is informative. I appreciate your perspectives & links. -- 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

Re: clojure.contrib.test-contrib.test-jmx build error

2010-01-29 Thread Michał Marczyk
Well, with sources freshly pulled from github just now, I was able to build contrib with no trace of the problem... Doing a (require 'clojure.contrib.jmx) followed by run-tests at the REPL also works. Still no idea what it was about, hoping it's gone for good. Thanks for the answers, it was reassu

Re: Standard Practice for a Canned Lexer, Parser, Analyzer?

2010-01-29 Thread Alex Osborne
The way most parser generators work is that you can attach arbitrary pieces of code to be run at certain points during parsing. Usually you use this to build up your abstract syntax tree (AST). No information (except perhaps things like comments and whitespace if you don't need to preserve them)

Re: Standard Practice for a Canned Lexer, Parser, Analyzer?

2010-01-29 Thread Alex Osborne
Liam writes: > Could someone educate me about what developers normally do when faced > with having to create a lexer / parser / analyzer, say for clojure? For parsing something like Clojure I would probably do it by hand, as the syntax is regular-enough that it's pretty easy to do. For parsing

Re: Remote swank cannot recconnect

2010-01-29 Thread Kyle R. Burton
I'll add that into my notes and my configuration. Thanks, Kyle On Wed, Jan 27, 2010 at 4:07 AM, Lukas Lehner wrote: > Hi Kyle > > Making a new ssh tunnel is a sure thing. The bad part was that the swank > server got "deaf". I could see agents still running (unix screen is cool) > but I could n

Re: Exception handling functional style

2010-01-29 Thread Meikel Brandmeyer
Hi, Am 29.01.2010 um 22:12 schrieb Lukas Lehner: > So, if they (monads) truly solve this kind of problems, then it's time to go > back to study... Maybe you also want to have a look at error-kit. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "C

Re: Exception handling functional style

2010-01-29 Thread Lukas Lehner
Monads, I knew I cannot avoid them after all. I've tried digging into the two main clojure-monad tutorials but got kinda lost, repeatedly. So, if they (monads) truly solve this kind of problems, then it's time to go back to study... Thanks On 1/29/2010 7:49 PM, Raoul Duke wrote: On Fri, Ja

Re: more lazy "fun"

2010-01-29 Thread DanL
Hello! On 29 Jan., 20:14, Meikel Brandmeyer wrote: > CL find as I understand it: (some (partial = x) some-coll). Sufficiently ugly > to show performance characteristics. > CL member as I understand it: (drop-while (partial not= x) some-coll). > Sufficiently ugly to show performance characterist

Re: more lazy "fun"

2010-01-29 Thread Sean Devlin
That's a great point. A contains? should be used in that case. On Jan 29, 2:14 pm, Meikel Brandmeyer wrote: > Hi, > > Am 29.01.2010 um 03:49 schrieb Sean Devlin: > > > I'd do one thing differently than Tim.  (partial = something) is a > > clojure smell.  It's more idiomatic to use a set > > > (i

Re: Using docs effectively (Ratio)

2010-01-29 Thread Meikel Brandmeyer
Patch submitted https://www.assembla.com/spaces/clojure/tickets/254-Expose-c-l-Ratio-s-accessors -- 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 modera

Re: interesting puzzle

2010-01-29 Thread Meikel Brandmeyer
Hi, Am 29.01.2010 um 20:45 schrieb Wilson MacGyver: > I had assumed when he wrote "do not use iteration", > what he meant is to "not use for/next loop" That's how I understood it. Especially since all solutions at the pastie link more or less use recursion. (Even when they cheat and call out to

Re: Exception handling functional style

2010-01-29 Thread ataggart
On Jan 29, 4:24 am, Lukas Lehner wrote: > The question is, wrapping all function in try - catch does not make is > clearer (from a processing point of view). Returning nil from broken > functions just adds a boilerplate code all the way up. In my opinion one should only catch those exceptions

Re: interesting puzzle

2010-01-29 Thread Wilson MacGyver
I had assumed when he wrote "do not use iteration", what he meant is to "not use for/next loop" otherwise, as you said, we can't solve the problem without examining the sequence. On Fri, Jan 29, 2010 at 2:38 PM, Meikel Brandmeyer wrote: > Hi, > > Am 29.01.2010 um 16:25 schrieb Wilson MacGyver: >

Re: interesting puzzle

2010-01-29 Thread Meikel Brandmeyer
Hi, Am 29.01.2010 um 16:25 schrieb Wilson MacGyver: > I saw this on twitter. > > http://pastie.org/796264 > > The problem: given a list of strings, produce a list where sequential > non-empty strings are concatenated > > # Conditions: Do not use iteration. > # > # Example: glom (["a", "b", "c"

Re: clojure box 1.0 failed to connect to emacs server

2010-01-29 Thread Rollo
Seconded. I have the same problem on win7, augmented by the fact that emacs spawns thousands of cmdproxy.exe... Depending on your machine capabilities, the only thing to do then is a hot reboot (try killing 5000 processes with new ones starting off every second). Works fine on winxp though... On J

Re: more lazy "fun"

2010-01-29 Thread Meikel Brandmeyer
Hi, Am 29.01.2010 um 03:49 schrieb Sean Devlin: > I'd do one thing differently than Tim. (partial = something) is a > clojure smell. It's more idiomatic to use a set > > (if (some #{"foo"} ["foo" "bar"]) "yay" "humbug") This will fail if the collection is allowed to contain nil or false. Sin

Re: more lazy "fun"

2010-01-29 Thread Meikel Brandmeyer
Hi, Am 29.01.2010 um 12:57 schrieb DanL: CL find as I understand it: (some (partial = x) some-coll). Sufficiently ugly to show performance characteristics. CL member as I understand it: (drop-while (partial not= x) some-coll). Sufficiently ugly to show performance characteristics. Sincerely Me

Re: apply macro to 'argument' list?

2010-01-29 Thread b2m
Just linking this diskussion to an earlier one: http://groups.google.com/group/clojure/browse_thread/thread/b38a2754fd5b8104/fcd7c578238622f5 -- 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

Re: Exception handling functional style

2010-01-29 Thread Raoul Duke
On Fri, Jan 29, 2010 at 4:24 AM, Lukas Lehner wrote: > The question is, wrapping all function in try - catch does not make is > clearer (from a processing point of view). Returning nil from broken > functions just adds a boilerplate code all the way up. > > I could not find any guidelines of syste

Re: apply macro to 'argument' list?

2010-01-29 Thread Raoul Duke
On Thu, Jan 28, 2010 at 6:43 PM, Sean Devlin wrote: > Check the apply-macro namespace in contrib ah-hah! i really should have figured. thanks. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups

What is clojure.lang.Sequential good for?

2010-01-29 Thread Konrad Hinsen
In trying to figure out why clojure.contrib.seq-utils/flatten wouldn't work on my data type, I discovered the Java interface clojure.lang.Sequential and the associated test function clojure.core/ sequential?. However, the interface contains no methods. It is used in the Clojure source code o

Re: interesting puzzle

2010-01-29 Thread Sean Devlin
Using seq-utils... 1. Assume " " is NOT empty 2. Use partition-by to split 3. Use remove to clean up 4. Map! user=>(map (partial apply str) (remove (comp empty? first) (partition-by empty? ["a" "" "b" "c"]))) ("a" "bc") I think this satisfies you conditions. Sean On Jan 29, 10:25 am,

interesting puzzle

2010-01-29 Thread Wilson MacGyver
I saw this on twitter. http://pastie.org/796264 The problem: given a list of strings, produce a list where sequential non-empty strings are concatenated # Conditions: Do not use iteration. # # Example: glom (["a", "b", "c"]) = ["abc"] # glom (["a", "", "b"]) = ["a", "b"] # glom

Re: update-in and get-in why no default?

2010-01-29 Thread Rich Hickey
On Jan 29, 9:04 am, Sean Devlin wrote: > Rich, > Your example didn't support a variadic signature.  Is that the long > term plan? > It's the short term plan. Let's see if there's any real need for more than three. I've never needed more than one. Rich -- You received this message because you

Re: (list* ())

2010-01-29 Thread Rich Hickey
On Fri, Jan 22, 2010 at 4:55 PM, ataggart wrote: > > > On Jan 22, 1:30 pm, samppi wrote: >> This is not a big deal: it is a quibble with a weird and inconvenient >> behavior of list*: when given an empty sequence, it returns nil >> instead of the empty list. Why is this? According to list*'s >> d

Re: Proposal: New fn assoc-in-with

2010-01-29 Thread Chouser
On Fri, Jan 29, 2010 at 8:44 AM, Rich Hickey wrote: > On Fri, Jan 22, 2010 at 8:57 AM, Chouser wrote: >> On Thu, Jan 21, 2010 at 10:11 PM, Sean Devlin >> wrote: >>> Sometimes you don't want assoc-in to create a hash-map.  Sometimes you >>> wish it could create a sorted map. >>> >>> Just finishe

Re: update-in and get-in why no default?

2010-01-29 Thread Sean Devlin
Rich, Your example didn't support a variadic signature. Is that the long term plan? Sean On Jan 29, 8:48 am, Rich Hickey wrote: > On Dec 30 2009, 6:18 am, Timothy Pratley > wrote: > > > On Dec 13, 1:24 am, Rich Hickey wrote: > > > > fnil seems to me to have greater utility than patching all f

Re: Types in deftype vs. gen-class

2010-01-29 Thread Rich Hickey
On Fri, Jan 22, 2010 at 4:19 PM, Andreas Wenger wrote: > Hi, > > I read that deftype is often a better replacement for gen-class and > defstruct. Indeed, it would fit for my purposes very well, except the > following problem: deftype does not (yet?) use all the information > from type hints. > > S

Re: update-in and get-in why no default?

2010-01-29 Thread Rich Hickey
On Dec 30 2009, 6:18 am, Timothy Pratley wrote: > On Dec 13, 1:24 am, Rich Hickey wrote: > > > fnil seems to me to have greater utility than patching all functions > > that apply functions with default-supplying arguments. > > Neat :) I like it. > > > The get-in function could be enhanced, and

Re: more constructors (to support default values) for deftype?

2010-01-29 Thread Rich Hickey
On Fri, Jan 22, 2010 at 5:41 PM, Raoul Duke wrote: > hi, > > if i have (deftype map-db [next-id id-to-item-map]) i have to then do > (map-db 0 {}) any time i want to make a new one. it would be nice to > be able to add a function in my deftype so i could use (map-db) to get > the same effect. > >

Re: "recursive" deftype?

2010-01-29 Thread Rich Hickey
On Fri, Jan 22, 2010 at 6:58 PM, Raoul Duke wrote: >> So you just need to instead use (new Trec (+ 1 v)). > > thanks! that does work for me, too. > > (i'm hoping Clojure will be able to avoid having to do it that way in > the long run.) > That's as designed, and documented. Rich -- You receive

Re: Proposal: New fn assoc-in-with

2010-01-29 Thread Sean Devlin
The following doesn't currently work: user=> (assoc [] 1 :a) # So I say this should be map only. Granted, assoc-in already has this issue. Also, what do you mean by your question "Where would the default go"? I don't understand what you're getting at yet. Sean On Jan 29, 8:44 am, Rich Hickey

Re: idiom question: infinite sequence as data source for many threads?

2010-01-29 Thread cburroughs
java.util.concurrent.LinkedBlockingQueue Check out the put() method. That what I used for a program similar to the original poster when I needed control over the number of threads. On Jan 28, 7:15 pm, Paul Mooser wrote: > This is something I run into with executors in Java periodically - I > h

Re: Proposal: New fn assoc-in-with

2010-01-29 Thread Rich Hickey
On Fri, Jan 22, 2010 at 8:57 AM, Chouser wrote: > On Thu, Jan 21, 2010 at 10:11 PM, Sean Devlin > wrote: >> Sometimes you don't want assoc-in to create a hash-map.  Sometimes you >> wish it could create a sorted map. >> >> Just finished working on something with Alexy Khrabrov & Chouser on >> IR

Re: return value of use, requires?

2010-01-29 Thread Rich Hickey
On Thu, Jan 21, 2010 at 2:51 AM, Raoul Duke wrote: > hi, > > in the repl when i (use 'foo) vs. (use :foo) they both return nil, so > it doesn't help me know that the former is right and the latter isn't. > i think. would it be sensible for use to return true or something more > positive than nil i

Re: Using docs effectively (Ratio)

2010-01-29 Thread Rich Hickey
On Thu, Jan 21, 2010 at 7:57 AM, Jacek Generowicz wrote: > Clojure has a Ratio type; presumably there should be an easy way to > find the numerator and denominator of a Ratio object. > > I didn't have much luck on clojure.org or with find-doc, but > >    (show 1/2) > > taught me that there are num

Exception handling functional style

2010-01-29 Thread Lukas Lehner
Hi all I am trying to figure out some systematic and clear way how to handle exceptions in clojure and their bubbling up through the call chain. Let me illustrate it on some code examples (not executable, just to show the principle). (defn get-from-io [p] (access-external-source p)) (de

Re: more lazy "fun"

2010-01-29 Thread DanL
Hello! On 29 Jan., 11:24, Meikel Brandmeyer wrote: > http://groups.google.com/group/clojure/msg/f2585c149cd0465d Rich has valid points but still, bad performance characteristics might be something that I, the user, should take responsibility for. I'm not sure if such considerations should preven

Fwd: Berlin Lispers Meetup: February 2, 2010 - Clojure presentation

2010-01-29 Thread Tim Lossen
FYI: if anybody happens to be in berlin next week -- there is going to be an interesting presentation about clojure "in the cloud" ... tim Begin forwarded message: > From: Hans Hübner > Date: 2010-01-29 11:53:25 > To: lisp-ber...@googlegroups.com, lisp-ber...@lists.bknr.net, > lisp...@common-

Re: more lazy "fun"

2010-01-29 Thread Meikel Brandmeyer
Hi, On Jan 29, 10:52 am, DanL wrote: > > (if (some #{"foo"} ["foo" "bar"]) "yay" "humbug") > > In my opinion, there really should be something like CL's FIND or > MEMBER in core (maybe both, since MEMBER is restartable but FIND > immediately returns the found element). I think using a set to ach

Re: Standard Practice for a Canned Lexer, Parser, Analyzer?

2010-01-29 Thread Roberto Mannai
I mean, the whole article: http://martinfowler.com/articles/codeGenDsl.html > http://martinfowler.com/articles/codeGenDsl.html#UsingTemplatesForGeneration. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@g

Re: Standard Practice for a Canned Lexer, Parser, Analyzer?

2010-01-29 Thread Roberto Mannai
Hello Liam I'm neither an expert on this subject. :) Nevertheless I'll give you my position. Defining a new language, formally speaking, is very hard: you have to define new symbols and rules. On many languages the same token can be used in different contexts (think of "{" on Java: if blocks, meth

Re: more lazy "fun"

2010-01-29 Thread DanL
Hello! On 29 Jan., 03:49, Sean Devlin wrote: > I'd do one thing differently than Tim.  (partial = something) is a > clojure smell.  It's more idiomatic to use a set > > (if (some #{"foo"} ["foo" "bar"]) "yay" "humbug") In my opinion, there really should be something like CL's FIND or MEMBER in c

Re: Standard Practice for a Canned Lexer, Parser, Analyzer?

2010-01-29 Thread Liam
Hello Laurent, Thank you very much for your answers and maintaining CCW. I was partially encouraged to use Eclipse (a while back) due to the existence of CCW (or clojure-dev as it was then). I wrote: […] sophisticated syntax based evaluation or inferences from “cold code” [...] not node. This is

Re: Question: Clojure & concurrency in large-scale problems.

2010-01-29 Thread Konrad Hinsen
On 29 Jan 2010, at 08:37, Mike Meyer wrote: Which brings me to my question: how does clojure deal with concurrency at the inter-process level? At the inter-system level? Are their distributed versions of refs & atoms and the like available somewhere? No. Or perhaps the answer should be "not ye

Re: Standard Practice for a Canned Lexer, Parser, Analyzer?

2010-01-29 Thread Laurent PETIT
Hello, 2010/1/29 Liam : > Could someone educate me about what developers normally do when faced > with having to create a lexer / parser / analyzer, say for clojure? > > Why would people go with a canned solution, i.e. ready-made like soup > out of a can, instead of by hand? > > E.g. why did the C