Re: ANN: Gloss, a byte-format DSL
This looks a *lot* like something I did a long time ago (Data File Disassembler) when I spent a lot of time reverse-engineering things. I had a view/edit layer on top (On Mac, back when a Mac II was extreme hardware :) and man, was it useful... had pluggable modules for microcontroller disassembly, a few common file formats I needed, etc. Just need to get my Lisp fu back, and I can go back to being productive again. Dave On Tue, Nov 23, 2010 at 12:03 PM, Zach Tellman ztell...@gmail.com wrote: When writing Calx [1], I discovered it was a huge pain to deal with mixed C datatypes in Java. When writing Aleph [2], I discovered the problem increases by a factor of ten when dealing with streams of bytes. In an attempt to alleviate my own pain, and hopefully help a few other people out, I've written Gloss, which can transform a simple byte-format specification into an encoder and streaming decoder. A full writeup can be found at https://github.com/ztellman/gloss/wiki. A few people have already asked me how this differs from protocol buffers, so I'll preemptively answer that protocol buffers are a fixed format that cannot be used to interface with external systems. Gloss is less performant than protocol buffers, but is also much less picky about formats. If anyone has any questions, I'd be happy to answer them. Zach [1] https://github.com/ztellman/calx [2] https://github.com/ztellman/aleph -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: logging recommendation
On Tue, Nov 23, 2010 at 5:46 PM, Stuart Sierra the.stuart.sie...@gmail.comwrote: On Nov 20, 5:56 pm, HiHeelHottie hiheelhot...@gmail.com wrote: What do you recommend for logging, especially to a set of rolling files? Simply use log4j? I manage with Log4j. The .properties configuration file is annoying sometimes, but it works. I've only had issues with Log4J enterprisily. Everywhere else, it's always worked great for me. Dave -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Parameterized SQL queries?
On Wed, Nov 10, 2010 at 12:35 PM, Daniel Bell wrote: I was curious as to exactly it means to parameterize a query. Is it a way to automatically insert arguments into the query, a way to destructure the results, or what? The first of those, including SQL-quoting etc. Most JDBC tutorials will have information regarding this. Dave -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: compiling a protocol with types
I thought there was some minor magic to get types in there though, wasn't that one of the interesting things Rich pointed out at a recent NYC Clojure meetup (Sept, maybe)? Dave On Nov 5, 2010 10:59 AM, Kevin Downey redc...@gmail.com wrote: for defining an interface you should use definterface On Fri, Nov 5, 2010 at 4:18 AM, Jeff Rose ros...@gmail.com wrote: Hi, I'm trying to define an interface for our automated import system written in Clojure so that we can use parsers implemented in Java. So far everything works great, but I'm wondering if there is any way to get types into the method signatures in the interface. For starters I created a simple protocol: (ns importer.parser) (defprotocol Parser (parse ^java.util.Iterator [this ^java.lang.String path])) compiled it from the repl: (compile 'importer.parser) and then when I decompile it using jd-gui I get this: package importer.parser; public abstract interface Parser { public abstract Object parse(Object paramObject); } It would be nice to have a tool that could inspect a Clojure namespace and then generate Javadoc for the protocols and types. Does something like this already exist? If that javadoc could specify the types, even if under the hood it's using Object, that would also be fine. Is there a way to access this type hint information though? I don't see it in the importer.Parser map. Thanks, Jeff -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Reloading java classes
JRebel is still the best answer. Loading a class at runtime is non- trivial. I don't know how it deals with handling existing instances of the class, though; I still think CLOS got that right. Dave On Nov 4, 2010 10:03 PM, Seth wbu...@gmail.com wrote: All i need to do is a function to reload a class I specify, nothing fancy. Surely there is some way? -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Getting Started with Gen-Class
--- On Mon, 12/15/08, CuppoJava wrote: And i get the message Unable to resolve symbol: compile in this context when i type (compile) at the REPL. How are you running the REPL? It's working for me whether I build with Ant or Maven, rev 1160. Dave --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Java interop question
--- On Sun, 12/14/08, David wrote: work (.getName java.lang.Integer) ; Evaluation aborted. Why does the second expression fail? Would that work in Java? Dave --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Java interop question
Sneaky, but I bet I'll get confused by the extra functionality at some point. --- On Sun, 12/14/08, Rich Hickey richhic...@gmail.com wrote: There used to be a long answer as to why: http://groups.google.com/group/clojure/msg/8fc6f0e9a5800e4b Now there is a short one - it does work! --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: iteration idioms
--- On Sat, 12/13/08, Stephen Parker wrote: On 12 Dec 2008, at 23:10, Mark Fredrickson wrote: [...] insert 3 before every item less than or equal to 5 in a seq: (def bar [24 6 5 5 7 5 8 2]) (insert-before-if #(= 5 %) 3 bar) = (3 24 3 6 3 5 3 5 3 7 3 5 3 8 2) Er... Dave --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Lisp/Clojure doesn't have syntax?
--- On Thu, 12/11/08, Paul Barry wrote: syntactic sugar is not syntax? I think that depends on which particular nits are being picked. Is it strictly true that Clojure has no syntax? Meh--probably not. (defun foo [bar] ...) has more unique characters than (defun foo (bar) ...) or (define (foo bar) ...) but is it a *meaningful* difference? Is '(foo) meaningfully different than (quote (foo))? Again, more unique characters... but is it in the language, or is it in the reader? They're called reader macros for a reason. All in all, not something I'll be terribly concerned with either way. Dave --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: A newbie question on Agents and ants
--- On Sun, 12/7/08, Michael Wood wrote: Is there an explanation that's a little smaller than 607MB? The slides and the code? Dave --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: neo4j-clojure
--- On Sat, 12/6/08, Julian Morrison wrote: A wrapper for neo4j, which is a non-relational database using [...] traversable relationships. Hey, wait... Dave --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running clojure-contrib.jar
--- On Sat, 12/6/08, janus wrote: It is my mistake, this is the error once again. Failed to load Main-Class manifest attribute from C:\clojure\clojure\clojure-contrib.jar. I did what Shulz said, however, I still have the same problem. Can you post the *exact* classpath and/or files and/or commands you're using? Like get the classpath via: echo %CLASSPATH% I'm reasonably sure it shouldn't be trying to load a Main-Class from the contrib jar, so I suspect the classpath is not being set properly. Dave --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: DISCUSS: replace (rand)
--- On Tue, 12/2/08, Paul Barry wrote: Since this is just pure java, shouldn't it be the same on all 1.5 JVMs? Would it be different on other JVM implementations? Just to verify, I checked on my Mac OS X 10.5 and in the Sun JDK 1.5 on Windows XP, and it does appear to be the same. A Sun v. Sun comparison? What about JDK/JVM implementations from different vendors? Dave --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure for LISP programmers....
--- On Mon, 11/17/08, Rich Hickey wrote: I've presented Clojure to many of the people who wrote CL and Scheme, and no one can deny it is a Lisp. I'd also add that at Lisp50 Clojure was very well received by many Lisperati, and many, if not most, of the folks there were *way* into Scheme and Lisp (although most also share a certain... hesitation when it comes to CL ;) with several I'd even classify as gushing-in-the-reserved-Lisp-fashion. On an un-related note, at one point gls sat down next to me in the back of the room. I texted to a friend of mine omg guy steele just sat down next to me and my friend (he's young) texted back cool ask him who guy steele is. Dave --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Clojure for LISP programmers....
I'll add that: (cond (foo bar) (baz plugh)) = (cond (foo) (bar) (baz) (plugh)) This particular CL difference is listed on the wiki page you listed: http://en.wikibooks.org/wiki/Clojure_Programming#Clojure_for_Common_Lisp_Programmers I also didn't have anywhere near these kinds of problems getting things to work, although I've been doing a lot of Java lately, and more Scheme than CL, so that may have helped. I'm sure other folks would also be interested in your contributions towards a CL = Clojure document; sounds like a good opportunity. Dave --- On Sun, 11/16/08, Brian W [EMAIL PROTECTED] wrote: I'm going to assume this is serious and not a joke, but you do realize Clojure is already quite well documented at clojure.org? #t t = true define defun =defn car, cdr, caar, etc. ~ first, rest, ffirst, rrest, frest, rfirst arglists are vectors because [ ] stand out better On Nov 16, 2:31 pm, Simon Brooke [EMAIL PROTECTED] wrote: Has anyone written a very simple introduction to Clojure for LISP hackers? I've spend an evening playing with it pretty intensively, and thus far I haven't got a thing to work. I've readhttp://en.wikibooks.org/wiki/Clojure_Programming#Clojure_for_Common_L..., but it hasn't helped me. In LISP: * (defun fact (n) (cond ((= 1 n) 1)(t (* n (fact (- n 1)) FACT * (fact 10) 3628800 that is Common LISP, but what the hell; in Portable Standard LISP it would have been identical except 'de' instead of 'defun'; in Scheme it's a little different: (define (fact n) (cond ((= n 1) 1)(#t (* n (fact (- n 1)) (fact 10) 3628800 But the family resemblance is there... So, let's try it in Clojure: user= (defun fact (n) (cond ((= n 1) 1) (t (* n (fact (- n 1)) java.lang.Exception: Unable to resolve symbol: defun in this context user= (de fact (n) ( cond ((= n 1) 1) (t (* n (fact (- n 1)) java.lang.Exception: Unable to resolve symbol: de in this context user= (def fact (n) ( cond ((= n 1) 1) (t (* n (fact (- n 1)) java.lang.Exception: Too many arguments to def user= (defn fact [n] (cond ((= n 1) 1)(t (* n (fact (- n 1)) java.lang.Exception: Unable to resolve symbol: t in this context user= (defn fact [n](cond ((= n 1) 1)(#t (* n (fact (- n 1)) java.lang.Exception: No dispatch macro for: t user= (defn fact [n](cond ((= n 1) 1)(#true (* n (fact (- n 1)) java.lang.Exception: No dispatch macro for: t user= (defn fact [n] (cond ((= n 1) 1)(true (* n (fact (- n 1)) #'user/fact OK, what's with the funny square brackets? A sequence of forms enclosed in square brackets is a vector, not a list. Why is the arglist for a function a vector? For now let's accept that it is, and pass on. user= (fact 10) java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn OK, so that doesn't work. As Zaphod memorably put it, 'hey, what is truth, man?' Good question: user= (true? 'true) true user= (true? true) true user= (true? t) java.lang.Exception: Unable to resolve symbol: t in this context user= (true? 't) false user= (def t 'true) #'user/t user= (true? t) true OK, now we know the truth, surely we can write a valid fact? user= (defn fact [n] (cond ((= n 1) 1)('true (* n (fact (- n 1)) #'user/fact user= (fact 10) java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn user= (defn fact [n] (cond ((= n 1) 1)((true? 'true) (* n (fact (- n 1)) #'user/fact user= (fact 10) java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn OK, it looks like whatever's causing the break isn't the guard on the second cond branch. Let's for a moment try something that's purely boolean: user= (defn band [l] (cond ((nil? l) true)((true? (car l))(band (cdr l) java.lang.Exception: Unable to resolve symbol: cdr in this context No CDR? It's LISP, but it can't fetch the contents of the decrement register? fifty years of LISP history tossed into the dirt. So if the CDR isn't called the CDR, what is it called (and what's the CDADR called)? user= (defn band [l] (cond ((nil? l) true)((true? (first l))(band (rest l) #'user/band user= (band '(true true true)) java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn OK, can we write any function at all that works? user= (defn square [n] (* n n)) #'user/square user= (square 4) 16 Fine, so recurse up from that: user= (defn power [n m] (cond ((= m 0) 1)(true (* n (power n (- m 1)) #'user/power user= (power 2 2) java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn Aggghhh... Getting LISP to work seamlessly inside a Java environment with easy intercalling between LISP and Java is a very big win, and potentially
Re: Testing Clojure (was Re: Bug? Strange set equality (r1075))
--- On Thu, 11/13/08, Frantisek Sodomka wrote: [...] becomes: (deftest t-Symbols (check (:equal 'abc (symbol abc) '*+!-_? (symbol *+!-_?) 'abc:def:ghi (symbol abc:def:ghi) 'abc/def (symbol abc def) 'abc.def/ghi (symbol abc.def ghi) 'abc/def.ghi (symbol abc def.ghi) 'abc:def/ghi:jkl.mno (symbol abc:def ghi:jkl.mno) ) (instance? clojure.lang.Symbol 'alphabet))) which is in my opinion much more readable. Any comments to this syntactic enhancement? My first impression when I read that is that it's expecting each arg to be equal to each other, not the reality of being a list of (expected to be) equal pairs. That's probably just me, I'm sure, but I find the original more readable and precise--something I think is key in tests, as tests are also documentation. Dave --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: REPL special variables
--- On Wed, 11/12/08, Mark Volkmann wrote: I don't seem to be able to access the special variables *1, *2, *3 and *e in the REPL. For example, user= (/ 1 0) user= (.printStackTrace *e) outputs java.lang.Exception: Unable to resolve symbol: *e in this context In which environment/build? It's working fine for me. Dave --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: (string?) bug
--- On Sun, 11/9/08, Brian Doyle wrote: Yes, it is a StringBuilder so technically yes. I guess you since the only thing you ever do with a StringBuilder is produce a string it just seemed like it would be a string. Same goes for StringBuffer. I'd say create your own (stringish? ...) function then--since Clojure is strongly Java-interop returning a T for a non-String would make (string? ...) seem less useful, but that's just my opinion. Dave --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: (string?) bug
--- On Sun, 11/9/08, Brian Doyle wrote: This seems like a bug returning false for StringBuilder. user= (string? (new java.lang.String hello)) true user= (string? (new java.lang.StringBuilder hello)) false Wouldn't it be a StringBuilder, and not a String? user= (. (new java.lang.StringBuilder hello) getClass) #=java.lang.StringBuilder user= (string? (. (new java.lang.StringBuilder hello) toString)) true Dave --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---