Re: Blogging About Clojure?

2008-12-17 Thread David Nolen
Lots of possibilities, but a simple solution is that you could find a hosting service that supports easy WordPress setup and pick a minimal theme that's to your liking. David On Tue, Dec 16, 2008 at 1:05 PM, Randall R Schulz wrote: > > Hi, > > Wordy though I am, I've never done any blogging bef

Re: A quasiquote for Clojure?

2008-12-17 Thread David Nolen
You can have unresolved symbols within a macro with: ~'symbol David On Wed, Dec 17, 2008 at 3:30 AM, Meikel Brandmeyer wrote: > > Hi, > > I'd like to propose/put up for discussion a change to the unquote > handling. > I basically ran into the following problem: > > I'd like to embed a DSL into

Re: Blogging About Clojure?

2008-12-20 Thread David Nolen
For syntax highlighting in WordPress this is a good solution. It was originally written to be used for the EmacsBlog so it should handle Clojure just fine. David On Fri, Dec 19, 2008 at 7:09 PM, Jason wrote: > > Hi Randall, > > I'm in the same boa

Re: clojure and clojure-contrib github projects updated

2008-12-27 Thread David Nolen
Thanks! On Sat, Dec 27, 2008 at 2:01 PM, Kevin O'Neill wrote: > Hi all, > I've updated the github svn clones to pull from google code. I've also > pushed the 20081217 branch so it's now accessible from git. > > Any problems please let me know. > > -k. > > > > --~--~-~--~~---

Re: Fibonacci sequence

2008-12-28 Thread David Nolen
> > (defn fib-helper [a b] > (fib-helper b (+ a b))) > > (defn fib (fib-helper 0 1)) ; This doesn't work either: (defn fib (fib- > helper '(0 1))) You're missing your argument list for fib. > (println (take 5 fib)) take creates a lazy list from a collection: (take n collection) Your fib do

Re: why two list comprehensions are different?

2008-12-28 Thread David Nolen
> > Yes, but I think maybe there is a bug in Clojure that causes the first > case to "work" when it should give a syntax error. If it is not a bug > I do not understand why it ignores the expression. > It's not a "bug" in Clojure because Clojure doesn't really have syntax in the way that you seem

Re: newbie question!!

2009-01-14 Thread David Nolen
(:name @(first (:friends @bill))) You need to dereference before trying to access name. David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroup

Re: is it type hint?

2009-01-16 Thread David Nolen
Just made sense to me today as well. #^Class is short form for saying set the metadata for the symbol being defined (in this case list) to the map {:tag Class}. #^ is a reader macro for setting metadata for the compiler. That code is simple tagging the symbol clojure/list. (meta #'list) will g

Inheritance & multiple inheritance using structs

2009-01-18 Thread David Nolen
After a couple of days of hacking it's clear that Clojure can support OO structures really, really, well. I've whipped up a little thing, jokingly called CLJOS. I'm curious to know what people think. It's a fairly simple affair combining structs, hierarchies, and some helper functions. It's my f

Re: Inheritance & multiple inheritance using structs

2009-01-18 Thread David Nolen
Of course it might be the case that not many people are interested in the implementing ideas from CLOS for Clojure especially since there's a lot of exciting new functional ground to cover in Clojure first ;) I come from a UI background so I'm interested in the OO implications/possiblities of Cloj

Re: A couple of questions concerning syntax-quote

2009-01-19 Thread David Nolen
The multiple syntax-quote and unqote behavior above seems to work in Clojure just fine and like CL as well. On Mon, Jan 19, 2009 at 5:58 AM, Rock wrote: > > I'm trying to make the documentation (still awaiting approval) in the > "Learning Clojure" WikiBook regarding syntax-quote expansion as > a

Re: is it type hint?

2009-01-19 Thread David Nolen
Thanks much. On Mon, Jan 19, 2009 at 11:03 AM, Michael Reid wrote: > > On Fri, Jan 16, 2009 at 9:57 PM, David Nolen > wrote: > > Just made sense to me today as well. > > #^Class > > is short form for saying set the metadata for the symbol being defined > (in

#^ Reader Macro Issues was Re: function equivalents of macro characters

2009-01-19 Thread David Nolen
On Mon, Jan 19, 2009 at 12:24 PM, Chouser wrote: > > #^ - metadata > > #^ adds metadata at read-time, so there's no way for a function to do > exactly the same thing, though 'with-meta' does something similar at > runtime. > I've noticed this as well. It seems to me that this prevents you from

Re: #^ Reader Macro Issues was Re: function equivalents of macro characters

