Re: (newbie) How to access a Java class's field?

2010-04-06 Thread Alex Osborne
Gregg Williams writes: > I'm currently stuck on how to translate "aNode.setPaint(Color.RED);" The interop syntax is described here: http://clojure.org/java_interop Color.RED is a static field, so we use the Classname/staticField syntax, so Color/RED. Combining that with (.instanceMember insta

(newbie) How to access a Java class's field?

2010-04-06 Thread Gregg Williams
Hi-- I'm continuing on my path to learning how to use Clojure with the graphics library Piccolo2D (http:// www.piccolo2d.org) by re-implementing some of Piccolo2D's sample programs. This time, I'm working on the "Building the Interface" program described at http://www.piccolo2d.org/learn/interface.

Re: A syntax question: positional & keyword

2010-04-06 Thread Sophie
On Apr 6, 7:03 pm, ataggart wrote: > See: > > http://richhickey.github.com/clojure-contrib/def-api.html#clojure.con... Ah, thank you (all). Will this be in 1.2? Is run-time cost expected to be minor, and will passing unrecognized keys be an error? -- You received this message because you are s

Re: Mutually-referencing structures

2010-04-06 Thread Sophie
I would really love to see (clearly by someone much smarter than I :) an insightful summary of these kinds of concept-heavy discussions, "stickied" or "FAQd" or even "book'd" somewhere. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this g

Re: let's all link to the "getting started" pages!

2010-04-06 Thread Giancarlo Angulo
will do! = angol = -|-^...@^_^, =|+^_^X++~_~,@- "The only thing worse than a hopeless romantic is a hopeful one" Magbasa bago Mamuna. Mag-isip bago mambatikos Without Truth there is no Justice, Without Justice, there is Tyranny Semper fi Proof of Desire is Pursuit www.onthe8spot

Re: A syntax question: positional & keyword

2010-04-06 Thread ataggart
See: http://richhickey.github.com/clojure-contrib/def-api.html#clojure.contrib.def/defnk On Apr 6, 2:25 pm, Sophie wrote: > Please don't misunderstand this post - it is not asking for a change > of syntax, just trying to understand something. > > Clojure has chosen positional parameters (just li

Re: A syntax question: positional & keyword

2010-04-06 Thread Michael Gardner
On Apr 6, 2010, at 6:08 PM, Sophie wrote: > Don't you think > - fixed-order named parameters > could (should?) be a separate issue from > - optional, any-order, named parameters > ? I don't see the advantage of fixed-order named parameters over keyword parameters. Note that you can require cer

Re: Mutually-referencing structures

2010-04-06 Thread Michael Gardner
On Apr 6, 2010, at 9:01 AM, Laurent PETIT wrote: >* BUT : isn't the real problem that one will not content > [him/her]/self with playing with in-memory data ? One will want to > make the data persistent (outside-of-process, aka > storage-persistance). And with this kind of problem, one will ha

Re: A syntax question: positional & keyword

2010-04-06 Thread Sophie
Don't you think - fixed-order named parameters could (should?) be a separate issue from - optional, any-order, named parameters ? ;; :x :y are fixed order, named, while :a :b are optional, named (defn foo [:x :y & {:keys [a b]] [x, y, a, b]) (foo :x 1 :y 2) => [1 2 nil nil] (foo :x 1 :a 2) =

Re: A syntax question: positional & keyword

2010-04-06 Thread Sophie
On Apr 6, 5:23 pm, Stuart Halloway wrote: > Have you seen destructuring of rest args in the current master branch? > > (defn foo [& {:keys [a b c]}] [a b c]) > > (foo :a 1 :c 3) > => [1 nil 3] > > With this last bit of sugar in place I am extremely happy with   > Clojure's arg handling. Hmmm. Loo

Re: A syntax question: positional & keyword

2010-04-06 Thread Sophie
On Apr 6, 4:46 pm, Jarkko Oranen wrote: > problem is that they also make some very common functional patterns > cumbersome: most notably function application (ie. apply), > composition, and higher-order functions. I don't think it should be either-or (and positional would be needed anyway to call

Re: A syntax question: positional & keyword

2010-04-06 Thread Stuart Halloway
Have you seen destructuring of rest args in the current master branch? (defn foo [& {:keys [a b c]}] [a b c]) (foo :a 1 :c 3) => [1 nil 3] With this last bit of sugar in place I am extremely happy with Clojure's arg handling. Please don't misunderstand this post - it is not asking for a ch

Re: let's all link to the "getting started" pages!

2010-04-06 Thread ataggart
Can we scavenge or link to the stuff in wikibooks: http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started In particular, getting started simply by installing clojure onto the system (irrespective of the various dev environment configs). Being able to have co-workers simply run "sudo por

