Re: dotimes suggestion

2009-02-22 Thread David Nolen
In general, I find that multiple arguments types for a function confusing. If dotimes is going to take multiple types it should be a multifn. That seems to imply a performance hit. I think Clojure wisely does not (or rarely does not?) allow for multiple types to be passed into a function. On top o

Re: dotimes suggestion

2009-02-22 Thread David Nolen
I agree that this is initially confusion, but I think that if you spend more than a couple of days with Clojure you will understand the ubiquitous and liberal use of binding forms. On Sun, Feb 22, 2009 at 2:42 PM, Mark Volkmann wrote: > > On Sun, Feb 22, 2009 at 1:34 PM, David Nolen &

Re: alternate syntax

2009-02-23 Thread David Nolen
Interesting thread on LtU on this subject: http://lambda-the-ultimate.org/node/1646 On Mon, Feb 23, 2009 at 10:42 AM, Mark Volkmann wrote: > > I have an idea I'd like to float to see if there are reasons why it's > a bad idea. > > What if Clojure had an alternate "surface" syntax that was transla

Re: alternate syntax

2009-02-23 Thread David Nolen
On Mon, Feb 23, 2009 at 12:10 PM, Mark Volkmann wrote: > The parens don't bother me. My concern though is that many people > won't take the time to learn Clojure primarily because of the parens. > The preprocessor would appease those people and not change anything > for those that like Clojure jus

Clojure & Slime, how to jump to a def/defn?

2009-02-23 Thread David Nolen
Is this supported yet? M-. is supposed to handle this, but I get an error when I try. David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.co

Re: Operating on multidimensional primitive arrays without reflection?

