Re: Feature idea: meta-macros

2010-09-15 Thread Richard Newman
My suggestion is inline with other commenters: use binding. If that doesn't satisfy you, consider using or writing a preprocessor like m4. -- 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

Re: JSON lib of choice?

2010-09-08 Thread Richard Newman
The c.c.json lib was rewritten in January by Stuart Sierra to incorporate the missing features present in Dan Larkin's lib, and make it faster. This was when it switched from c.c.j.read/write to c.c.json. I switched to c.c.json around that time, and I've been happy with it as a substitute.

Re: New Primitive data types (equal branch) - impact on optimized code.

2010-06-24 Thread Richard Newman
Mark, I don't disagree with your message as a whole, but: Once you start using mutable arrays and type hinting every single variable, why aren't you just using Java? The argument I've heard is this: there are two ways to get a fast program in a slow-by-default language. The first is Pytho

Re: Enhanced Primitive Support

2010-06-21 Thread Richard Newman
user=> (defn fac [n] (loop [n n r 1] (if (= n 1) r (recur (dec' n) (*' r n) NO_SOURCE_FILE:5 recur arg for primitive local: r is not matching primitive, had: Object, needed: long Auto-boxing loop arg: r #'user/fac user=> (fac 40) 8159152832478977343456112695961158942720N Might I sugg

Re: Enhanced Primitive Support

2010-06-20 Thread Richard Newman
I agree with Nicolas. An overflow says "you did math that doesn't work with basic numbers" and pretty much everybody coming to computers via any path may encounter that from time to time. It's basic stuff. There's a distinction between knowing that something can occur, and expecting to have to

Re: Enhanced Primitive Support

2010-06-17 Thread Richard Newman
This imposes too high a burden on any programmer who cares about safety. Don't buy it. That's the whole point of BigInt contagion. If fact and foo are correctly written this will work. It only takes one library to screw up, and the whole stack falls down. Screwing up can occur because of o

Re: Enhanced Primitive Support

2010-06-17 Thread Richard Newman
... which, I acknowledge, might be very hard work, possibly involving every such function having 2 polymorphic variants, one generic boxed form and one unboxed form, automatically selected and call-site-cached like OO dispatch. That's pretty much what Common Lisp compilers do. The compiler

Re: Enhanced Primitive Support

2010-06-17 Thread Richard Newman
I don't want to commit to a full-fledged response on this issue (yet), but: On the other hand, the mental burden for someone who wants BigInts in the new system is very low - you'll get a trivial to track exception. Assuming that I understand your implication (that ArithmeticExceptions

Re: reacting to an article on clojure protocols, ruby monkey patching, and safety

2010-06-03 Thread Richard Newman
The surface of the problem is reduced because of namespacing: two different "fold" methods (with different semantics) from two protocols won't clash. Plus if there are two extensions of the same protocol to the same type, they should be rather equivalent since they satisfies the same semantics.

Re: Understanding sequence abstraction

2010-06-01 Thread Richard Newman
Because seq is defined as returning nil for an empty sequence. The only way to find that out for a lazy sequence is to realize the first element. I'm not sure if that answers why seq should realize the first element. Even by what you say, only if I wanted to find if my LazySeq was nil should I

Re: Understanding sequence abstraction

2010-05-30 Thread Richard Newman
1. In case coll is a LazySeq why does (seq coll) realize its first element? I thought seq just did a type conversion and all of list, vector .. etc implemented Seqable or something. Because seq is defined as returning nil for an empty sequence. The only way to find that out for a lazy sequenc

Re: API for posting multipart/form-data

2010-05-09 Thread Richard Newman
Anyone know of a Clojure library (or wrapper) for posting HTTP multipart/form-data? Do you mean submitting or receiving? If you mean submitting, clj-apache-http will allow you to do it. Simply create any Apache HttpEntity and pass it as the value of

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread Richard Newman
(+ today (- 14 remind-prior)) => 2 weeks from today - a fixed remind before days => a date when I am going to be reminded for an event 2 weeks from today I'm deeply suspicious of such a behaviour. Why would + on a date mean adding days? Frink (as one example) resolves this through unit track

Re: deftype and final classes

2010-04-28 Thread Richard Newman
What are you going to do about: default public constructor? The JAX-WS tools don't really care if javac generates a default constructor or if Clojure does. The deftype constructor with no fields defined is: public com.example.FooBarService(); which -- assuming it calls super() and ini

deftype and final classes

2010-04-27 Thread Richard Newman
Further to IRC conversations: I'm attempting to generate a JAX-WS service using Clojure. The main stumbling block was annotations; that's been removed, so I gave it a shot using deftype. My first strike works code-wise, so I sent it to the list earlier today. When it comes to actually inte

Example JAX-WS server code using annotation support

2010-04-27 Thread Richard Newman
I just spent a little time figuring this out, so I figured I'd share. This example shows how to hang annotations onto Clojure code to replicate the equivalent Java web service code produced by NetBeans. It includes exported parameter names, types, and operat

Re: Datatypes and Protocols update

2010-04-24 Thread Richard Newman
Neither of those attributes reveal information about the implementation of the objects in question. They both reveal information about the state that some client could find useful. They are both values that, if not directly available from the object should be calculated by the object, as calculati

Re: Annotations

2010-04-23 Thread Richard Newman
I've started adding some support for Java annotations, as of this commit: Fantastic! I'm just about to do some JAX-WS stuff (which requires annotations), so this is a welcome change. The syntax looks no worse than Java's, so no comment on that... -- You received this message because you are

Re: questions about clojure's core library organization

2010-04-18 Thread Richard Newman
Something like the 'for' macro (if it is thought of as a non-general monad) can be implemented in terms of reduce. Is there a reason this isn't so? I can think of two: * filter and map are lazy. Implementing every? and some? in those terms would needlessly introduce lazy sequences to the

Re: Set as function

2010-04-05 Thread Richard Newman
filter works just as well with a function that returns true and false, so that's not a particularly good example. Heh, that's true. Should have re-read :) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@

Re: Set as function

2010-04-05 Thread Richard Newman
Why this behavior? It's useful: e.g., you can use a set as a filter. user=> (filter #{2 3 4 5} (range 1 10)) (2 3 4 5) If you want your alternative, use contains?: user=> (contains? #{true false} false) true -- You received this message because you are subscribed to the Google Groups "Clojur

Re: formatting hex string

2010-03-31 Thread Richard Newman
ur=> (map #(Integer/parseInt % 16) ["ff43" "0032"]) (65347 50) ...that yields, not shorts. At the risk of diverging from the question: why are you concerned with the specific type of the number? You realize that Java doesn't allocate less memory for a short than for an int, right? The on

Re: formatting hex string

2010-03-31 Thread Richard Newman
"ff43" "0032" ... (you get the idea) I want to use clojure's short form on them, but short expects an authentic hex input, e.g. (short 0xff43) it will not accept something like (short "0xff43") Any suggestions would be gratefully appreciated!! user=> (map #(Integer/parseInt % 16) ["ff43" "00

Re: copying structures

2010-03-28 Thread Richard Newman
Is this the common way to do it? (def sister (assoc brother :name "Cindy")) If you want to change the value of one key in a map, yes. (In this example it looks weird, of course.) If you want to create a new map by taking only some values from another map: user=> (def sister (assoc (sele

Re: copying structures

2010-03-28 Thread Richard Newman
Is there a shorter way to do this? See my earlier message. dissoc and assoc will do what you want. (def brother {:name "Gary" :address "..." :mother "Mary" :father "John"}) (def sister (assoc brother :name "Cindy")) user=> sister {:name "Cindy", :address "...", :mother "Mary", :father "John

Re: copying structures

2010-03-28 Thread Richard Newman
This may be really basic. So much so that it's hard to find on the internet, but is there something like a copy constructor in clojure, where I can copy everything in a structure except one or two keys? Maybe something like struct-map, but fills in the other variables not supplied by another data

Re: convert hex string to number

2010-03-27 Thread Richard Newman
Is there a function for converting these strings into normal hex or numbers?? I tried num, but it didn't work. user=> (read-string "0x44") 68 Safer: (defn hex->num [#^String s] (binding [*read-eval* false] (let [n (read-string s)] (when (number? n) n You could also us

Re: converting long string to number

2010-03-25 Thread Richard Newman
In those hills yonder in the lands of Common Lisp, it's usually considered good practice to blast the entire read table save for what you need when you deal with untrusted data. Barring that, a better option might be a more modular reader: read-number, read-symbol, etc. Clojure doesn't have a us

Re: converting long string to number

2010-03-25 Thread Richard Newman
Of course, it might also pose a bit of a security threat: user> (read-string "#=(println \"I OWN YOU NOW!\")") I OWN YOU NOW! nil :) user=> (binding [*read-eval* false] (read-string "#=(println \"I OWN YOU NOW!\")")) java.lang.RuntimeException: java.lang.Exception: EvalReader not allowed w

Re: Why I have chosen not to employ clojure

2010-03-21 Thread Richard Newman
To be successful however Clojure needs to adopt 'mainstream' values - introduce just one 'different' thing i.e. the language, rather than expecting people to adopt both the language, and a different development environment / toolchain e.g. leiningen etc (which IMO is classic NIH). I think

Re: Translation from Common Lisp 1

2010-03-18 Thread Richard Newman
But using symbols for something like this is a bit contrived anyway. Maybe, but I've seen it in other Common Lisp books/tutorials before. e.g. I'm sure PAIP was one of them. Part of the motivation is that CL symbols always compare with EQ and EQL, whilst strings are not required to do so:

Re: help with infinite loop: break and examine stack? dynamic tracing? circular lists?

2010-03-17 Thread Richard Newman
It'd still be even nicer to be able to get some info without quitting, but this is definitely an improvement! The JVM shouldn't quit when it gets a SIGQUIT. That's just the signal name. You might find this useful: http://www.unixville.com/~moazam/stories/2004/05/18/debuggingHangsInTheJvm.h

Re: help with infinite loop: break and examine stack? dynamic tracing? circular lists?

2010-03-17 Thread Richard Newman
An alternative: Is there a way to watch my running Clojure program without breaking it, that is to observe the recent call history (of my own definitions, either all of them or specifically marked ones) from outside the process? If you send a SIGQUIT to the java process, it will print the t

Re: A Tour of Enlive

2010-03-14 Thread Richard Newman
I just finished up a fairly involved tour of Enlive. Great stuff, thank you for sharing. If I have any comments as I walk through, I'll send them along. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@

Re: Leiningen, Clojure and libraries: what am I missing?

2010-03-12 Thread Richard Newman
I'm confused. Why do we need symlinks or copies at all? Why can't we just tell clojure where it's supposed to find a given projects dependencies? I'm sure the answer involves some mumbo-jumbo about classpath and what not, but surely there has to be a better alternative than whatever maven/l

Re: quote versus backquote

2010-03-11 Thread Richard Newman
Is there a good reason for this behavior? What is the rationale behind it? Read this. http://clojure.org/reader#syntax-quote -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that pos

Re: Leiningen, Clojure and libraries: what am I missing?

2010-03-10 Thread Richard Newman
repos $ du -hc $(ls */lib/*.jar) | fgrep total 291Mtotal Cost (on standard disks): < 5 cents. Sorry, that's tiny. It's even less than 0.5% of the small SSD I have in my laptop. Seriously, this is just premature optimization. You're seriously fine with every single Leiningen-based proj

Re: Leiningen, Clojure and libraries: what am I missing?

2010-03-10 Thread Richard Newman
What benefit does this have aside from a tiny saving in disk space? Not that tiny when you multiply it across the dozens of projects on your hard drive. repos $ du -hc $(ls */lib/*.jar) | fgrep total 291Mtotal Add to that the size of the Maven repo itself. Symlinks are nice. * you c

Re: Clojure Implementation issues that may affect performance?

2010-03-09 Thread Richard Newman
I suspect that on recursion If you use plain function-calling recursion, yes. If you use (loop ... recur...) then (IIRC) locals are not boxed (as well as saving stack). Also bear in mind that JIT will come into play here; after a few tens of thousands of arithmetic ops, the common path wil

Re: monkeypatching in clojure

2010-03-08 Thread Richard Newman
Yeah I'm not talking about OO vs FP but about the function-centric approach that Lisps and languages like Haskell take as opposed to the object, or noun-centric approach of languages like Java or Ruby. Interesting reading from 2006: http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-o

Re: Some basic guidance to designing functional vs. state parts of app

2010-03-03 Thread Richard Newman
For a single value there seems to be little reason to adopt refs, though I've often wondered why Stuart Halloway's book gives an example updating a single ref of messages for a chat application. I seem to recall atoms being the last reference type to be introduced. They might not have existed

Re: bug: clojure.contrib.json should not default to use keywords.

2010-03-01 Thread Richard Newman
Actually, HTTP headers are case-insensitive, so you can't really trust a regular map of keywords for all purposes. You'd have to reify a maplike construct (maybe a clojure.lang.IAssociative?) to take care of case differences. No idea if ring or compojure does this already yet. I don't see why yo

Re: newbie question: Please help me stop creating constructors

2010-03-01 Thread Richard Newman
but complexity of such expressions quickly grows as dependencies between variables become more complex. Is there any technique/framework for handling such calculations automatically? I have a vague impression that this is what logic programming languages are about. How would one implement such cal

Re: newbie question: Please help me stop creating constructors

2010-03-01 Thread Richard Newman
I'd like to note that if you do this, you might just as well use the - function directly. Of course; this was merely for the sake of illustration. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegro

Re: newbie question: Please help me stop creating constructors

2010-02-28 Thread Richard Newman
So I rewrote the whole kit and kaboodle. My understanding of your mail led me to take the approach of defining functions who take as arguments the invariant values and who output functions that take variant values. For example: I'm not sure how much functional programming experience you have, bu

Re: bug: clojure.contrib.json should not default to use keywords.

2010-02-28 Thread Richard Newman
For an example outside of JSON: recently Compojure changed how it works so the HTTP request properties are all converted to keywords by default. I can see the appeal, but now anyone using Compojure has the increased incidental complexity of possible keyword violations. Imagine if you were integrat

Re: difference between if/when

2010-02-28 Thread Richard Newman
I'm still undecided whether to shake this habit: , | (defmacro unless [pred & body] | `(when-not ~pred ~...@body)) ` Heh. I still think that "unless" is a better name than "when-not", but I've migrated pretty easily. This is an interesting point, though -- does "unless" communicat

Re: difference between if/when

2010-02-28 Thread Richard Newman
hmm...I don't understand why clojure when and if simultaneously? What is the diffirences between them and when I should use one instead another one? Disregarding all of the practical benefits (such as an implicit do): languages often incorporate apparently redundant constructs because one of

Re: browsing clojure source code

2010-02-23 Thread Richard Newman
Can anyone suggest how best to browse the source code for clojure? I've downloaded the clojure-read-only tree and would like to bounce around in it using something like find-tag. How does one create an emacs tags file for java and clojure, or, how does one load it into eclipse so that ecl

Re: Need advice on best concurrency model

2010-02-21 Thread Richard Newman
I'd be very thankful if I could get some advice here, sicne I am running out of ideas. You might be doing something wrong with the way you're arranging refs. I'll let others comment on that. One observation, though: parallelization doesn't always help. pmap runs your tasks on several thre

Re: newbie question: Please help me stop creating constructors

2010-02-19 Thread Richard Newman
I have to think that's preferable to submitting 30+ arguments to rent and sell. Or were you suggesting a different approach? The different approach only works with a different approach :) The way you've structured run-calculator, using the map is best, because 30 arguments is crazy. Your n

Re: newbie question: Please help me stop creating constructors

2010-02-18 Thread Richard Newman
Richard Newman has with utmost patience (THANK YOU!), I believe, been trying to gently beat into my head from the start. No problem. Happy to help. Richard, your mails were extremely clear (and at this point I've read them all at least 2 or 3 times) but my head was so far away fro

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread Richard Newman
I don't expect anyone to actually read, rather I was hoping some folks who know Clojure might just glance at it to get the rhythm of the math. It's the pattern, not the detail that matters. How should what is essentially a monster algebra equation be codified in Clojure? I looked at your PDF. Y

Re: newbie question: Please help me stop creating constructors

2010-02-17 Thread Richard Newman
I'm just trying to figure out what the right pattern is because the fact that I'm forced to make the derived values into thunks feels really wrong but I honestly don't know what's right in the context of Clojure. I don't think you're using the term "thunk" correctly. A thunk is (usually) a no-a

Re: newbie question: Please help me stop creating constructors

2010-02-16 Thread Richard Newman
It seems however that the consensus of the group based on what I've said so far is to pass around state in a structmap. Not necessarily a struct-map. Just a map. This is nice in that it makes each function completely self contained (e.g. no external references). It's unfortunate in that it now

Re: newbie question: Please help me stop creating constructors

2010-02-16 Thread Richard Newman
For the method tax_deductible_expenses to run it ends up requiring 19 user defined values. That's a whole lot of arguments to pass into a function. Obviously I could wrap them up in a StructMap but then I get expressions like (+ 1 (args :B)) which doesn't seem much better than (+1 (B)). Pass

Re: newbie question: Please help me stop creating constructors

2010-02-15 Thread Richard Newman
So imagine the user submits a value A. I will have a value B whose definition will be something like (+ 1 A) (yes, more complex in reality, but you get the idea). In Java, everything's an object, so you go about this by defining some class. All of its private members, its constructors, and it

Re: clojure-dev: #55: clojure.contrib.sql expects *err* to be a PrintWriter Ticket updated - Resolution?

2010-02-14 Thread Richard Newman
Why log anything at all? The relevant information is (or can be) stored in the exception. I don't want to see clojure contrib embrace the catch/log/re-throw idiom. I couldn't find any other code in contrib that follows this approach. Ain't my code. I was simply saying I prefer libraries to pr

Re: contrib.sql with postgresql is really a problem

2010-02-14 Thread Richard Newman
My first problem was to save a timestamp value. I defined a field in pgsql as "timestamp" and wasn't able to store a simple timestamp value because I got type mismatch errors and it also displayed the statement which I could copy and execute successfully in pgadmin which confused me a lot. I see

Re: clojure-dev: #55: clojure.contrib.sql expects *err* to be a PrintWriter Ticket updated - Resolution?

2010-02-14 Thread Richard Newman
Patching swank might be appropriate but doesn't address several incorrect assumptions made by c.c.sql: 1) *err* and *out* promise to implement java.io.Writer in the documentation not java.io.PrintWriter. Calling .println on *out* or *err* is not appropriate. I started in the same mental place

Re: clojure-dev: #55: clojure.contrib.sql expects *err* to be a PrintWriter Ticket updated - Resolution?

2010-02-13 Thread Richard Newman
The above thread suggests defining *err* as a PrintWriter instead of as a Writer. Has this been patched, and is it official? If so, I'll patch clojure-swank to use PrintWriter. If not, I'll patch clojure.contrib.sql to not use println. I patched swank-clojure: diff --git a/src/swank/core/ser

Re: Help me make this more idiomatic clojure

2010-02-11 Thread Richard Newman
You can use get on Properties. Use .foo for method calls. Use literal vec syntax, not list. Use or for conditional branches instead of (if foo foo ...). Untested: (defn obtain-local-connection [vmid] (let [vm (VirtualMachine/attach vmid) props (.getSystemProperties vm) acqu

Re: Simple clojure and contrib install, with SLIME ... ?

2010-02-11 Thread Richard Newman
What are other people doing to maintain their installations? Is there some simple way to keep all of these projects up to date? Or do people simply not update all of these projects often? I suck it up. Fortunately I was in the process of switching to Leiningen when contrib suddenly moved to Ma

Re: Clojure and OOP

2010-02-11 Thread Richard Newman
I suspect that Clojure is actually more suited to OOP than Java, assuming you're going by Dr. Kay's definition. :) Another Kay quote: "I invented Object-Oriented Programming, and C++ is not what I had in mind." -- You received this message because you are subscribed to the Google Groups "Cl

Re: scope of binding

2010-02-08 Thread Richard Newman
You can also capture the binding. This looks a little ugly, but it works: it grabs the binding eagerly, and returns a closure that dynamically binds it when the function is invoked. (binding [*v* 2] (map (let [v *v*] (fn [n] (binding [*v* v] (f n

Re: compiled namespaces referencing each other

2010-02-05 Thread Richard Newman
which invokes "(compile 'foo.main)". I then get "java.lang.Exception: Unable to resolve symbol: a in this context". foo.main uses foo.util. foo.util uses foo.main. That's a circular reference. There are ways around this (e.g., create foo.main in foo.util, then use declare to ensure that `a`

Re: newbie question: splitting up source files

2010-02-05 Thread Richard Newman
It might be helpful if the documentation at http://clojure.org/namespaces mentioned how to split out a namespace into multiple files. I never split a namespace into multiple files: I split my project into multiple namespaces. That way I can simply :require and :use them from each other, and

Re: Is this possible in Clojure?

2010-02-04 Thread Richard Newman
And he does have some eval's in there: http://github.com/brool/gulliver/blob/master/template-servlet.clj But my Clojure knowledge isn't yet good enough to tell me whether he's using eval only once or on every render? It uses eval at runtime, but only once: that code slurps a template, turn

Re: Is this possible in Clojure?

2010-02-04 Thread Richard Newman
Enlive has to reconstruct HTML from its data structures. This, on the other hand, mostly just prints already "rendered" strings, and calls any clojure functions/macros along the way. Most CL/Clojure HTML output systems, like clj-html or CL-WHO, produce optimal output by processing the macro

Re: Is this possible in Clojure?

2010-02-04 Thread Richard Newman
NAME (not name) may be "interned" in the sense that it will exist somewhere in the symbol tree, but that doesn't matter—at all. At least in newLISP. In Clojure it may have some consequences and if so, that would be a valid argument to make, I'd be interested to know what they are if that is

Re: Is this possible in Clojure?

2010-02-04 Thread Richard Newman
OK, I hope you can see the difference though between that and what I showed. Of course I can; I'm just illustrating a point by exaggeration. They are not the same; in your example: - It's not clear what the magic symbols are - The user does not specify the magic symbols (as they did in mine)

Re: Is this possible in Clojure?

2010-02-04 Thread Richard Newman
* You don't have to fiddle with magic names. The user can choose himself. These aren't magic names, they're just like you keywords, except they're symbols, and they're not magic because they're defined by the columns of the table. Or, I may be misunderstanding your use of the term 'magic'

Re: Clojure for system administration

2010-02-04 Thread Richard Newman
in a bash (or other language) script anyway to handle the classpath, The classpath is a perpetual source of frustration. It drives me nuts every time I have to restart swank to work on a different project with a different classpath. It certainly means that something like a Clojure shell wo

Re: Request for advice on java interop namespace hunting

2010-02-02 Thread Richard Newman
I've found myself a few times in a situation where I'm banging some java code into clojure, and the java source uses import foo.* blah.* bar.* Now Clojure requires explicit class naming (which I fully support) so I end up spending a good slice of time googling "java SomeWierdClass someapi" to ge

Re: update-in and get-in why no default?

2010-02-01 Thread Richard Newman
There are still some sharp edges I'm not sure about: (A) user=> (get-in {:a 1} []) {:a 1} ;; this is existing behavior, but I feel the result should be nil +1 for nil I think I disagree. If you view 'get-in' as an unwrapping operation, unwrapping by zero steps should return the existing col

Re: Lazy (apply concat ...) ?

2010-02-01 Thread Richard Newman
Am I understanding this correctly? It seems laziness is only an option in batches of 32 now. Indeed. *Processing* *chunked* lazy sequences can only be done in batches of 32. Custom lazy sequences (using (lazy-seq ...)) don't suffer from this. You might be interested in this blog post: http

Re: Lazy (apply concat ...) ?

2010-02-01 Thread Richard Newman
Oh I see. Thanks for the explanation. I always assumed that chunked sequences can be viewed as purely an optimization and transparent from the user. Is there a way (short of writing a lazy version of apply concat) that I can achieve my desired result? I've heard talk about trying to provide some

Re: Lazy (apply concat ...) ?

2010-02-01 Thread Richard Newman
I'm wondering whether (apply concat ...) can be re-written to be lazy. ... -Behavior in 1.1.0-- The operation is eager. It's not: it simply uses chunked sequences, so the first 32 elements are evaluated together. user=> (def temp (for [i (range 50)] (do (println i)

Re: Transients question/feedback

2010-02-01 Thread Richard Newman
My question is: why not have each conj! produce a new, lightweight TransientVector instance pointing to the same shared data? ... My guess is that the resulting ephemeral garbage would have only a small effect on performance, retaining most of the advantage of transients, but improving their s

Re: newbie python/clojure and java.lang.OutOfMemoryError: Java heap space

2010-01-28 Thread Richard Newman
What's puzzle me is that past at certain number (10 millions), clojure chocks and throw a «java.lang.OutOfMemoryError: Java heap space», continue for a while and stop before completing the sequence. The JVM puts a limit on the amount of memory that will be allocated. Try adding -Xmx512m to you

Re: apply macro to 'argument' list?

2010-01-28 Thread Richard Newman
yup. and i mean "i wish lisp had that ability, rather than forcing everything that isn't strict-evaluation functional argument passing into compile time macros." of course, it only moves the newbie (like me with macros) "hey, these things aren't all exactly the same?!" reaction somewhere else --

Re: apply macro to 'argument' list?

2010-01-28 Thread Richard Newman
A broader analysis of this: because macros work at compile-time, not at runtime, you need to know the number of arguments in advance. That means for the case of 'and', it seems like if one had other call-by-* semantics available in the lisp, then one wouldn't have to use a compile-time macro?

Re: Clojure Conference Poll

2010-01-28 Thread Richard Newman
Conference alignment is smart, but to which conference? I suppose it depends on whether the conference organizers prefer to convenience the audience of JavaOne or ICFP. I'm unfamiliar with what sort of folks go to JavaOne, I'd imagine many of them aren't familiar with Clojure and wouldn't be int

Re: apply macro to 'argument' list?

2010-01-28 Thread Richard Newman
Doesn't extend to arbitrary number of arguments, though. that was sorta a deal-breaker. :) A broader analysis of this: because macros work at compile-time, not at runtime, you need to know the number of arguments in advance. That means that any solution which requires a variable number of

Re: apply macro to 'argument' list?

2010-01-28 Thread Richard Newman
is there a general shorthand rule for (apply macro [arg1 arg2])? given your version i'm assuming "no" :-) (apply #(macro %1 %2) [arg1 arg2]) Doesn't extend to arbitrary number of arguments, though. every? does. -- You received this message because you are subscribed to the Google Groups "Cloju

Re: apply macro to 'argument' list?

2010-01-28 Thread Richard Newman
if "and" were a function then i could do (apply and [true false]) and get false, i think. is there some shorthand for doing that given that apply doesn't work with macros? (every? identity [true false]) -- You received this message because you are subscribed to the Google Groups "Clojure" group

Re: newbie question about ns and :require

2010-01-27 Thread Richard Newman
now if i only knew when to use ' or : or nothing, and which in (ns) vs. inline in the repl. Simple: ns is a macro, so you don't need to quote. use and require are functions, so you need to quote their symbol arguments. ns uses keywords to identify its directives (:use), and functions (use)

Re: A new lisper's question about a macro

2010-01-24 Thread Richard Newman
The former is a lot clearer to read, as it uses standard Clojure datastructures. ... which offers other advantages beyond the human, such as (def page-names keys) user=> (page-names foobar) (:page :posts :post) Power comes from algorithms × data structures, and hiding the data structures —

Re: Clojure Conference Poll

2010-01-24 Thread Richard Newman
as far as pricing goes, how does something in the $199 range sound? we can probably add a tutorial day Friday for a small additional cost, say $149...? we can certainly have some well-known clojurians conduct the tutorials, I'm sure we'll have plenty of real world clojure experience in the house..

Re: Debugging in Clojure

2010-01-24 Thread Richard Newman
That said (and I'm not trying to make this a "charged" statement ... just a way to learn more) I had always thought that one of the key things that made lisp so complete was that programs don't just crash ... that debugging is fully-baked into the *core* of everything. Now, I don't remembe

Re: Promise/Deliver use cases

2010-01-23 Thread Richard Newman
You're right. Here's a recursive example of what I was trying to do with promise/deliver: http://gist.github.com/284957 And with delay/force: http://gist.github.com/284972 Nice comparison, thanks for sharing. I suppose the one thing I like about promise/deliver is that promises can be "w

Re: Promise/Deliver use cases

2010-01-23 Thread Richard Newman
delay/force definitely do not do what I'm describing. What we want to is something like a continuation as mentioned by Chouser. We want to block the thread of execution until some point in the future when the values become available. I'm not sure that what you described describes what you w

Re: Dependency management

2010-01-22 Thread Richard Newman
They have a partial ordering wrt a particular repo. Many repos have straight-line histories, and thus have a total ordering. So how do I find out the ordering of your x repository here in my machine, possibly without having x installed. Or your repo cloned? I'm assuming that a source-based

Re: Dependency management

2010-01-22 Thread Richard Newman
And as for Apache HttpComponents, it sounds like they don't grok the notion that breaking backwards compatibility should only occur with a major-version change. Yeah, it's a pain to use their stuff -- I've never seen *so many packages* in one library -- but it seems to be the only feature-rich

Re: Dependency management

2010-01-22 Thread Richard Newman
Just this week I noticed that Apache HttpComponents 4.0.1 and 4.1 use completely different methods to apply pre-emptive HTTP Basic Auth, and have even changed class hierarchies. A version of clj- apache-http targeted at 4.0.1 won't even run against a 4.1 jar (and vice versa), *even without A

Re: Clojure for largish web application?

2010-01-22 Thread Richard Newman
I've developed some smaller web applications using Common Lisp, but I'm not confident that any of the CL web servers (CL-HTTP, Hunchentoot, AllegroServe, Araneida, mod_lisp, et al) are up to handling high traffic high data sites. (Maybe they are, I just don't know). Does anyone know how good any

Re: Dependency management

2010-01-22 Thread Richard Newman
BTW: commit ids as version numbers break down here, because they are not ordered. They have a partial ordering wrt a particular repo. Many repos have straight-line histories, and thus have a total ordering. Neither maven nor ivy are so simple-minded to allow only one version. How well range

Re: Dependency management

2010-01-22 Thread Richard Newman
Now for the original question: http://groups.google.com/group/clojure/browse_thread/thread/6cef4fcf523f936 The problem is AOT compiled code. Not only. If my library refer to a function that's first defined in library-X version 1.5, and some other code uses library-X 1.4 *and* my library, t

Re: Clojure Conference Poll

2010-01-22 Thread Richard Newman
What coast are you thinking? That will probably affect a lot of answers. Agreed. I'm flexible enough to go during the week (which frees up my weekend!), but I imagine that's not the case for most. -- You received this message because you are subscribed to the Google Groups "Clojure" group.

Re: Dependency management

2010-01-22 Thread Richard Newman
Alternatively, is it possible to at least depend on a "source" version of the dependency, having it compiled on the fly locally when compiling the main project ? (so that one could benefit from AOP, and this could also solve the problem of a library mixing java and clojure source) ? I've th

  1   2   3   4   >