Re: A syntax question: positional & keyword

2010-04-06 Thread Jarkko Oranen
On Apr 7, 12:25 am, Sophie wrote: > Just curious >   - what folks think of fixed-positional-keyword params >   - whether it was considered for Clojure I don't know for certain whether Rich ever considered smalltalk-style parameters, but I doubt it. I do like them, though; in Objective-C and Sma

Re: Set as function

2010-04-06 Thread Sophie
On Apr 6, 12:16 am, Alex Osborne wrote: > Calling the set as if it is a fn is a short-hand for "get", that is > retrieving an element from the set. Why would you want to do this, when > to look it up you need to know what element is?  Sets are based on > value-equality not reference-equality.  T

A syntax question: positional & keyword

2010-04-06 Thread Sophie
Please don't misunderstand this post - it is not asking for a change of syntax, just trying to understand something. Clojure has chosen positional parameters (just like for Lisp, C, C++, Java, Ruby, Python, Prolog, ...) Smalltalk composes a full method name from a prefix-name + named parameters.

Re: Problem with installation of swank-clojure without elpa...

2010-04-06 Thread Preecha P
Well, as I said in previous post, I got stringp error with advice on slime-read-interative-args. My guess is that there is something wrong in (aput 'slime-lisp-implementations 'clojure (list (swank-clojure-cmd) :init 'swank-clojure-init))) in swank- clojure.el I think I might try to look at it aga

Re: clojure and emacs. again.

2010-04-06 Thread jney
my bad. I didn't find swank-clojure on ELPA and tried to install it manually. now it works. thanks. On Apr 3, 6:20 am, Phil Hagelberg wrote: > On Fri, Apr 2, 2010 at 12:19 PM, jney wrote: > >  I'm a newbie in clojure and inemacstoo. I got this message error > > while launching Slime : > > > Debu

Re: defprotocol's support for variadic arguments seems broken

2010-04-06 Thread Zach Tellman
You're right, that does explain it. I assumed that variadic arguments were supported, but maybe I was wrong. Can anyone confirm whether or not this was ever intended to work? On Apr 6, 2:32 am, Jarkko Oranen wrote: > On Apr 6, 8:16 am, Zach Tellman wrote: > > > Possibly this fall out from the

Re: let's all link to the "getting started" pages!

2010-04-06 Thread Stuart Halloway
Google's top hit for "clojure getting started" is http://clojure.org/getting_started -- should that page be replaced or at least simplified and include a prominent link to the assembla page? --Chouser http://joyofclojure.com/ Yes. The page is now somewhat simplified and has a link to the asse

Re: let's all link to the "getting started" pages!

2010-04-06 Thread Phil Hagelberg
On Tue, Apr 6, 2010 at 9:13 AM, Chouser wrote: > Google's top hit for "clojure getting started" is > http://clojure.org/getting_started -- should that page be > replaced or at least simplified and include a prominent link to > the assembla page? I vote for an HTTP-level redirect if that's possibl

Re: let's all link to the "getting started" pages!

2010-04-06 Thread Chouser
On Tue, Apr 6, 2010 at 4:55 PM, Stuart Halloway wrote: > People getting started with Clojure have struggled to find an up-to-date > source for information on getting their editor of choice up and running. > This is unfortunate, since there is good support in a bunch of different > editors. > > The

Re: let's all link to the "getting started" pages!

2010-04-06 Thread Laurent PETIT
Done ! * Replaced ccw install instructions with a link to Eclipse/Counterclockwise page ! * Added an "Related projects" link in the counterclockwise home page Thanks again Stuart for having done such a great work ! -- Laurent 2010/4/6 Stuart Halloway : > People getting started with Clojure

Re: Trying to set emacs for some clojure coding

2010-04-06 Thread Phil Hagelberg
2010/4/6 Pelayo Ramón : > Installed with ELPA clojure-mode and swank-clojure. But slime couldn't > find the swank-clojure.jar so I  downloaded it and setted the > classpath in .emacs to the directory where I stored it along with > clojure.jar and clojure-contrib.jar > > the emacs line is: > > (setq

let's all link to the "getting started" pages!

2010-04-06 Thread Stuart Halloway
People getting started with Clojure have struggled to find an up-to- date source for information on getting their editor of choice up and running. This is unfortunate, since there is good support in a bunch of different editors. The "Getting Started" page on Assembla (http://www.assembla.com

Re: Mutually-referencing structures

2010-04-06 Thread Per Vognsen
On Tue, Apr 6, 2010 at 10:43 PM, Douglas Philips wrote: > On 2010 Apr 6, at 10:59 AM, Christophe Grand wrote: >> >> The cycles are gone but the identity john-doe aand its curren-state are >> still conflated so you get the same problem: > > Thus, since simple trees have the exact same issues, circu

Re: Mutually-referencing structures

2010-04-06 Thread Douglas Philips
On 2010 Apr 6, at 10:59 AM, Christophe Grand wrote: The cycles are gone but the identity john-doe aand its curren-state are still conflated so you get the same problem: Thus, since simple trees have the exact same issues, circularity is not the problem. Really, to me the problem isn't cre

Re: Mutually-referencing structures

2010-04-06 Thread Per Vognsen
On Tue, Apr 6, 2010 at 9:59 PM, Christophe Grand wrote: > Btw, to some extent, one can create cyclic data-structures in Clojure (only > lazyseqs though -- unless you implement your own map or use lazy-map etc.) : > user=> (defn cyclic-seq [coll] (let [s (promise)] @(deliver s (lazy-cat coll > @s))

Re: Mutually-referencing structures

2010-04-06 Thread Christophe Grand
On Tue, Apr 6, 2010 at 3:43 PM, Douglas Philips wrote: > (def john-doe {:name "John Doe" :email "j...@doe.com"}) > > (def account {:identity john-doe :balance 100} ) > > (assoc john-doe :email "john.doe at gee mail.com") > > Now the account contains old/obsolete data and no cycles are needed to

Re: Mutually-referencing structures

2010-04-06 Thread Christophe Grand
On Tue, Apr 6, 2010 at 3:41 PM, Sophie wrote: > On Apr 6, 8:09 am, Christophe Grand wrote: > > > > Let say one can write: > > (def john-doe {:name "John Doe" :email "j...@doe.com" :account {:owner > > # :balance 1000}}) > > At this point the cyclic structure is a consistent value. True. >

Re: Mutually-referencing structures

2010-04-06 Thread Laurent PETIT
The question of the OP was also a practical one : "is either Clojure or functional not a good match?" Honestly, I don't know the answer for sure, because: * there is still no (widely known ?) utilities to manipulate things easily. There were attemps like the one by Jeffrey Streizhem in clojure

Re: Mutually-referencing structures

2010-04-06 Thread Douglas Philips
On 2010 Apr 6, at 9:09 AM, Christophe Grand wrote: On Mon, Apr 5, 2010 at 4:54 PM, Douglas Philips wrote: Immutability is orthogonal to reference-ness. There is nothing "wrong" with having immutable cyclic graphs of values. There is something wrong with immutable cyclic data structures: an

Re: Mutually-referencing structures

2010-04-06 Thread Sophie
On Apr 6, 8:09 am, Christophe Grand wrote: > > Let say one can write: > (def john-doe {:name "John Doe" :email "j...@doe.com" :account {:owner > # :balance 1000}}) At this point the cyclic structure is a consistent value. As long as updates create new values that match the domain invariants, why

Re: Mutually-referencing structures

2010-04-06 Thread Christophe Grand
On Mon, Apr 5, 2010 at 4:54 PM, Douglas Philips wrote: > Immutability is orthogonal to reference-ness. > There is nothing "wrong" with having immutable cyclic graphs of values. > There is something wrong with immutable cyclic data structures: an undefined (or unexpected) behaviour on update beca

Re: Trying to set emacs for some clojure coding

2010-04-06 Thread Pelayo Ramón
Finally i did it. Installed with ELPA clojure-mode and swank-clojure. But slime couldn't find the swank-clojure.jar so I downloaded it and setted the classpath in .emacs to the directory where I stored it along with clojure.jar and clojure-contrib.jar the emacs line is: (setq swank-clojure-ext

Re: defprotocol's support for variadic arguments seems broken

2010-04-06 Thread Jarkko Oranen
On Apr 6, 8:16 am, Zach Tellman wrote: > Possibly this fall out from the latest commit requiring an explicit > 'this' reference (ba6cc3b), I haven't checked any versions but the > most recent. > > user> (defprotocol Protocol (f [a b & c])) > Protocol > user> (def p (reify Protocol (f [a b & c] [a

Re: holding types or units in metadata vs pattern matching

2010-04-06 Thread Konrad Hinsen
On 3 Apr 2010, at 10:40, Per Vognsen wrote: By the way, I wanted to emphasize that I don't think this would be an ideal use of metadata even if your use case was supported. But the reason metadata is so tempting is that you want frequencies and distances to be treatable as numbers and so on. If

Re: Set as function

2010-04-06 Thread Alex Osborne
B Smith-Mannschott writes: >> Calling the set as if it is a fn is a short-hand for "get", that is >> retrieving an element from the set. Why would you want to do this, when >> to look it up you need to know what element is? > > Since you asked: canonicalization. I've wanted this on occasion (in >