2009-02-23 Thread David Nolen
(time (let [arr (make-array Float/TYPE 1 1)] (dotimes [_ 10] (let [#^floats sub-arr (aget arr 0)] (aset-float sub-arr 0 0.0) Seems to work? Looks an eligible candidate for a macro. On Mon, Feb 23, 2009 at 9:04 PM, Jason Wolfe wrote: > > I'm trying to call some third-party code th

Re: Clojure & Slime, how to jump to a def/defn?

2009-02-23 Thread David Nolen
You're right, works perfectly on clojure sources, but not the instances you've described. It would be great if this would work again. I don't understand swank/slime well enough to try it myself. On Mon, Feb 23, 2009 at 9:23 PM, Alec Berryman wrote: > > David Nolen on 2009

Re: Algebraic data types in clojure.contrib

2009-02-25 Thread David Nolen
> > 1) User-friendly printing. > > I implement the multimethods print-method and print-dup for my > classes, which allows me to specify how objects are printed. print- > method and print-dup dispatch on class, so my types need to be > classes or at least derive from a class that is distinct from th

Re: Multimethods in other namespaces

2009-02-25 Thread David Nolen
That should work fine as far as I can tell. On Wed, Feb 25, 2009 at 3:36 PM, Jeffrey Straszheim < straszheimjeff...@gmail.com> wrote: > If in namespace one I define >(defmulti fred dispatch-fred) > > and have imported that ns into another, can I just do > > (defmethod fred ::val [x] )

Re: Algebraic data types in clojure.contrib

2009-02-25 Thread David Nolen
25, 2009 at 7:51 PM, Rich Hickey wrote: > > > > On Feb 25, 12:19 pm, Konrad Hinsen wrote: > > On Feb 25, 2009, at 17:40, David Nolen wrote: > > > > > Should print and println be multimethods? It seems the ability to > > > custom print a data structure

Re: Mathy operations on non-numerics

2009-02-27 Thread David Nolen
What about something like: (defn gt [str1 str2] (first (sort [str1 str2]))) (gt "Zoe" "Bob") ; -> "Bob" On Fri, Feb 27, 2009 at 12:03 PM, Phil Hagelberg wrote: > > Christian Vest Hansen writes: > > >> Are you referring to using <, >, =, with objects that implement > >> java.lang.Comparable?

Re: Laziness madness

2009-03-01 Thread David Nolen
Remember that you can force lazy sequences if you need to as you are with doseq with doall (retains head) and dorun (does not) as well. You probably want (dorun (map #(add-watch % watcher callback-fn) all-agents)) I think it's pretty clear here what's going on. Your code needs side-effects. In C

Re: Question on names of errors in error-kit

2009-03-03 Thread David Nolen
I appreciate that they stand out. Again, this is similar to the constants conversation earlier, visually marking the intended use is a good habit, IMHO. Of course this doesn't mean that error-kit should define the base error this way, but I intend to keep on wrapping my errors in earmuffs :) Davi

Re: Question on names of errors in error-kit

2009-03-03 Thread David Nolen
capitals seems pretty weird for a Lisp. Now that I think about it, perhaps foo-error isn't so bad. David On Tue, Mar 3, 2009 at 10:54 PM, Chouser wrote: > > On Tue, Mar 3, 2009 at 10:36 PM, David Nolen > wrote: > > I appreciate that they stand out. Again, this is simila

Re: hash-map based on identity

2009-03-07 Thread David Nolen
Depending on what you are doing perhaps you could use (hash x). This might not be very helpful if you need to update keys frequently. However if you're mostly doing lookups, then this would help quite a bit. On Sat, Mar 7, 2009 at 3:44 PM, Mark Engelberg wrote: > > Here's why it would be useful t

Re: On the importance of recognizing and using maps

2009-03-08 Thread David Nolen
Structs are maps with shared keys and positional constructors as Rich mentions in the original post. I think Rich is saying that maps should indeed "be abused" ;) By building all "higher level" structures on top of them, consumers are guaranteed not only your custom functionality, but all the func

Re: Help please: or function

2009-03-09 Thread David Nolen
The first regex is returning an empty list not nil. David On Mon, Mar 9, 2009 at 11:48 AM, timc wrote: > > Can someone please see what's wrong with this. > > (defn getArg [arg] >"Return a [keyword value] depending on the form of the string arg: >1. arg is of the form +x ==> [:x t

Re: macros

2009-03-10 Thread David Nolen
It does. Also Practical Common Lisp and On Lisp cover this in depth as well, though you'll need to convert commas into tildes as well as use ~' for each level of backquote depth that you don't want Clojure to namespace free symbols. On Tue, Mar 10, 2009 at 6:05 PM, .Bill Smith wrote: > > Does the

Re: macros

2009-03-10 Thread David Nolen
Practical Common Lisp and On Lisp are available online and free. On Tue, Mar 10, 2009 at 6:16 PM, David Nolen wrote: > It does. Also Practical Common Lisp and On Lisp cover this in depth as > well, though you'll need to convert commas into tildes as well as use ~' for > each

Re: Question about throwing errors

2009-03-11 Thread David Nolen
Doesn't error-kit do this? On Wed, Mar 11, 2009 at 10:15 PM, Mark Engelberg wrote: > > I'm thinking about implementing a backtracking mechanism that throws > errors as a way to escape out of the current computation and try > another possibility. I'd want to create a specific error to escape, > a

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread David Nolen
Amazing stuff. In particular this finally makes debugging macros sane. For those of you that are using swank-clojure you only need to make minor modifications to swank-clojure to pretty-print your macro expansions to the macro expansion buffer. Even better you can move the cursor to subform macros

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread David Nolen
So that people can copy and paste the change in basic.clj (defn- apply-macro-expander [expander string] (binding [*print-suppress-namespaces* true] (let [astr (with-out-str (with-pprint-dispatch *code-dispatch* (pprint (expander (read-from-string string)] (subs astr 0 (dec (cou

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread David Nolen
I suppose the following is more idiomatic: (defn- apply-macro-expander [expander string] (let [astr (with-out-str (binding [*print-suppress-namespaces* true] (with-pprint-dispatch *code-dispatch* (pprint (expander (read-from-string string))] (subs astr 0 (dec (count astr

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread David Nolen
s-namespaces* true] >(with-pprint-dispatch *code-dispatch* > (write (expander (read-from-string string)) :pretty true :stream > nil > > Completely untested! :-) > > Tom > > On Mar 12, 11:07 am, David Nolen wrote: > > I suppose the following is more idiomatic: &

Re: swank-clojure: swank-clojure-init-files not used

2009-03-16 Thread David Nolen
On Mon, Mar 16, 2009 at 3:42 AM, Tassilo Horn wrote: > > > When adding ~/.clojure/ to `swank-clojure-extra-classpaths' and starting > SLIME, htop shows that this directory is not in the -cp java option. > Sending a SIGINT kills the clojure process and doesn't interrupt the > current Thread only...

Re: Symbols evaluated at compile time?

2009-03-16 Thread David Nolen
This has come up before. You can actually work around this (search the mailing list for declare) I think that when not hacking against the REPL that the default behavior is a good one. Having to use declare bugged me a little at first, but I now consider it a very minor annoyance compared to the ad

Re: Symbols evaluated at compile time?

2009-03-16 Thread David Nolen
lare because this came up in another thread about declare and someone had hacked the reader to not bail immediately on undefined symbols). In CL, if you have definitions out of order in the compiler will issue warnings. > > I'm not saying it's an easy change... > > >

Re: Symbols evaluated at compile time?

2009-03-16 Thread David Nolen
Here's the post by Timothy talking about patching the compiler: http://groups.google.com/group/clojure/msg/ef5bae605f4a0730 On Mon, Mar 16, 2009 at 4:36 PM, Paul Stadig wrote: > On Mon, Mar 16, 2009 at 4:18 PM, David Nolen wrote: > >> On Mon, Mar 16, 2009 at 4:08 PM, P

Re: Clojure Web Framework, what I want to add

2009-03-16 Thread David Nolen
I'm mostly a front-end UI person with crazy amounts of JS experience so most of my input will be from that stand point. 1. I agree with Sean on this one. No need to bring in middleware that can't be expressed in 10X-20X less code in pure Clojure. 2. The framework should allow for any backend (even

Re: Can Clojure simulate Class?Lisp can do it!

2009-03-19 Thread David Nolen
Doesn't On Lisp talk about simulating CLOS with closures? It's free online. I would like to add as the creator that I would not use Spinoza yet ;) And I've put it on hold as I'm currently obsessed with trying to port cl-cont. Spinoza still needs quite a bit of work, I started on that before a few

ANN: Delimited Continuations for Clojure

2009-03-19 Thread David Nolen
You can get it here: http://github.com/swannodette/clj-cont/tree/master So over the past week I've been porting cl-cont ( http://common-lisp.net/project/cl-cont/) originally written by Slava Akhmechet to Clojure. I've now ported most of the functionality that's translatable from Common Lisp though

Re: Defaults for multi-argument dispatch

2009-03-20 Thread David Nolen
This works well as long as you don't mind the perf hit for the second dispatch :) On Fri, Mar 20, 2009 at 11:35 AM, Paul Stadig wrote: > You could use multiple multi-methods: > > user=> (defmulti plus-int (fn [x y] (type y))) > #'user/plus-int > user=> (defmethod plus-int :default [x y] (println

Re: New release 20090320

2009-03-20 Thread David Nolen
Congrats! It's been said many a time, but it bears being said again, Clojure makes hacking fun again. It's great working with a language that is very production ready, yet still evolving at a quick clip. It's also fascinating that a language supports so many different usage patterns- the diversity

Help with the dot operator special form

2009-03-21 Thread David Nolen
I'm wondering if it's possible to create a Clojure function that does what the dot operator does. It seems like this would be possible with definline but I'm unable to get this to work or figure it out. For example I want to be able write something like the following: (dot "Hello world" (list 'sub

Re: Help with the dot operator special form

2009-03-21 Thread David Nolen
On Sat, Mar 21, 2009 at 9:10 PM, Kevin Downey wrote: > > you want defmacro not definline. the result of a macro is a data > structure. that data structure is then evaluated in place of the call > to the macro. definline (I think?) behaves similar to a function, so > if it returns a data structure

Re: Help with the dot operator special form

2009-03-21 Thread David Nolen
Or rather I did not express that requirement clearly enough. On Sat, Mar 21, 2009 at 9:21 PM, David Nolen wrote: > On Sat, Mar 21, 2009 at 9:10 PM, Kevin Downey wrote: > >> >> you want defmacro not definline. the result of a macro is a data >> structure. that data str

Re: Help with the dot operator special form

2009-03-22 Thread David Nolen
Thanks all for the pointers, this looks like a workable approach. In my case I'm not bothered by the performance hit from reflection (CPS transformation creates an obscene number of anonymous functions anyway). However I am running into an issue. Here's my dot function: (def not-seq? (comp not se

Re: Help with the dot operator special form

2009-03-22 Thread David Nolen
That was it! At one point I knew these things. Thanks much. On Sun, Mar 22, 2009 at 2:18 PM, Eric Tschetter wrote: > > > (let [myref (ref {})] > > (dot > >clojure.lang.LockingTransaction > >(list 'runInTransaction (fn [] (commute myref assoc :mykey :myval) > > I'm getting a instanc

Re: Help with the dot operator special form

2009-03-22 Thread David Nolen
s are being transformed into a version that relies on reflection you can't expect this code to be super performant. That may or may matter depending on your use case ;) On Sun, Mar 22, 2009 at 5:28 PM, David Nolen wrote: > That was it! At one point I knew these things. Thanks much

Re: Information Hiding

2009-03-23 Thread David Nolen
You could always build something where setters/getters are auto-magically created if specified by the constructor macro. And with clojure.contrib.def you could auto-magically generate private setters/getters. On Mon, Mar 23, 2009 at 4:27 AM, Mark Engelberg wrote: > > I've been thinking quite a bi

Re: Slime errors with clojure_20090320

2009-03-23 Thread David Nolen
You need to make sure all the different moving parts are based on the newest version of Clojure as well. This includes swank-clojure, clojure-mode, and any other libs you might be using. On Mon, Mar 23, 2009 at 9:51 AM, Dan Pomohaci wrote: > > Hi, > > When I start slime with the new clojure_20090

Re: Proposed Change to str-utils

2009-03-23 Thread David Nolen
Looks interesting and maybe even very useful. Why not put your code on Github or some other public repo of your liking. It's much nicer than pasting all this code ;) On Mon, Mar 23, 2009 at 9:18 PM, Sean wrote: > > Hello Everyone, > I've been reviewing the str-utils package, and I'd like to prop

Re: Problem with CLASSPATH

2009-03-24 Thread David Nolen
The latest version of Clojure incorporated lazy sequences which broke many libraries early on. Most of these problems have been worked out. In my experience you should use the cutting edge version of everything including SLIME. I clone everything from GitHub (clojure, clojure-contrib, swank-cloju

Re: Suggestion for Java Clojure code, use of checkstyle or code formatter

2009-03-24 Thread David Nolen
Javadoc would be nice, but I do note that Rich's Java code is pretty darn clear ;) I also note the indentation style is similar to Whitesmith's according to Wikipedia http://en.wikipedia.org/wiki/Indent_style. I've always preferred the BSD curly brace level matching convention over the K&R derivat

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: Using method names in macros

2009-03-28 Thread David Nolen
Your solution is the accepted one ;) On Sat, Mar 28, 2009 at 1:59 PM, ke...@ksvanhorn.com wrote: > > I'm in the process of learning Clojure, and I ran across something > that other newbies like me may find useful. The question I had was > this: how does one get a method name into a macro? Cons

Re: oo

2009-03-28 Thread David Nolen
On Sat, Mar 28, 2009 at 4:40 PM, mikel wrote: > > So, at minimum, to make a solid port, you need to add a function that > can return a sensible type value for any input Enjoying the thread. Out of curiosity for which Clojure values is the return value of the type function undefined? David --~

Possible Solution for Left-Right Precedence and More when using Multimethods? (was re: oo)

2009-03-28 Thread David Nolen
Having thought a little about multiple inheritance when implementing Spinoza I also ran into this problem. However at the time I wasn't hindered by multifn dispatch as much as the fact that parents cannot be ordered (because calling parents on a tag returns a set) as pointed out by Mark. I understa

Re: What's a convenient way of calling super.method()?

2009-03-28 Thread David Nolen
Here's a quickly hacked together solution (code golf welcome), I'm using special variables so that we don't affect what other multimethods see: (def *super* nil) (defmacro super [afn obj & args] (let [fn-key (keyword (str afn))] `(binding [*super* {~fn-key (or (and (~fn-key *super*) (fi

Re: new in contrib.test-is: fixtures

2009-03-28 Thread David Nolen
very cool :) On 3/28/09, Stuart Sierra wrote: > > Hi folks, > I finally came up with fixtures for clojure.contrib.test-is. Now you > can do before/after setup for each test case. Here's the > documentation, let me know what you think. > -Stuart Sierra > > ;; FIXTURES (new) > ;; > ;; Fixt

Re: oo

2009-03-28 Thread David Nolen
On Sun, Mar 29, 2009 at 1:25 AM, mikel wrote: > > (type (proxy [clojure.lang.IMeta clojure.lang.IRef][])) > > java.lang.UnsupportedOperationException: meta (NO_SOURCE_FILE:0) > [Thrown class clojure.lang.Compiler$CompilerException] > > > No doubt someone is going to point out that the proxy objec

Re: What's a convenient way of calling super.method()?

2009-03-29 Thread David Nolen
Glad to be of help. To be totally honest I hadn't really tested it too much, so I don't know ;) One obvious limitation here is that it doesn't work with multiple inheritance (it only looks at the first item in the parents set). As long you're sticking with a Java-style single inheritance model thi

Re: oo

2009-03-29 Thread David Nolen
n the technical sense :) case as the one you've pointed out? I'm interested in hearing reasons if there is one. David On Sun, Mar 29, 2009 at 5:22 PM, mikel wrote: > > > > On Mar 29, 1:34 am, David Nolen wrote: > > On Sun, Mar 29, 2009 at 1:25 AM, mikel wrote: > >

Re: Please suggest a way to learn just enough Java for Clojure

2009-03-30 Thread David Nolen
There's a few posts on the mailing list suggesting some good starting points. You can get far in Clojure without resorting to Java but it definitely helps to know some if you really want to advance your knowledge of Clojure's inner workings as well as get it to interoperate with Java libraries. O

Re: I need help tracking down a performance problem.

2009-03-31 Thread David Nolen
Did you try using aset-int instead of aset? On Tue, Mar 31, 2009 at 8:25 AM, Vincent Foley wrote: > > For those interested, I managed to improve the performance of my > original program from 2 minutes 40 seconds to decode 1000+ files down > to 2 minutes. I'm still far from my goal, but it's an

Re: Possible Solution for Left-Right Precedence and More when using Multimethods? (was re: oo)

2009-03-31 Thread David Nolen
Many thanks for the long and reasoned reply (and to mikel as well for adding his thoughts). I apologize for my slowness in understanding the nature of multimethods- it's tricky converting my existing knowledge ;) On Tue, Mar 31, 2009 at 10:32 AM, Rich Hickey wrote: > > > Here are the areas I'm lo

Re: I need help tracking down a performance problem.

2009-03-31 Thread David Nolen
> > > > > No, but in my defense I did not know such a function existed :) I'll > > > give it a whirl and report back! > > > > > On Mar 31, 9:57 am, David Nolen wrote: > > > > Did you try using aset-int instead of aset? > > > >

Re: I need help tracking down a performance problem.

2009-03-31 Thread David Nolen
1 Class loader > 0.0% 2 Unknown: no last frame > > > Flat profile of 0.01 secs (1 total ticks): DestroyJavaVM > > Thread-local ticks: > 100.0% 1 Blocked (of total) > > > Global summary of 176.12 seconds: > 100.0% 1160

Re: I need help tracking down a performance problem.

2009-03-31 Thread David Nolen
Foley wrote: > > I tried it just now; it made no difference. Nevertheless, thank you > for you help and time! > > On Mar 31, 9:38 pm, David Nolen wrote: > > Did you try > > (int (mask8 (. buf__2572__auto__ (get > > > > ? > > > > Your ma

Re: I need help tracking down a performance problem.

2009-03-31 Thread David Nolen
As as a side note, putting type hints into the body of the macro expansion doesn't do anything. These will be discarded. You will need to coerce types via other methods, investigating how ints is implemented in core.clj is a good place to start. On Tue, Mar 31, 2009 at 11:04 PM, David Nolen

Re: -> vs. comp

2009-03-31 Thread David Nolen
comp creates a new function that you can store. -> threads a value through a series of expressions. On Wed, Apr 1, 2009 at 12:52 AM, kkw wrote: > > Hi folks, > >I have some code where I wanted to: > - take a list of stuff (which includes another list inside) > - use 'seq-utils/flatten' to fl

Re: Possible Solution for Left-Right Precedence and More when using Multimethods? (was re: oo)

2009-04-01 Thread David Nolen
Very cool. On Wed, Apr 1, 2009 at 8:47 AM, Rich Hickey wrote: > > > I've added get-method (SVN 1338). > > (derive ::Circle ::Shape) > (derive ::Rect ::Shape) > > (defmulti area :Shape) > > ;note - you can name methods > (defmethod area ::Shape area-shape [x] nil) > > (get-method area ::Rect) > #

Re: Questions about Clojure and Common Lisp

2009-04-02 Thread David Nolen
On Apr 1, 11:41 am, Chanwoo Yoo wrote: > Hello. Yesterday, I talked with a representative of a publisher about > a translation of Lisp books. There are books about Ruby, Lua, Erlang, > and Groovy in South Korea, but there is no book about Lisp except > SICP. So he is considering printing the fi

Re: Array of primitives

2009-04-02 Thread David Nolen
you should look into float-array and friends. On Fri, Apr 3, 2009 at 12:04 AM, Sean wrote: > > I'm working with AWT, and there is a method that requires a float[] > (The java.awt.BasicStroke constructor). Is it possible to directly > create an array of primitives directly in Clojure, or do I ne

Re: Simple dosync/alter question

2009-04-06 Thread David Nolen
I think what you want is: (def foo (ref 0)) (defn square [x] (* x x)) (defn square-ref [x] (dosync (ref-set foo (square x (square-ref 2) On Mon, Apr 6, 2009 at 3:02 PM, bgray wrote: > > I have a some what (I believe) easy question. Could someone let me > know what I'm doing wrong? A simpli

Re: A large Clojure deployment

2009-04-07 Thread David Nolen
Congrats! Perhaps soon there should be a Projects Using Clojure section on the main site? Good way to get the word out that people are using Clojure in the "real world" David On Tue, Apr 7, 2009 at 10:47 AM, Sean wrote: > > Okay wow... it'll take some time to fully appreciate this. > > Can yo

Re: Clojure on Google AppEngine

2009-04-07 Thread David Nolen
Very exciting, thanks for the excellent and informative writeup. On Wed, Apr 8, 2009 at 12:41 AM, John D. Hume wrote: > > As predicted, Google has now released Java support for AppEngine. I > was lucky enough to get an early look, which I dedicated entirely to > Clojure. > > Here's a writeup: > h

Re: Enlive questions

2009-04-10 Thread David Nolen
This is great. I had thought that supporting some kind of partial template thing would be interesting, but that's actually just my poor logic at work ;) It seems like with the new version of Enlive I could do something like this: (deftemplate pageA-template path [] [[:div (attr? :tiptree:repl

Re: Enlive questions

2009-04-10 Thread David Nolen
Real quick thought: (deftemplate-generator template-generator [args] rule-vector transform-fn) Would produce a template generator. (def template-name (template-generator path-to-xml-or-file-or-xml-string)) Would produce a real template. (apply str (template-name arg1 arg2 arg3)) --~--~

Re: Amb operator

2009-04-13 Thread David Nolen
Using try-catch for control flow is probably not a good idea. Shameless plug, do you think you could get this to work with clj-cont? clj-cont is a port I did of cl-cont. It has some limitations, but because Clojure has so few special forms (compared to Common Lisp), it has the chance to achieve pre

Re: Amb operator

2009-04-13 Thread David Nolen
retty much anything else. However, with some quick testing I note that using Exceptions for flow control might be even 2x slower than clj-cont. On Mon, Apr 13, 2009 at 1:54 PM, David Nolen wrote: > Using try-catch for control flow is probably not a good idea. Shameless > plug, do you thi

Re: Amb operator

2009-04-13 Thread David Nolen
27;re throwing away the away stack trace making debugging more difficult? It got me thinking about arbitrary flow control, on the nested loop thread I've added my findings... On Mon, Apr 13, 2009 at 4:24 PM, Victor Rodriguez wrote: > > On Mon, Apr 13, 2009 at 2:13 PM, David Nolen > wrote

Re: Nested loops

2009-04-13 Thread David Nolen
Out of simple curiosity I wondered how hard it would be to implement flow control using proxy. I know Rich isn't hot on non-structured programming, but there may be times where this might be useful: (ns flow.return-from (:import (flow IReturnFrom))) (defn create-return-from [value] (proxy [T

Re: Javascript generator

2009-04-13 Thread David Nolen
Do you have any plans for continuing to support this? If so are you against putting this on GitHub or Google Code so that people can follow it's development? Thanks for contributing it to the community. On Wed, Feb 25, 2009 at 7:49 PM, jim wrote: > > I've just uploaded a javascript generator ala

Re: Javascript generator

2009-04-13 Thread David Nolen
ce maps are not ordered. On Tue, Apr 14, 2009 at 1:19 AM, David Nolen wrote: > Do you have any plans for continuing to support this? If so are you against > putting this on GitHub or Google Code so that people can follow it's > development? > Thanks for contributing it to the c

Re: Javascript generator

2009-04-14 Thread David Nolen
Cool! Rather then waiting, you could host it in the interim on GitHub or Google Code so people like myself can submit patches (which I'm more than willing to do) ;) Just a thought... A couple of things: (println (javascript (var x))) I would expect this to convert to: var x; It does not. (pri

Re: Javascript generator

2009-04-14 Thread David Nolen
Cool! Rather then waiting, you could host it in the interim on GitHub or Google Code so people like myself can submit patches (which I'm more than willing to do) ;) Just a thought... A couple of things: (println (javascript (var x))) I would expect this to convert to: var x; It does not. (pri

Re: [Discuss] Contribs with dependencies

2009-04-14 Thread David Nolen
Joda Time, Colt, Fork/Join seem like projects that truly add something to Clojure. These are projects which solve problems that developers have come to expect from their respective language. Joda Time - sane date/time (really useful when building web services). Colt - enough people want to do graph

Re: [Discuss] Contribs with dependencies

2009-04-14 Thread David Nolen
s over and over again (writing matrix math Clojure apps on top of Clojure vectors...) On Tue, Apr 14, 2009 at 11:01 AM, David Nolen wrote: > Joda Time, Colt, Fork/Join seem like projects that truly add something to > Clojure. These are projects which solve problems that developers have come &

Re: Javascript generator

2009-04-14 Thread David Nolen
Cool! Thanks. Also sorry for the accidental double post and I had a typo, I meant the weird result was: (println (javascript (new ClassGenerator {prop1 "a" prop2 "b"}))) > var MyClass = new(ClassGenerator, {prop1:"a",prop2:"b"}); Instead of- var MyClass = new ClassGenerator({prop1:"a", prop2:"b

Re: Enlive questions

2009-04-14 Thread David Nolen
Great! I will play around with the new features and returns with some more informed feedback ;) On Tue, Apr 14, 2009 at 9:58 AM, Christophe Grand wrote: > > Hello David, > > David Nolen a écrit : > > Considering the above, I'm left wondering if it's possible to

Re: Enlive questions

2009-04-14 Thread David Nolen
there right now ;) On Tue, Apr 14, 2009 at 1:31 PM, Christophe Grand wrote: > > I pushed do->, attr=, attr? and snippets values as source to github > http://github.com/cgrand/enlive/commits/right > > Christophe Grand a écrit : > > Hello David, > > > > David Nolen

Re: Enlive questions

2009-04-14 Thread David Nolen
e: > > I pushed do->, attr=, attr? and snippets values as source to github > http://github.com/cgrand/enlive/commits/right > > Christophe Grand a écrit : > > Hello David, > > > > David Nolen a écrit : > > > >> Considering the above, I'm left wo

Re: Enlive questions

2009-04-16 Thread David Nolen
Because predicates in selectors no longer need to be quoted it seems you can't use Enlive selectors in a first class way with snippets: (let [aselector [[:div (attr= :tiptree:widget "widgetA")]]] ((snippet "widget.html" aselector [some-map] [:div.value] (content "foo")) {})) I believe th

Re: Enlive questions

2009-04-16 Thread David Nolen
pp6 {:widgetA {:value "0"}, :widgetB {:value "1"}})) Works for me, and this was in general the use case I was thinking of. On Thu, Apr 16, 2009 at 4:24 PM, David Nolen wrote: > Because predicates in selectors no longer need to be quoted it seems you > can't use E

Re: Enlive questions

2009-04-17 Thread David Nolen
] >>           [widget] >>            [:div.value] (content (if widget >>                                    (:value widget) >>                                    "foo"))) >> >> (deftemplate my-app6 "app2.html" >>  [widgets] >>   [[:div (attr?

Re: clojure-swank and macro expansion

2009-04-17 Thread David Nolen
If you have the latest version of clojure.contrib you can do the following: Modify the namespace declaration in swank-clojure/swank/commands/basic.clj to look like the following: (ns swank.commands.basic (:refer-clojure :exclude [load-file]) (:use (swank util commands core) (swank.util

Re: clojure-swank and macro expansion

2009-04-17 Thread David Nolen
include sub-forms. > I will keep digging... > > Thanks again, > Paul. > > 2009/4/17 Jeffrey Chu : > > > > Thanks for the tip. I've added it to swank-clojure (only if you have > > clojure.contrib installed though, so don't forget to have that > >

Re: StackOverflowError Question

2009-04-20 Thread David Nolen
You have two other function calls getAdaptedWeightVector computeActualResponse Are these recursive as well? On Sun, Apr 19, 2009 at 11:26 PM, jleehurt wrote: > > Hi all, I have the following code that trains a perceptron with the > given inputs and corresponding desired inputs. For input/output

Re: Modifying data structures without changing their interface

2009-04-20 Thread David Nolen
A couple of things. In your initial example, you conflated some things. One issue is simply a matter of convenience- defining a getter so that you can use Python object property access (via the dot operator). Personally I don't like this idiom at all (you find it in Objective-C 2.0 and Javascript).

Re: 'first vs 'nth on maps

2009-04-20 Thread David Nolen
Maps aren't ordered so this isn't a good idea anyway. The reason first/second work is because they call seq on the collection. (key (nth (seq {:a 1 :b 2 :c 3}) 1)) -> :b On Mon, Apr 20, 2009 at 2:51 PM, hughw wrote: > > Hi all, > > Why should 'first and 'second work on maps, but not 'nth? > > u

Re: Abstract data types in functional languages

2009-04-20 Thread David Nolen
Konrad added an early implementation of abstract data types to clojure-contrib (types.clj) you might want to check that out. I also did some work on supporting more traditional style OO with Spinoza (structural+behavioral inheritance), but I've sidelined it for the time being until I find that I ac

Re: Abstract data types in functional languages

2009-04-21 Thread David Nolen
Nice post thanks for putting it together. My gut feeling is that the need for information hiding is still overinflated, but... until someone builds a 200k LOC Clojure program who will know for sure? Here's my shot at a solution for private data: (defn set-private [m k x] (let [the-meta(meta

Re: 'first vs 'nth on maps

2009-04-21 Thread David Nolen
On Mon, Apr 20, 2009 at 5:17 PM, Hugh Winkler wrote > > > Thanks! I think 'nth ought to behave just like 'first and 'second, > don't you? If it's a good idea for 'first it's a good idea for 'nth. > It does seems like a reasonable behavior for sorted-set and sorted-map, but what else really? Also

Re: Abstract data types in functional languages

2009-04-22 Thread David Nolen
nse? A few quick tests show that the hash of a data structure will match on any VM. On Wed, Apr 22, 2009 at 1:01 PM, Victor Rodriguez wrote: > > On Tue, Apr 21, 2009 at 12:01 PM, David Nolen > wrote: > > Nice post thanks for putting it together. My gut feeling is that the > need &

Re: Abstract data types in functional languages

2009-04-23 Thread David Nolen
[m k] (get (:private (meta m)) k)) (defn eq? [a b] (and (= a b) (= (:private (meta a)) (:private (meta b) On Wed, Apr 22, 2009 at 7:20 PM, Victor Rodriguez wrote: > > On Wed, Apr 22, 2009 at 1:28 PM, David Nolen > wrote: > > You're missing the clever hack ;

Re: Abstract data types in functional languages

2009-04-24 Thread David Nolen
On Fri, Apr 24, 2009 at 12:15 PM, Mark Engelberg wrote: > > The problem, of course, is that there is a language design principle > that has evolved in the OO community that client code shouldn't need > to know whether you are accessing a field or a method. In Clojure, > things kind of break down

Re: Abstract data types in functional languages

2009-04-24 Thread David Nolen
Oops didn't finish my thought before sending. Anyways, the point is that Clojure encourages the programmer to design functionality around functions not data structures. Because Clojure is a Lisp, this syntax can be very expressive. On Fri, Apr 24, 2009 at 12:49 PM, David Nolen wrote: >

Re: Google announcement, version 1.0 & SCM Holy War (not really)

2009-04-24 Thread David Nolen
Well you have it in your local repo, that "counts" ;) In fact that is the big advantage of a DVCS, that you can make local commits. This also means that if for some reason the big server in the sky goes down, your repo has all the information that the big sky one did and can be used by anyone to c

Re: Abstract data types in functional languages

2009-04-24 Thread David Nolen
Perhaps I'm being dense but I still fail to see what the issue is here: (defn setter [sym] `(defn ~(symbol (str "set-" sym)) [~'x ~'y] (assoc ~'x ~(keyword (str sym)) ~'y))) (defn getter [sym] `(defn ~(symbol (str "get-" sym)) [~'x] (~(keyword (str sym)) ~'x))) (defmacro accessors [

<    1   2   3   4   5   6   7   8   9   10   >