Help with zetta-parser please

2012-12-09 Thread timc
Hi Can someone give example of parsing using zetta-parser for the case that the input stream is intermittent (i.e. possibly incomplete at a particular moment). The author of zetta-parser refers to this very possibility in his readme (for example parsing messages arriving at a socket or such).

How to emulate Java sub-classing using closure with a macro?

2012-11-18 Thread timc
Hello - I would appreciate some advice on how to implement something equivalent to sub-classing. The context for this is a finite state machine (FSM), by which I mean a thread that waits on a queue of events, then deals with each event (one at a time) according to the state it is in, possibly

Re: Macros to help writing closures?

2012-04-22 Thread timc
Thanks Cedric - that's very nice. I'm beginning to understand the power of macros. I have to say they are not very well explained in the clojure docs. In particular, how many distinct 'macro operators' are there, and what are their precise definitions? For instance, is ~' a single operator, or

Re: Macros to help writing closures?

2012-04-22 Thread timc
I often write functions like this: (defn foobar [] (let [log (makeLogger foobar)] blah blah )) where makeLogger returns a logging function that prefixes all messages with the name provided. It looks as though macros don't have a stringize ability (like the C preprocessor) so that

Macros to help writing closures?

2012-04-21 Thread timc
Hello I am a beginner when it comes to writing macros, so there may be an easy way to do this. I have a number of 'state machines' which have this sort of appearance: (defn startFSM [eventQ] (let [state (atom :1) going (atom true) timerId (atom -1) startTimer (fn []

Help: how to construct lazy sequences

2011-05-19 Thread timc
Hello I wonder if I could ask for advice on how to construct a lazy sequence. My application might be of interest to some of you. The context for this is that I have an embedded system with very limited facilities for proper debugging. I have inserted a 'trace' facility in the embedded code

Re: Help: how to construct lazy sequences

2011-05-19 Thread timc
That was very helpful - thanks Meikel and Jonathon. -- 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 first post.

Re: Handling of unsigned bytes

2011-02-12 Thread timc
believe these are frequently used for Java I/O, and can be used for   Clojure I/O as well. Andy On Feb 11, 2011, at 9:22 AM, timc wrote: How on earth is one supposed to do communication programming (not to mention handling binary files etc) without an unsigned byte type? I see that this issue

Re: Handling of unsigned bytes

2011-02-12 Thread timc
). So - what I'm pleading for, is that (byte b) and (int i), (short s), etc. should simply perform a masking operation (on the appropriate number of least significant bits) in the way that java clearly does. On Feb 12, 1:08 pm, timc timgcl...@gmail.com wrote: Sorry I did not make myself clear - I

Re: Handling of unsigned bytes

2011-02-12 Thread timc
: On Sat, Feb 12, 2011 at 4:54 PM, Aaron Cohen aa...@assonance.org wrote: On Sat, Feb 12, 2011 at 4:42 PM, Ken Wesson kwess...@gmail.com wrote: On Sat, Feb 12, 2011 at 8:28 AM, timc timgcl...@gmail.com wrote: (def b (byte i)) is doing something equivalent to this internally: byte b

Handling of unsigned bytes

2011-02-11 Thread timc
How on earth is one supposed to do communication programming (not to mention handling binary files etc) without an unsigned byte type? I see that this issue has been talked about vaguely - is there a solution? Thanks -- You received this message because you are subscribed to the Google Groups

Compile works with 1.1, fails with 1.2.0-RC3

2010-08-19 Thread timc
I'm trying to compile a program, with source files as follows. com/minibar/PmsSimulator.clj -- containing these lines: (ns com.minibar.PmsSimulator (:require [com.minibar :as mb] ...etc) (:load pmssim/util ...etc) (:gen-class)) ...etc where the file com/minibar/pmssim/util.clj contains

What is EvalReader?

2010-02-19 Thread timc
The API documentation refers to EvalReader: Quote *read-eval* - var - When set to logical false, the EvalReader (#=(...)) is disabled in the read/load in the thread-local binding. Unquote Is #= an undocumented reader macro character? And what is the EvalReader anyway? It doesn't appeared to be

Hints on how to 'nest' lazy sequences

2010-01-28 Thread timc
Can anyone please advise on how to structure a sort of 'nested lazy sequence' in this sense: Given a collection (say*command-line-args*) of file names, how to make a lazy function that in effect does what clojure.contrib.duck-streams/ read-lines does, but of all the files in sequence. Thanks --

Re: Hints on how to 'nest' lazy sequences

2010-01-28 Thread timc
Thanks Michal -- however, (multi-read-lines *command-line-args*) produces this exception: java.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 0 args, got: 1 On Jan 28, 12:54 pm, Michał Marczyk michal.marc...@gmail.com wrote: On 28 January 2010 13:41, timc timgcl

Re: Hints on how to 'nest' lazy sequences

2010-01-28 Thread timc
Michal The last, elegant one works -- marvellous! Thanks a lot. Tim On Jan 28, 1:05 pm, Michał Marczyk michal.marc...@gmail.com wrote: Ouch, sorry, this won't work with recur... Use an explicit call instead: (defn multi-read-lines [sources]   (when-let [source (first sources)]    (lazy-cat

How to make lazy seq from socket input?

2009-10-30 Thread timc
Can someone suggest how to make the packets received on a socket into a lazy sequence? The application I'm making is a log file parser. A (Java) program is producing log output using log4j, the output can go to file(s) or be sent to a socket. So, the program has this outline: (defn fileLines

Re: How to make lazy seq from socket input?

2009-10-30 Thread timc
Thanks for the help. On Oct 30, 1:23 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, if you have a stream, you can basically do: (defn stream-seq   [stream]   (take-while #(= 0 %) (repeatedly #(.read stream This will give a character at a time. From there you can build the lines and

Syntax for proxy methods?

2009-10-01 Thread timc
Can someone please advise me if this is possible: // --- IX.java --- interface IX { void doit(); void doit(int n); } ; --- x.clj --- (def prx (proxy [IX][] (doit ([] (doseq [x someSeq] (doit x)) ([y] (print y When I tried something of this form, it looks like the call of

Re: Syntax for proxy methods?

2009-10-01 Thread timc
No, its a proxy for an interface. On Oct 1, 7:22 pm, Jarkko Oranen chous...@gmail.com wrote: On Oct 1, 9:18 pm, timc timgcl...@gmail.com wrote: snip (def prx (proxy [IX][]   (doit     ([] (doseq [x someSeq] (doit x))     ([y] (print y When I tried something of this form

Re: Syntax for proxy methods?

2009-10-01 Thread timc
Oops, I spoke too hastily -- thank you Jarkko. On Oct 1, 8:38 pm, timc timgcl...@gmail.com wrote: No, its a proxy for an interface. On Oct 1, 7:22 pm, Jarkko Oranen chous...@gmail.com wrote: On Oct 1, 9:18 pm, timc timgcl...@gmail.com wrote: snip (def prx (proxy [IX][]   (doit

How to call function (or Java method) using string name?

2009-04-26 Thread timc
Is there a way of invoking functions, or java methods by name in Clojure? Or, put another way, why does this work: (+ 1 2) but this does not: ((symbol +) 1 2) Similarly, this works (. javaObj (methodName param)) but this does not: (. javaObj ((symbol methodName) param)) I suppose this

Re: How to call function (or Java method) using string name?

2009-04-26 Thread timc
/reflect/index.html -Stuart Sierra On Apr 26, 10:46 am, timc timgcl...@gmail.com wrote: Is there a way of invoking functions, or java methods by name in Clojure? Or, put another way, why does this work: (+ 1 2) but this does not: ((symbol +) 1 2) Similarly, this works (. javaObj

Re: Problem with SwingWorker and proxy-super

2009-03-23 Thread timc
))                         (. cb (setSelected true) ie: don't use the publish/process part but instead put updates on the Event Thread explicitly. On Mar 20, 5:56 am, timc timgcl...@gmail.com wrote: I am trying to understand how to use SwingWorker to do time-consuming work that needs to update a Swing GUI

Problem with SwingWorker and proxy-super

2009-03-19 Thread timc
I am trying to understand how to use SwingWorker to do time-consuming work that needs to update a Swing GUI. The following makes a frame with a button (which starts a SwingWorker on the first click). Thereafter, clicking the button increments an integer n that is displayed in the first

Re: Problem with SwingWorker and proxy-super

2009-03-19 Thread timc
It would be a great pity if there was no way to do this, as SwingWorker is the 'proper' way for long-running code to interact with Swing objects. Any ideas for how to achieve this would be appreciated. On Mar 19, 7:35 pm, MikeM michael.messini...@invista.com wrote: However the code

Confused about vars, symbols, names,...

2009-03-06 Thread timc
I would like to have a function which tells me about the values of a var, where the parameter to the function is a string equal to the 'name' of the var. For example: (defn checkNil [name] If the var with the given (String) name is nil, display a message; result = value of var. (when

Clojure-contrib build fails

2009-03-04 Thread timc
After checking out the trunk of clojure-contrib (revision 565) and doing ant jar, I get this: compile_clojure: [java] Compiling clojure.contrib.accumulators to C: \eclipseWS1\clojure-cont rib\classes [java] java.lang.IllegalArgumentException: fn params must be Symbols (accum

Please explain

2009-02-27 Thread timc
On the page describing Vars, I cannot get the meaning of this sentence (a typo has made it incomprehensible I think): Bindings created with binding can be assigned to, which provides a means for nested contexts to communicate with code before it the call stack. Thanks

Please take mercy on us newbies

2009-02-27 Thread timc
Can I make a small plea for people who submit source code to PLEASE insert some sort of explanation of what the code is about. I know it's usual in programming circles to think that if someone can't understand something it's because they are dumb - but really - this is a terribly inefficient way

Re: Please take mercy on us newbies

2009-02-27 Thread timc
, -- Laurent 2009/2/27 timc timgcl...@gmail.com Can I make a small plea for people who submit source code to PLEASE insert some sort of explanation of what the code is about. I know it's usual in programming circles to think that if someone can't understand something it's because

Re: Please take mercy on us newbies

2009-02-27 Thread timc
Thanks for the responses - very helpful. On Feb 27, 3:24 pm, Chouser chou...@gmail.com wrote: On Fri, Feb 27, 2009 at 10:14 AM, James Reeves weavejes...@googlemail.com wrote: Just to expand on Meikel's answer: when people upload files, it's usually as an attachment to an existing thread.

Re: Example of use of Atom: Fibonacci generator

2009-02-16 Thread timc
Thanks for these interesting replies - I have some way to go in my understanding of the power of functional programming. I look forward to seeing Stuart's chapter 5! On Feb 16, 11:25 am, Timothy Pratley timothyprat...@gmail.com wrote: Also consider

How to build tree with nodes that 'point' to each other?

2009-02-12 Thread timc
I'm new to Clojure so this may be a stupid question. I want to make a tree out of these things: (defstruct treeNode :parent :children :data) so that every node knows which node is its parent and which nodes are its children. But, given that these things are immutable, I am baffled as to how

Ways of making a Clojure program?

2009-01-29 Thread timc
I'm struggling to understand exactly what form(s) a Clojure program can take. In particular, the empty section The REPL and main entry points on the clojure.org web site doesn't help. Obviously, interacting manually with the REPL is nice for learning the language, but this becomes tedious as the