Re: Lisp/Scheme Style Guide

2010-08-31 Thread Sean Corfield
On Tue, Aug 31, 2010 at 1:52 PM, Greg wrote: > Can we please drop this? No offense Greg, but yes, please, drop this. By replying, all you've done is perpetuate this :( It's clear you don't agree (with lots of other people's opinions) and we get that. Style is personal - do what makes you happy.

Re: reflection warnings with defprotocol/deftype with type hints

2010-08-31 Thread Meikel Brandmeyer
Hi, On 1 Sep., 07:33, Adrian Cuthbertson wrote: > There are probably ways of creating types on protocols, but I haven't > tried that yet. Clojure is a dynamically typed language. I don't think that putting types on protocols is very interesting. Type hints should be a low- level construct put i

Re: Minor macroexpand issue

2010-08-31 Thread Konrad Hinsen
On 1 Sep 2010, at 00:17, Frederic Koehler wrote: If you were to say, (macroexpand '(foo)), it returns (foo), even if it's not defined in the context, so I'd say it's a little unexpected. True, but then, the function macroexpand is mostly a development tool, for which I can accept such mino

Re: reflection warnings with defprotocol/deftype with type hints

2010-08-31 Thread Adrian Cuthbertson
Hi Albert, I made sense of this by keeping the concept of defprotocol separate from definterface and deftype. defprotocol is like multimethods and deftype is like creating an implementation of an interface. You then need to instantiate a new instance of the deftype to execute its methods. The foll

Re: picking out a tag from a nested struct-map and xml-seq

2010-08-31 Thread Abhishek Reddy
Hi Peter, The library clojure.contrib.zip-filter is pretty good at this sort of thing. For example: (require '[clojure.xml :as xml]) (require '[clojure.contrib.zip-filter.xml :as zx]) (require '[clojure.zip :as zip]) (defn get-mods-for-iva "Returns the node if one exists under a node whos

Re: Lisp/Scheme Style Guide

2010-08-31 Thread Fogus
> It would be a tragedy if The State ordered Picasso to make his paintings more > realistic I think your confusing the virtue in shuffling parentheses around. If you want to place your parentheses on their own line then more power to you, it's your style -- but don't confuse it with making high

Ed Lambda: Functional programming meetup in Edinburgh

2010-08-31 Thread Ollie Saunders
Hi guys, I'm running a meetup for functional programming in Edinburgh. The first one will be on the 13th of September at Malone's Irish Bar (14 Forrest Road) and will continue every 2nd monday of each month. For the first meetup I think we'll just be having a chat and getting to know each other bu

Re: Lisp/Scheme Style Guide

2010-08-31 Thread Greg
On Aug 31, 2010, at 5:26 PM, Mike Meyer wrote: > Um, read the explanation: he's talking about productivity and code > quality. He didn't say people didn't care about styles, or weren't > passionate about styles. Which means you haven't addressed his issues, > just your straw man. There is no stra

Re: Minor macroexpand issue

2010-08-31 Thread Armando Blancas
I agree, that's not the expected behavior. The form is just data, it doesn't have to be valid code. Since '(Object) is not a macro (Object is a Symbol there, not a class) it should just return the form just like (identity) does: user=> (identity '(Object)) (Object) But macroexpand-1 does some extr

Re: Lisp/Scheme Style Guide

2010-08-31 Thread Mike Meyer
On Tue, 31 Aug 2010 15:41:13 -0700 Greg wrote: > On Aug 31, 2010, at 2:35 PM, fin wrote: > > >> The concept of the One-Style-To-Rule-Them-All is just childish. > > > > Have you read "Style is Substance"? > > http://www.artima.com/weblogs/viewpost.jsp?thread=74230 > > No, I hadn't, thanks for t

Re: NullPointerExecption after Java class import

2010-08-31 Thread Stuart Campbell
You could call (import) directly after you've initialised the Gate class: (gate-init "foo") (import gate.Factory) ; use Factory class as required Cheers, Stuart On 31 August 2010 01:01, zm wrote: > > Initialization exception can be avoided if Factory class is > initialized indirectly: > > (let

Re: Lisp/Scheme Style Guide

2010-08-31 Thread Mike Meyer
On Tue, 31 Aug 2010 15:40:10 -0600 "Eric Schulte" wrote: > I apologize for apparently re-opening some fresh wounds. > > I wasn't trying to assert that these guidelines should be universally > adopted or enforced. > > There are a number of conventions that exist for writing lisp, and I > thought

Re: Lisp/Scheme Style Guide

2010-08-31 Thread Greg
On Aug 31, 2010, at 2:35 PM, fin wrote: >> The concept of the One-Style-To-Rule-Them-All is just childish. > > Have you read "Style is Substance"? > http://www.artima.com/weblogs/viewpost.jsp?thread=74230 No, I hadn't, thanks for the link. I tried to read the whole thing but stopped after readi

Re: Lisp/Scheme Style Guide

2010-08-31 Thread Cyrus Harmon
XMLHttpRequest vs. xml-http-request. I rest my case. On Aug 31, 2010, at 3:35 PM, Mark Engelberg wrote: > Speaking of style conventions, am I the only one who finds it mildly > irksome that in any Clojure code, half the identifiers are > lisp-style-multiword-names while the other half are > javaC

Re: Lisp/Scheme Style Guide

2010-08-31 Thread Mark Engelberg
Speaking of style conventions, am I the only one who finds it mildly irksome that in any Clojure code, half the identifiers are lisp-style-multiword-names while the other half are javaCamlCaseMethodNames. It feels so inconsistent. I'd be happier if Clojure just moved completely to caml case (take

Re: Problem with installing and running labrepl in Eclipse

2010-08-31 Thread Laurent PETIT
Well, you seem to describe a problem with the m2eclipse plugin, which may not have recognized the project as a maven project. This is a third party plugin, hard to help with this. Alternatively, could you try the (still experimental) labrepl support ccw offers ? Go to File > New > Examples > Othe

Re: Minor macroexpand issue

2010-08-31 Thread Frederic Koehler
If you were to say, (macroexpand '(foo)), it returns (foo), even if it's not defined in the context, so I'd say it's a little unexpected. More annoying is the result this has on macroexpand-all, which breaks because of this weird behaviour: (use 'clojure.walk) (walk/macroexpand-all '(let [Object

Re: Lisp/Scheme Style Guide

2010-08-31 Thread Eric Schulte
I apologize for apparently re-opening some fresh wounds. I wasn't trying to assert that these guidelines should be universally adopted or enforced. There are a number of conventions that exist for writing lisp, and I thought that this paper was interesting because it - collects and explicitly sta

Keep getting this error "No implementation of method: :arraySet of protocol"

2010-08-31 Thread Jarl Haggerty
The full error is No implementation of method: :arraySet of protocol: #'ndarray.NDArray/ ArrayProtocol found for class: ndarray.NDArray.NDArray (NDArray.clj:0) and the code is this (ns ndarray.NDArray (:import java.lang.Object)) (def ... (reify Object)) (defprotocol ArrayProtocol (fixIndex

Re: Lisp/Scheme Style Guide

2010-08-31 Thread Andrew Gwozdziewycz
On Tue, Aug 31, 2010 at 4:52 PM, Greg wrote: > Can we please drop this? > > This is going to go nowhere fast, like other thread on closing parens on new > lines. > > Whoever wrote this did a terrible job, at least WRT that topic. > > Not only did he misrepresent the trailing parenthesis style (no

Re: Lisp/Scheme Style Guide

2010-08-31 Thread fin
> The concept of the One-Style-To-Rule-Them-All is just childish. Have you read "Style is Substance"? http://www.artima.com/weblogs/viewpost.jsp?thread=74230 -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure

Problem with installing and running labrepl in Eclipse

2010-08-31 Thread Peter Stahl
Hi everyone, I'm a computational linguist coming from Python and want to learn Clojure. So I thought it would be a good idea to start with labrepl. I'm working on Mac OS X 10.6 (Snow Leopard) with the 32bit Cocoa version of Eclipse 3.6 (Helios). I followed the instructions on the labrepl github pa

picking out a tag from a nested struct-map and xml-seq

2010-08-31 Thread Peter
Hi- I'm brand new to Clojure and FP, reading a bunch and working on my first programming task (reading in values from an xml file and a text file and then creating a new text file with some lines/sections of the original text file replaced based on the content of the xml). I found some helpful in

Re: reflection warnings with defprotocol/deftype with type hints

2010-08-31 Thread Alan
I haven't quite figured out type hinting either, but here's one thing I realized I was doing wrong that you might want to try. (.length msg) is a reader macro that expands to (. msg length). The docs for the . special form state that if no arguments are provided for an instance member, it is assum

reflection warnings with defprotocol/deftype with type hints

2010-08-31 Thread Albert Cardona
Hi all, I am puzzled by the type hint support in deftype. I can add type hints to defprotocol: user=> (defprotocol PTest (test-it ^boolean [this ^String msg])) PTest … but adding them to deftype fails: user=> (deftype Test [^String name] PTest (test-it [this msg] (str "test " name ": " m

Re: Lisp/Scheme Style Guide

2010-08-31 Thread Greg
The concept of the One-Style-To-Rule-Them-All is just childish. It is akin to the enforcement of school uniforms, and in many ways perhaps worse. The imposition of aesthetic preferences upon others is likely to result in the following: - A counter-reaction, such as argument, insults, "flame wa

Re: Lisp/Scheme Style Guide

2010-08-31 Thread Greg
Can we please drop this? This is going to go nowhere fast, like other thread on closing parens on new lines. Whoever wrote this did a terrible job, at least WRT that topic. Not only did he misrepresent the trailing parenthesis style (not all parenthesis must be trailed), but the so-called rati

Re: Help speed up an inner loop?

2010-08-31 Thread Nicolas Oury
On Tue, Aug 31, 2010 at 8:43 PM, tsuraan wrote: > >> In this situation, inlining (int 10) does not buy much. > > interesting; for me replacing the 10 with (int 10) brings my times > from 28.7ms to 19.6ms. I meant putting (int 10) instead of nl and a let. Anyway, it seems that we can get to java

Re: Help speed up an inner loop?

2010-08-31 Thread tsuraan
> This one is quite good for me. > (defn countnl >  [#^bytes buf] >  (let [nl (int 10)] >   (areduce buf idx count (int 0) >            (if (== (int (aget buf idx)) nl) >              (unchecked-inc count) >              count > > > It appears that == is not resolved for bytes. So converting to

Re: Help speed up an inner loop?

2010-08-31 Thread Nicolas Oury
This one is quite good for me. (defn countnl [#^bytes buf] (let [nl (int 10)] (areduce buf idx count (int 0) (if (== (int (aget buf idx)) nl) (unchecked-inc count) count It appears that == is not resolved for bytes. So converting to int works fine.

Lisp/Scheme Style Guide

2010-08-31 Thread Eric Schulte
This is the best I've seen so I thought I'd share (pulled from a post on the guile mailing list) http://mumble.net/~campbell/scheme/style.txt (note: the attached copy opens in Org-mode in Emacs for easier reading) -- You received this message because you are subscribed to the Google Groups "Clo

Re: ANN: SQLRat - A Clojure 1.2 library to access Relational Databases using DataTypes

2010-08-31 Thread Shantanu Kumar
SQLRat 0.1 GA is pushed to Clojars. Maven/Lein details here: http://clojars.org/org.bituf/sqlrat The same is also reflected here: http://code.google.com/p/bitumenframework/ # Changes and TODO ## 0.2 / planned - [TODO] Support large sized query result-sets (by adding lazy loading option) - [TODO

Re: Why do is used in this function?

2010-08-31 Thread Chouser
On Tue, Aug 31, 2010 at 11:08 AM, Justin Kramer wrote: > Another tip: per the doc for 'empty?', (seq s) is preferred over (not > (empty? s)). Oh, and 'str' isn't necessary since 'println' adds spaces > between arguments: > > (defn printall [s] >  (when (seq s) >   (println "Item:" (first s)) >   (

Re: Help speed up an inner loop?

2010-08-31 Thread tsuraan
> Replace also  (unchecked-add count 1) with  (unchecked-add count (int 1)) > > (this should get easier in 1.3) That didn't change anything for my tests, but this code: (defn countnl [#^bytes buf] (areduce buf idx count (int 0) (if (= (aget buf idx) 10) (unchecked-add

Re: Help speed up an inner loop?

2010-08-31 Thread Nicolas Oury
Replace also (unchecked-add count 1) with (unchecked-add count (int 1)) (this should get easier in 1.3) On Tue, Aug 31, 2010 at 4:20 PM, tsuraan wrote: >> (defn countnl-lite >>  [#^bytes buf] >>  (areduce buf idx count (int 0) >>           (if (= (clojure.lang.RT/aget buf idx) 10) >>          

Re: Help speed up an inner loop?

2010-08-31 Thread tsuraan
> (defn countnl-lite >  [#^bytes buf] >  (areduce buf idx count (int 0) >           (if (= (clojure.lang.RT/aget buf idx) 10) >             (unchecked-add count 1) >             count))) > > Key points are initializing count to a primitive integer and directly > calling clojure's aget to avoid an u

Re: Question re Mikael Sundberg's Getting started with compojure

2010-08-31 Thread Michał Marczyk
On 31 August 2010 16:52, Jacek Laskowski wrote: > As we're at it, how does people reload functions while connected to a > remote Clojure app from within Emacs? Do they also > (require...:reload)? Is there a tutorial/article about it? One possibility is to open the remote file wherein the function

Re: Extending Clojure's STM with external transactions

2010-08-31 Thread .Bill Smith
> I'd like to see a day when programmers need to worry about persistence > about as much as they worry about garbage collection now. Me too, but of course beware of leaky abstractions. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this g

Re: Why do is used in this function?

2010-08-31 Thread Justin Kramer
Another tip: per the doc for 'empty?', (seq s) is preferred over (not (empty? s)). Oh, and 'str' isn't necessary since 'println' adds spaces between arguments: (defn printall [s] (when (seq s) (println "Item:" (first s)) (recur (rest s Justin On Aug 31, 10:57 am, Nicolas Oury wrote:

Re: Why do is used in this function?

2010-08-31 Thread Nicolas Oury
One solution to remove it is to use when. (when (not (empty? s) (println (str "Item: " (first s))) (recur (rest s As there is only one case for a when, you can give multiple instructions for this case without grouping them Even better: (when-not (empty? s) (println

Re: Question re Mikael Sundberg's Getting started with compojure

2010-08-31 Thread Jacek Laskowski
On Tue, Aug 31, 2010 at 4:44 PM, Mark Rathwell wrote: > > I'm not sure if this is the question you are asking, but to reload a > namespace in a repl, depending on whether you are use-ing the ns or > require-ing it, there are :reload and :reload-all  keyword arguments > accepted: > (require '[foo.s

Re: Question re Mikael Sundberg's Getting started with compojure

2010-08-31 Thread Mark Rathwell
I'm not sure if this is the question you are asking, but to reload a namespace in a repl, depending on whether you are use-ing the ns or require-ing it, there are :reload and :reload-all keyword arguments accepted: (require '[foo.something :as something] :reload) (require '[foo.something :as some

Re: Why do is used in this function?

2010-08-31 Thread Baishampayan Ghose
> Hey, > Having this function: > > (defn printall [s] >   (if (not (empty? s)) >       (do >           (println (str "Item: " (first s))) >           (recur (rest s) > > Why do is used here? what happens if I drop it? > Thanks for help and time. In Clojure and most other Lisps, `if' has the fo

Why do is used in this function?

2010-08-31 Thread HB
Hey, Having this function: (defn printall [s] (if (not (empty? s)) (do (println (str "Item: " (first s))) (recur (rest s) Why do is used here? what happens if I drop it? Thanks for help and time. -- You received this message because you are subscribed to the

Question re Mikael Sundberg's Getting started with compojure

2010-08-31 Thread Jacek Laskowski
Hi, I've been reading Mikael Sundberg's Getting started with compojure [1] and been wondering how to reload a function "display" (without Emacs and swank) so I don't have to restart repl. I'd love to update the function while running lein repl. Is it possible?* How? [1] http://cleancode.se/2010/0

Re: Help speed up an inner loop?

2010-08-31 Thread Nicolas Oury
On Tue, Aug 31, 2010 at 1:53 PM, Nicolas Oury wrote: > I am not convince that (make-array Byte/TYPE *numbytes*) creates an > array of primitives. Actually it does, sorry for the noise. Should check before sending emails. Best, Nicolas. -- You received this message because you are subscribed t

Re: Help speed up an inner loop?

2010-08-31 Thread Nicolas Oury
I am not convince that (make-array Byte/TYPE *numbytes*) creates an array of primitives. And I think byte [] is an array of primitives. That would make a difference. I don't know if clojure has a byte-array. It seems that there is no byte-array as there is int-array. Could you try your code with

Re: Help speed up an inner loop?

2010-08-31 Thread Meikel Brandmeyer
Hi, On 31 Aug., 08:46, Robert McIntyre wrote: > Without AOT compilation countnl-lite takes around 66 msecs > With AOT compilation countnl-lite takes ~46 msecs Did you measure start-up time in your runs? AOT compilation should have no impact on the runtime speed. Sincerely Meikel -- You recei

Re: Help speed up an inner loop?

2010-08-31 Thread John Fingerhut
Consider trying to use "==" in place of where you have "=", which can be faster when comparing numbers for equality. Source for this and a few other performance tips: http://gnuvince.wordpress.com/2009/05/11/clojure-performance-tips/ Andy On Mon, Aug 30, 2010 at 11:46 PM, Robert McIntyre wrote

Re: defrecord issue in unit tests

2010-08-31 Thread garf
--Doh! Thanks, David, that worked On Aug 30, 8:29 am, David Nolen wrote: > On Mon, Aug 30, 2010 at 6:37 AM, garf wrote: > > I am getting the following error when I switched from defstruct to > > defrecord > > **Unable to resolve classname: Rule-record (RecordInitTest.clj:8)** > > I only have thi

Re: Problem reloading source file with imports

2010-08-31 Thread Meikel Brandmeyer
Hi, On 31 Aug., 12:00, Chris Jenkins wrote: > The thing that still confuses me is that I can successfully load a source > file that imports the whole of clojure.contrib.seq once (with warnings) but > an attempt to reload that source file then fails - even if I edit the source > file to remove th

Re: Problem reloading source file with imports

2010-08-31 Thread Chris Jenkins
Thanks Robert. That makes a lot of sense and I was able to follow your advice last night and get my source file to reload successfully by adding ":only [indexed]" to my :use clause (because indexed was the only function that I was using in this case). The thing that still confuses me is that I can