2009-01-19 Thread David Nolen
Wow, nice! On Mon, Jan 19, 2009 at 1:47 PM, Stuart Sierra wrote: > > On Jan 19, 1:15 pm, David Nolen wrote: > > I've noticed this as well. It seems to me that this prevents you from > > dynamically defining a var (like in a macro) that has metadata attached > to &g

Re: #^ Reader Macro Issues was Re: function equivalents of macro characters

2009-01-19 Thread David Nolen
Actually, so this can't be used on structs for fns? On Mon, Jan 19, 2009 at 1:47 PM, Stuart Sierra wrote: > > On Jan 19, 1:15 pm, David Nolen wrote: > > I've noticed this as well. It seems to me that this prevents you from > > dynamically defining a var (like i

Re: #^ Reader Macro Issues was Re: function equivalents of macro characters

2009-01-19 Thread David Nolen
Works. amazing. On Mon, Jan 19, 2009 at 4:51 PM, David Nolen wrote: > Actually, so this can't be used on structs for fns? > > On Mon, Jan 19, 2009 at 1:47 PM, Stuart Sierra < > the.stuart.sie...@gmail.com> wrote: > >> >> On Jan 19, 1:15 pm, David Nolen

Re: Possible feature: consider aliases when reading namespace-qualified keywords.

2009-01-19 Thread David Nolen
My OO example from earlier deals with this case by completely removing any need to manually derive tags. This is done by having CLJOS keep it's own internal hierarchy (via make-hierarchy) rather than using the default one. By modifying metadata on the vars holding structs created by defclass (usi

Multimethod Reflection?

2009-01-20 Thread David Nolen
Looking at the multimethod implementation (MultiFn.java) I noticed that multimethod keeps an internal persistent map of dispatch values in a field call methodTable. It seems to me it would pretty simple to expose this field (or a copy of it anyway) so that multimethod reflection can take place. (r

Re: Multimethod Reflection?

2009-01-20 Thread David Nolen
Thanks! On Tue, Jan 20, 2009 at 7:28 PM, Rich Hickey wrote: > > > > On Jan 20, 6:48 pm, David Nolen wrote: > > Looking at the multimethod implementation (MultiFn.java) I noticed that > > multimethod keeps an internal persistent map of dispatch values in a > fiel

Re: struct question

2009-01-22 Thread David Nolen
Finally started a GitHub repo just for this project. http://github.com/swannodette/cljos/tree/master The earlier version of course was very flawed/buggy. OK start, but the macros in it were written with little/no understanding about how symbols are resolved into their namespaces in Clojure (or Li

Re: struct question

2009-01-22 Thread David Nolen
> > I am not entirely happy with this approach though. If everyone starts > to use metadata for various purposes, such type tags may well > disappear by some function replacing the metadata on an object > without preserving the tags that are already there. This is all the > more likely because ther

Re: struct question

2009-01-22 Thread David Nolen
Can't some elements of the problem be solved with some form of predicate dispatching as proposed by Meikel? Predicate dispatching would allows us to use _anything_ as a type (i.e. structs themselves), as well as allowing user defined functions to do the matching instead of being limited to isa? an

Re: struct question

2009-01-22 Thread David Nolen
http://lispnyc.org/soc2009.clp Forget most of what I said, it seems the BDFL already has these things in mind ;) Enough of types and structs for me, time for me dive into the less familiar territory of Clojure. On Thu, Jan 22, 2009 at 12:25 PM, David Nolen wrote: > Can't some element

Re: Possible feature: consider aliases when reading namespace-qualified keywords.

2009-01-23 Thread David Nolen
Nice :) On Fri, Jan 23, 2009 at 2:10 PM, Jason Wolfe wrote: > > On Jan 19, 4:29 pm, Jason Wolfe wrote: > > I've been doing some OO-type Clojure programming, and have run into > > the following (quite minor) annoyance: > > > > I've defined a struct with a :class of ::Foo in namespace > > my.long

Clojure for Games/Simluation/Art (Optimization in Clojure)

2009-01-27 Thread David Nolen
Dear Clojurians, After my obsessed stint with object orientation, I went on to a new obsessed stint with basic functional programming with the hope of converting a nice Java boid simulation written in the popular Processing pedagological tool. I would like to find out if anyone has pointers on im

Re: Clojure for Games/Simluation/Art (Optimization in Clojure)

2009-01-28 Thread David Nolen
> > For the purpose of game development, I think it is a mistake to perform > these calculations for every pair of birds. If you had an error of 1% in > each of the three characteristics (cohesion, alignment, separation) would > that still be good enough? Would this be an acceptable loss if you got

Re: Clojure for Games/Simluation/Art (Optimization in Clojure)

2009-01-28 Thread David Nolen
On Wed, Jan 28, 2009 at 6:59 AM, bOR_ wrote: > > There is many ways in which you can improve the algorithm. I have seen > flocks of 10,000 birds being rendered real-time on a laptop by Hanno > Hildenbrandt, theoretical biology Utrecht. > > > http://www.rug.nl/biologie/onderzoek/onderzoekgroepen/t

Re: pretty-printing?

2009-01-28 Thread David Nolen
Agreed ;) On Wed, Jan 28, 2009 at 9:54 AM, Matt Moriarity wrote: > > I say go for it. maybe swank could use it for macroexpansions and > stuff. the lack of pretty-print drives me crazy! > > On Jan 27, 10:56 am, Mike DeLaurentis wrote: > > Hi, > > > > Is anyone aware of a pretty-print function fo

Re: Object system for Clojure?

2009-01-30 Thread David Nolen
At this point you have to roll your own, I have an experimental thing I plan on fleshing out temporarily called CLJOS. I've implemented field inheritance, type inheritance, basic multiple inheritance, basic introspection. Search the mailing list for CLJOS and you'll see more details. It only took

Re: Object system for Clojure?

2009-01-30 Thread David Nolen
> > (defn make-window [id] > {:tag ::window, :id id}) > > (defn make-color-window [id color] > (assoc (make-window id) >:tag ::color-window >:color color)) > > (derive ::color-window ::window) > > (defmulti describe-window :tag) > > (defmethod describe-window ::window [w] > (println "Win

Re: Object system for Clojure?

2009-01-30 Thread David Nolen
> > On Jan 30, 3:16 pm, Stuart Sierra wrote: > > > > I think the goal is to provide object-like capabilities without > > needing actual objects. > > Why is that the goal? I mean, the JVM provides a well defined, high > performance object oriented system. Clojure can already generate > classes -

Re: Clojure is "not a serious language"

2009-01-30 Thread David Nolen
Agreed :) On Fri, Jan 30, 2009 at 11:40 PM, Jon Harrop wrote: > > > Apologies if you've seen this before but I just thought it was absolutely > hillarious: > > http://www.3ofcoins.net/2009/01/30/common-lisp-clojure-and-seriousness/ > > -- > Dr Jon Harrop, Flying Frog Consultancy Ltd. > http://ww

CLJOS -> Spinoza, 3X faster than struct-map ;)

2009-02-01 Thread David Nolen
I've changed the name of my project since that was a joke anyway. http://github.com/swannodette/spinoza/tree/master Spinoza isn't just for people who want object oriented behaviors. It's also for anyone who plans on instantiating many structs. Spinoza's make-instance macro automatically orders y

Re: CLJOS -> Spinoza, 3X faster than struct-map ;)

2009-02-02 Thread David Nolen
Just to be clear make-instance is a macro on struct: (defmacro make-instance "Takes a defclassed struct-basis and creates a struct. Initializes properties to default values." [aclass & initializers] (let [class-key (eval (make-pair aclass)) class-sym (symbol (name aclass))

Re: Clojure speed

2009-02-02 Thread David Nolen
Heh, this is a more reasoned reply than my own as it points out an actual implementation difference between Python and Clojure. And of course you might need arbitrary precision arithmetic in your program, but again this just reinforces the insignificance of microbenchmarks without some context of w

Re: Clojure speed

2009-02-02 Thread David Nolen
Please do the list a favor and read the very long threads about performance. You cannot expect to enter a new language run a microbenchmark you would never see in a running programming and expect that to be anything like a real comparison. Here's something unlikely but far less so (something like

Re: CLJOS -> Spinoza, 3X faster than struct-map ;)

2009-02-02 Thread David Nolen
Hey, it is an extremely simplified example ;) Which is more readable in the long run? (struct sprite ::foobar 98 ::hunta ::laser [5.5 3.3] 4.01 78) or (make-instance foobar :id 98 :mode ::hunta :weapon ::laser

Re: special forms vs. functions and macros

2009-02-02 Thread David Nolen
I think the special forms list on the Clojure main page lists all the constructs that are not written in Clojure itself. It seems most everything else can be found in the .clj files in the src directory. I'm constantly looking in there when I'm curious how something works or is implemented, espec

Re: need some help getting jacob com library to work

2009-02-02 Thread David Nolen
You need to add it to -cp argument when starting up the REPL, not your environment CLASSPATH. On Mon, Feb 2, 2009 at 9:05 PM, greg wrote: > > I have recently enjoyed exploring clojure. > > I can use java... > C:\myprograms\clojure>java -cp clojure.jar clojure.lang.Repl > Clojure > user=> (into [

Re: Clojure speed

2009-02-03 Thread David Nolen
Even more constructive is to take a real Python program that you've written where you actually care about it's performance. Rewrite it Clojure. Do some investigation about which parts seem slow to you. Spend some time on this. Come back with some code and questions and you'll probably get some

Re: CLJOS -> Spinoza, 3X faster than struct-map ;)

2009-02-03 Thread David Nolen
: > > On Feb 1, 5:22 pm, David Nolen wrote: > > I've changed the name of my project since that was a joke anyway. > http://github.com/swannodette/spinoza/tree/master > > > > Spinoza isn't just for people who want object oriented behaviors. It's >

Re: Macro error

2009-02-03 Thread David Nolen
{} is a reader macro for hash-map I believe, try something like this: (defmacro foobar [& rest] `(hash-map ~...@rest)) (foobar :first 1 :second 2) On Tue, Feb 3, 2009 at 7:45 PM, Jeffrey Straszheim < straszheimjeff...@gmail.com> wrote: > > Btw, I fixed the ~ needed on relation. It didn't hel

Type hint Java array of your own Java class

2009-02-04 Thread David Nolen
(defn foobar [#^MyClass[] myarray]) This syntax doesn't seem to 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

Re: Type hint Java array of your own Java class

2009-02-04 Thread David Nolen
Many thanks. On Wed, Feb 4, 2009 at 12:49 PM, Christophe Grand wrote: > > David Nolen a écrit : > > (defn foobar [#^MyClass[] myarray]) > > > > This syntax doesn't seem to work. > Indeed it's a bit tricky: > #^"[Lyour.package.YourClass;" > &g

Re: anyone going to FOSDEM?

2009-02-05 Thread David Nolen
Raphaël, I will be there presenting the open source meta web project ShiftSpace ( http://shiftspace.org) at the art festival Artefact ( http://www.artefact-festival.be/). Unfortunately this project isn't really Clojure related, it's primarily written in Javascript :) However, two people (including

Clojure Simulation Redux (more on Clojure Optimization)

2009-02-05 Thread David Nolen
For those who are interested in Clojure performance, I've updated my flocking example from earlier, which uses Roland's excellent Processing library. http://github.com/swannodette/clojure-stuff/blob/80035bb3b76c21d39d6f8011e9a27aa1116b/flocking.clj It is twice as fast as the previous version a

Re: CLJOS -> Spinoza, 3X faster than struct-map ;)

2009-02-05 Thread David Nolen
> > I don't argue that this model is better than what you're doing with > Spinoza, but for years (see > http://www.mactech.com/articles/frameworks/8_2/Protocol_Evins.html > from 1994) I've wanted an object model that explicitly separates > structure from protocol, and since I partially built one in

Re: CLJOS -> Spinoza, 3X faster than struct-map ;)

2009-02-05 Thread David Nolen
(isa? [:spinoza-example-one/circle] [:spinoza/object]) ;; true Just to note, the above shows that protocols could have their own inheritance chain. This is insanely powerful and could be implemented very quickly. --~--~-~--~~~---~--~~ You received this message bec

Re: CLJOS -> Spinoza, 3X faster than struct-map ;)

2009-02-05 Thread David Nolen
> > I'm not looking for a way to statically define protocols in which > classes participate. Consider an example similar to the one I gave in > my reply to Laurent: Static defining of anything is just a matter of chose, especially in Clojure. For example in Spinoza you have pose-as which changes

Re: CLJOS -> Spinoza, 3X faster than struct-map ;)

2009-02-05 Thread David Nolen
> > The fly in the ointment is: what happens if both > protocols specialize frob? Then Clojure will complain that it can't > tell which method to call. In order to resolve that problem, we must > use prefer-method to declare that one protocol or the other is > preferred. > > But what if I want to

Re: CLJOS -> Spinoza, 3X faster than struct-map ;)

2009-02-05 Thread David Nolen
> > (prefer-method frob ::idea ::thing) > (prefer-method [::runtime-tag1 ::idea] [::runtime-tag1 ::thing]) (prefer-method [::runtime-tag2 ::thing] [::runtime-tag2 ::idea]) Provide a dispatch fn that extracts the runtime tag. --~--~-~--~~~---~--~~ You received th

Re: CLJOS -> Spinoza, 3X faster than struct-map ;)

2009-02-05 Thread David Nolen
Have thoughts about this, will have to collect them, will reply soon. On Thu, Feb 5, 2009 at 9:06 PM, mikel wrote: > > > > On Feb 5, 7:12 pm, David Nolen wrote: > > > I'm not looking for a way to statically define protocols in which > > > classes participate.

Re: CLJOS -> Spinoza, 3X faster than struct-map ;)

2009-02-06 Thread David Nolen
> > Yuck. Instead of defining a method on ::idea, you now must define a > method on [something-that-has-no-meaning-in-context ::idea] (because > the dispatch function must now return a vector, which means the > defmethods must now be called on vector dispatch values...). Sure but as you mention

Tools for parsing arguments

2009-02-06 Thread David Nolen
Is there anything in core or contrib for parsing arguments to a function? Since Clojure fns don't support optional args or even keyword args, is there a standard set of helpers functions to do this? I looked around but I didn't see anything obvious. David --~--~-~--~~~-

Multimethod Reflection Question

2009-02-06 Thread David Nolen
(methods multifn) Returns a hash-map where the keys are vectors if the dispatch values of the multimethods were vectors, weird and cool :) How does one check for the existence of a key in a hash-map if the key is vector? I tried several things and nothing obvious seemed to work. Thanks, David -

Re: Tools for parsing arguments

2009-02-06 Thread David Nolen
Thanks all, Clojure list is the best. On Fri, Feb 6, 2009 at 11:27 AM, Christophe Grand wrote: > > Stuart Sierra a écrit : > > No, but there is a pattern for keyword args: > > > > (defn my-function [& args] > > (let [options (apply hash-map args)] > > ...)) > > > > Then you can call (my-fun

Re: CLJOS -> Spinoza, 3X faster than struct-map ;)

2009-02-06 Thread David Nolen
> > I built 4 iterations of a model/protocol/thing system, accumulating > more requirements for it with each iteration. This discussion has had > the nice side-effect of grooming my requirements into a tidy state > that I can use for reference. What I'm doing next is stripping out all > of the m/p/

Re: Multimethod Reflection Question

2009-02-06 Thread David Nolen
Hmm, for example, this does not work: ([:spinoza/object :spinoza-example-three/serializable] (methods archive)) I get the following exception: java.lang.IllegalArgumentException: Key must be integer even though: (= [:spinoza/object :spinoza-example-three/serializable] (ffirst (methods archive)

Re: Multimethod Reflection Question

2009-02-06 Thread David Nolen
Oops not paying attention you are right. Hash map comes first as the function. Works like a charm. 2009/2/6 Craig Andera > > > (methods multifn) > > > > Returns a hash-map where the keys are vectors if the dispatch values of > the > > multimethods were vectors, weird and cool :) > > How does on

Re: Strapped to the JVM?

2009-02-06 Thread David Nolen
Well considering that the JVM is now open source as well as Clojure itself I wouldn't worry too much :) That said all languages are simply stepping stones, Clojure happens to be a particular elegant one that you might want to pause on for a considerable amount of time, take a deep breath, and enjoy

Re: CLJOS -> Spinoza, 3X faster than struct-map ;)

2009-02-07 Thread David Nolen
> > On the issue list there is a patch for per-defmulti hierarchies, > waiting for Rich's approval. Although it's not predicate dispatch > it might help to bridge the time until the SoC project gives us > predicate dispatch. > > Sincerely > Meikel > > +1 for this, without this the usefulness of mak

Re: ANN: clojure.contrib.error-kit

2009-02-07 Thread David Nolen
Nice I will most definitely be checking this out and get back with thoughts. I've been fearing the need to define custom Java Exception for my code and this looks most useful for people who wish to code as much as possible in pure Clojure. On Fri, Feb 6, 2009 at 9:10 PM, Chouser wrote: > > It's

Re: ANN: clojure.contrib.error-kit

2009-02-08 Thread David Nolen
So far this is fantastic! And I haven't even got around to playing with the restart mechanism :) I'm using it in Spinoza to provide contextual errors (malformed slot list, missing base class etc.). I notice the contrib libraries in general are very good at throwing exceptions so that consumers hav

Re: Clojure, Slime and multiple file projects

2009-02-08 Thread David Nolen
A simple solution is to define a namespace that brings in all of your different files. Is there some reason you can't do things this way? On Mon, Feb 9, 2009 at 8:05 AM, Bradbev wrote: > > Hi folks, > I'm getting to the stage on a Clojure project that I want to start > breaking the code into mul

Re: How to port a mixin to clojure

2009-02-11 Thread David Nolen
There are quite a few ways to do what you're describing (and no particular prescribed way). You want to look at multimethods and tag hierarchies. http://clojure.org/multimethods Tags can have multiple parents. I'm working on a project called Spinoza (search the mailing list for that and CLJOS) w

Re: Generic functions: things, models, and protocols revisited

2009-02-12 Thread David Nolen
dispatch and the Datalog project might meet up soon? Or am I totally wrong? On Thu, Feb 12, 2009 at 12:02 PM, mikel wrote: > > David Nolen and I were recently discussing CLOS and method dispatch. I > implemented such a scheme for my own use. This post is an FYI for > David and a

Re: Generic functions: things, models, and protocols revisited

2009-02-12 Thread David Nolen
> > > > Seems like this kind of dispatch and the Datalog project might meet up > soon? > > Or am I totally wrong? > > I have given it zero thought. Perhaps interesting to pursue? Rich had brought it up in conversations about predicate dispatch. Could greatly help from the performance side of thin

Re: Newbie at macros: Manipulating a vector of bindings

2009-02-14 Thread David Nolen
You can pretty much call anything outside of the quote, in fact all runtime information is available (you have access to anything that was previously read). The main thing to understand is that all parameters passed to your macro are unevaluated. On Sat, Feb 14, 2009 at 10:45 AM, samppi wrote:

Re: Newbie: Separating and grouping the elements in a bunch of vectors

2009-02-15 Thread David Nolen
(map (fn [& rest] (apply vector rest)) [1 2 3] ['a 'b 'c] ["cat" "dog" "bird"]) On Sun, Feb 15, 2009 at 7:16 PM, samppi wrote: > > What would I do if I wanted this: > > [[a0 a1 a2] [b0 b1 b2] ...] -> [[a0 b0 ...] [a1 b1 ...] [a2 b2 ...]] > > I could write a loop, I guess, but is there a nice, id

Re: Newbie: Separating and grouping the elements in a bunch of vectors

2009-02-15 Thread David Nolen
Actually something closer to your exact expression is this: (apply (partial map (fn [& rest] (apply vector rest))) [[1 2 3] ['a 'b 'c] ["cat" "dog" "bird"]]) On Sun, Feb 15, 2009 at 7:42 PM, David Nolen wrote: > (map (fn [& rest] (app

Re: Newbie: Separating and grouping the elements in a bunch of vectors

2009-02-15 Thread David Nolen
t; > > Actually something closer to your exact expression is this: > > > > (apply (partial map (fn [& rest] (apply vector rest))) [[1 2 3] ['a > > 'b 'c] ["cat" "dog" "bird"]]) > > > > On Sun, Feb 15, 2009 at 7:42

error-kit + test-is

2009-02-15 Thread David Nolen
I've been attempting to combine error-kit and test-is, but getting the relation between assert-expr form in test-is and the handle form in error-kit is a bit tricky. Looking at the test-is thrown? example and Chouser's error-kit post on the mailing list I tried something like the following: (defme

Re: ANN: clojure.contrib.error-kit

2009-02-15 Thread David Nolen
Would it be possible to make the arguments to handle be optional? Is this a good or bad idea? It seems to me, in the case of setting up test fixtures that check for raised errors, often you don't care what arguments the error takes. David On Fri, Feb 6, 2009 at 9:10 PM, Chouser wrote: > (kit/

Re: Newbie: Separating and grouping the elements in a bunch of vectors

2009-02-15 Thread David Nolen
> I'm sure it can be done, but it's not clear to me if you have a vector of > vectors > how Stuart's solution would work: > > 1:15 user=> (map vector vecs) ([[:a0 :a1 :a2]] [[:b0 :b1 :b2]]) (apply (partial map vector) [[1 2 3] ['a 'b 'c] ["cat" "dog" "bird"]]) works on a vector of vectors. The

Re: error-kit + test-is

2009-02-15 Thread David Nolen
(raised? *malformed-slots-error* (verify-slots [[:origin 0 0] :width :height]))) Much nicer than those ugly Java Exceptions, no? ;) On a last note, I've found your qualify-sym fn quite handy and have been using it elsewhere ;) On Sun, Feb 15, 2009 at 11:52 PM, Chouser wrote: > >

Re: error-kit + test-is

2009-02-15 Thread David Nolen
Heh not macro, I meant multimethod. Here is the macro that seems to work, any improvements much appreciated ;) > This fails when no error is raised, when the wrong error type is raised, and > I believe it's captures errors which are derived but not the exact error (is > this a weird behavior?). Y

Re: error-kit + test-is

2009-02-15 Thread David Nolen
> I don't quite understand why you got through all that work to get > error-str -- isn't it just (str (qualify-sym error-type))? > > ...and since you then use it only as an arg to 'symbol' or 'str', you > could just use the symbol itself instead of converting it to a string > and back. > If I brin

Re: Fully lazy sequences are coming - feedback wanted!

2009-02-16 Thread David Nolen
> butlast, doall, dorun, doseq, dosync, dotimes, doto, fnseq, gensym, > macroexpand, macroexpand-1, mapcat, nthrest > > -1 Because they are similar to other Lisps I assume. The same reason for println vs print-line. Changing these are a bad idea in IMHO. Breaking the meaning of rest with Common

Re: compiling a GUI app and also: interference of Java's built-in architechture

2009-02-16 Thread David Nolen
On Mon, Feb 16, 2009 at 10:27 AM, rob levy wrote: > So if I am right about these two facts, it seems like Clojure should > include a native way of making applets/applications that both enables the > truly functional style that Clojure is built on, and doesn't require writing > Java to call it (it

Re: error-kit + test-is

2009-02-16 Thread David Nolen
(defmethod assert-expr 'raised? [msg [_ error-type & body :as form]] (let [error-name (qualify-sym error-type)] `(with-handler (do ~...@body (report :fail ~msg '~form ~(str error-name " not raised."))) (handle ~error-type {:as err#} (report :pass ~msg '~for

Re: Idiomatic Way to Write the Following:

2009-02-17 Thread David Nolen
Is using subvec for something like this a bad idea? On Wed, Feb 18, 2009 at 12:38 AM, CuppoJava wrote: > > Hi, > I'm wondering if there's a terser more idiomatic way to write the > following. I want to get a new vector with the specified indexes > removed. I found myself doing this often enough t

Re: Performance of (fn [] ...)?

2009-02-17 Thread David Nolen
new MBP 2.53ghz (defn create-fn [] (fn [] (println "hi"))) (time (dotimes [x 4000] (create-fn))) > "Elapsed time: 1034.409 msecs" Hopefully you don't need 40,000,000 functions in less than a second ;) On Wed, Feb 18, 2009 at 1:16 AM, CuppoJava wrote: > (defn create_fn [] > (fn [] (

Re: Idiomatic Way to Write the Following:

2009-02-17 Thread David Nolen
My point was that you could use subvec to do vector splicing and build your remove function off of that. I'm sure the more experienced Clojurians can chime in on what is the most idiomatic form. On Wed, Feb 18, 2009 at 1:10 AM, CuppoJava wrote: > > Mmm, subvec doesn't quite seem to do the same t

Re: how to learn clojure ?

2009-02-18 Thread David Nolen
Practical Common Lisp is also online and free. Though there are significant differences between the two languages many of the strange and beautiful concepts that Clojure embraces are covered there. Especially dynamic variables, macros, destructuring bind, and multiple dispatch. On Wed, Feb 18, 200

Re: bug affecting clojure.core/bean?

2009-02-18 Thread David Nolen
If I've been following things correct: rest _used_ to force the seq, it does no longer. next forces the seq In my own mind i'm thinking next to mean (return the seq with the next value computed), rest now means just give me the uncomputed remaining values of the seq. On Wed, Feb 18, 2009 at 12:00

Re: how to learn clojure ?

2009-02-19 Thread David Nolen
Of course I beg to differ. The Stuart Halloway's book is fantastic of course, I have it myself. It's absolutely required reading. Stuart does his best to describe the ins and outs of the language while giving a crash course on the Lisp philosophy. And yes Clojure is syntactically different from

Re: how to learn clojure ?

2009-02-19 Thread David Nolen
> > No offense here to Lispers but when I learn a new language, I try to learn > it as it is and I make parallels > and connections with what I know at the moment. Otherwise you end up > learning more than one thing > at the same time and it can get quite confusing. > > If your experience is made m

Re: how to learn clojure ?

2009-02-19 Thread David Nolen
Great list. On Thu, Feb 19, 2009 at 11:39 AM, Stuart Halloway wrote: > > Thanks for the kind words, David. I hope many people will like > Programming Clojure and find it useful. > > Clojure has a *ton* of goodness in it. I think many of the chapters in > Programming Clojure book could usefully b

Re: Error Handling paradigms in Clojure

2009-02-19 Thread David Nolen
Check out Chouser's error-kit in clojure-contrib. It borrows from the condition/restart system of Common Lisp. On Thu, Feb 19, 2009 at 5:25 PM, levand wrote: > > So, my project is reaching a sufficient level of complexity where I > really need good error tracking - when something goes wrong, I n

Re: structmap instance test

2009-02-21 Thread David Nolen
This not hard to implement. This exactly what Spinoza does. Feel free to lift any of my code. On Sat, Feb 21, 2009 at 9:08 AM, Mark Volkmann wrote: > > Is there a way to test whether a given object is an instance of a > given structmap? > For example, > > (defstruct dog-struct :name :breed) > > (

Re: structmap instance test

2009-02-21 Thread David Nolen
For example, with Spinoza: (def my-circle (make-instance circle)) (instance-of? my-circle circle) ; > true circle is just a struct. On Sat, Feb 21, 2009 at 2:09 PM, David Nolen wrote: > This not hard to implement. This exactly what Spinoza does. Feel free to > lift any of my code.

Re: generic functions update

2009-02-21 Thread David Nolen
I'm interested as well. On Sat, Feb 21, 2009 at 3:03 PM, Dan Larkin wrote: > > On Feb 21, 2009, at 2:23 PM, mikel wrote: > > > > If there's interest in having models and generic functions in contrib, > I'll get a contributor agreement to Rich. > > > Aye there is, from me at least. > > > > > > --

Re: Clojure Naming Conventions

2009-02-21 Thread David Nolen
+name+ is also in line with Common Lisp patterns http://www.cliki.net/Naming%20conventions On Sat, Feb 21, 2009 at 4:07 PM, Luc Prefontaine < lprefonta...@softaddicts.ca> wrote: > In our software, we use uppercase or +name+ as constant names. > Both Java and RUBY use uppercase, I think it's more

Re: Clojure Naming Conventions

2009-02-21 Thread David Nolen
The fact that the Clojure data structures are immutable and that some of those data structures might be used logically constants are two separate concerns. When reading Clojure code, we've already internalized the fact that the data structures are immutable. Using a naming convention for a consta

Re: Clojure Naming Conventions

2009-02-21 Thread David Nolen
Hagelberg wrote: > > David Nolen writes: > > > The fact that the Clojure data structures are immutable and that some > > of those data structures might be used logically constants are two > > separate concerns. > > I don't understand what this means. What'

Re: dotimes suggestion

2009-02-21 Thread David Nolen
(defmacro again [n & body] `(dotimes [~'_ ~n] ~...@body)) (again 3 (println "Ho")) On Sat, Feb 21, 2009 at 5:51 PM, samppi wrote: > > For now, I do: > (dotimes [_ 3] (print "Ho")) > > But I also think it would be a nice, natural addition. > > On Feb 21, 3:07 pm, Timothy Pratley wrote: > > +1

Re: arguments to dissoc and select-keys

2009-02-21 Thread David Nolen
dissoc is like assoc. If you want to use collections with dissoc you can always use apply. It's not too much to type: (def my-map {:first "Bob", :middle "Joe", :last "Smith"}) (apply dissoc my-map [:first :middle]) On Sat, Feb 21, 2009 at 5:58 PM, samppi wrote: > > Allowing dissoc and select-ke

Re: arguments to dissoc and select-keys

2009-02-21 Thread David Nolen
want? On Sat, Feb 21, 2009 at 6:24 PM, Mark Volkmann wrote: > > On Sat, Feb 21, 2009 at 5:07 PM, David Nolen > wrote: > > dissoc is like assoc. > > If you want to use collections with dissoc you can always use apply. It's > > not too much to type: > > (

Re: arguments to dissoc and select-keys

2009-02-21 Thread David Nolen
> > On Feb 21, 5:58 pm, samppi wrote: > > Allowing dissoc and select-keys to accept both keys as arguments and > > as a collection would be nice, and backwards compatible. > > Nope - Collections can be keys. Ah the power of Clojure ;) The fact that (almost?) anything can be a key is a pretty lib

Re: Clojure Naming Conventions

2009-02-21 Thread David Nolen
Thanks for the points. What I was thinking, was that for things like π, in Clojure (as in CL), perhaps it makes to sense to mark it like so: +pi+ On Sat, Feb 21, 2009 at 8:59 PM, Chouser wrote: > > On Sat, Feb 21, 2009 at 5:36 PM, David Nolen > wrote: > > My point is simp

  1   2   3   4   5   6   7   8   9   10   >