Re: Macros and deftype – usage question

2012-04-28 Thread Armando Blancas
Seems like the expansion is trying to put the function's value in there, and this has already been compiled. If the function' code is expanded in-place it works. user=> (defmacro bar [a] (let [b (keyword a) f `(fn [& args#] ~b)] `(deftype ~a [] clojure.lang.ILookup

Re: question about a macro

2012-04-19 Thread Armando Blancas
Flatten isn't the problem. You can't put together a special form with apply. Try taking the class name as a symbol or string and use reflection. On Wednesday, April 18, 2012 1:57:27 PM UTC-7, Thomas wrote: > > Hi, > > I'd like to write a macro which transforms > > (my-macro SomeClass. a b [x y] c

Re: Newbie question about rebinding local variables

2012-04-19 Thread Armando Blancas
You could keep the board in an atom so it can mutate; then try to find maybe two good places for mutation to happen, your move and the program's. With the rest being functional you'll avoid the problems of global state while not being forced to fit your logic into a loop of some re-binding that

Re: Boolean

2012-04-13 Thread Armando Blancas
It's the other way around: false is boxed into Boolean/FALSE. Here's the if stmt: public Object eval() { Object t = testExpr.eval(); if(t != null && t != Boolean.FALSE) return thenExpr.eval(); return elseExpr.eval(); } On Friday, April 13, 2012 12:45:02 PM UTC-7, Andy Fingerhut wrote: > > One li

Re: Boolean

2012-04-12 Thread Armando Blancas
> > > 'false' is a clojure built-in, > > false and true are JVM built-ins. > LOL. Don't let him get away with anything! -- 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 posts from

Re: Extracting string literals from codebase

2012-04-11 Thread Armando Blancas
Maybe walking the result of (read-string (str "(" (slurp "somefile.clj") ")")) On Wednesday, April 11, 2012 9:20:31 AM UTC-7, Mark Fredrickson wrote: > > Hello, > > I have a web survey/survey experiment written in Clojure. The survey is > currently in English and needs to be translated into Fren

Re: Forgetting (require…) => nasty bug

2012-03-28 Thread Armando Blancas
> > Is there a way to capture those kind of bugs earlier? > For each namespace I get a fresh repl and (use) the one in turn, then try the whole program. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@go

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-27 Thread Armando Blancas
an be the simpler, better choice. On Tuesday, March 27, 2012 12:25:16 PM UTC-7, David Nolen wrote: > > On Tue, Mar 27, 2012 at 3:12 PM, Armando Blancas wrote: > >> If anything, the java-in-parens gvec.clj *proves* how difficult it is to >> get Java perf in Clojure. Th

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-27 Thread Armando Blancas
You can spot a weak argument when euphemisms and stuff we are yet-to-encounter start to pop up. I find puzzler's experience exactly to mine, point by point, and given the little talk of multi-threading coding in this board I'd expect the same to apply to many others. If anything, the java-in-pa

Re: can Clojure 1.3 code always be made as fast as Java for numeric computations?

2012-03-27 Thread Armando Blancas
An alternative to the complexities involved may be to write number-crunching hot spots in Java. Thus I'd add to Tip 10 that it ain't so bad if you exploit some JVM-platform-goodness *you* just wrote; by definition it's not much code, it's much simpler and can be done in a functional style. On

Re: How to escape a space in a keyword?

2012-03-12 Thread Armando Blancas
> > If invalid input will not throw an error > immediately, then it DOES need to be documented that invalid input > will result in undefined output. > > ~Justin > Documented by whom? By you and FrankS? Maybe the push back is for lotta suggestin' but little doin'. -- You received this message be

Re: Why don't extends? and satisfies? require implementation of all protocol methods?

2012-03-09 Thread Armando Blancas
(extend-type clojure.lang.IPersistentVector > Fixo > (fixo-push [vector value] >(conj vector value))) > [should FAIL - protocol name not allowed here unless all methods are > implemented] > > => (extend-type clojure.lang.IPersistentVector > nil >

Re: Why don't extends? and satisfies? require implementation of all protocol methods?

2012-03-08 Thread Armando Blancas
(Don't know why I can only respond to the first message.) I come across partial implementation all the time, and with proxy, too. In Eclipse this is so common that this is typical: "This adapter class provides default implementations for the methods described by the SelectionListener interface.

Re: Why don't extends? and satisfies? require implementation of all protocol methods?

2012-03-07 Thread Armando Blancas
> > user=> (boom (Record.)) > AbstractMethodError user.Record.boom()Ljava/lang/Object; user/eval55 > (NO_SOURCE_FILE:3) > > Apparently, types/records can implement a protocol "in name only." > That can't in name only since you obviously got an implementation, though abstract. > What is b

Re: checking if a method is defined

2012-02-29 Thread Armando Blancas
> > What should I be using to check that the symbol .firstName and > .fullName are defined in the current scope? > "fullName" is easier because it gets interned in the current namespace: user=> (ns-interns 'user) {fullName #'user/fullName, ->Person #'user/->Person,

Re: Lack in the documentation

2012-02-15 Thread Armando Blancas
> Can you provide some more specific examples of what's missing? Surely you're joking, Mr. Hagelberg. > I don't know any Java and was able to manage pretty well. This is no time for modesty, lest the OP might feel his troubles aren't even valid. Perhaps better to say that a rudimentary grasp of

Re: A Bug of map function?

2012-02-14 Thread Armando Blancas
eval doesn't mind lazy seqs as input: user=> (map identity ['quote ()]) (quote ()) user=> (class (map identity ['quote ()])) clojure.lang.LazySeq user=> (eval (map identity ['quote ()])) () But it can't handle a form that contains an (evaluated) empty lazy seq. Another example: user=> (eval `(quo

Re: Persistent collections and garbage collection

2012-02-10 Thread Armando Blancas
Not sure if I understand your concern since I wonder how's that different from, say, some ephemeral Java collection that happens to be around after a given generational threshold and then becomes unreachable. On Feb 10, 4:01 am, pron wrote: > And have you profiled the objects making it to the old

Re: How to loop over several sequences in parallel for side-effects?

2012-01-24 Thread Armando Blancas
Well, you can always use the (time) macro and pick what runs faster: (dorun (map some-fn-with-side-effects sequence-1 sequence-2)) (doseq [x (map some-fn-with-side-effects sequence-1 sequence-2))]) (doseq) could be faster in some cases because its implementation uses chunked sequences. Now, (dos

Re: How to loop over several sequences in parallel for side-effects?

2012-01-23 Thread Armando Blancas
Can you point to where that's happening? I can only see an iteration of next over the sequence returned by map. On Jan 23, 6:43 am, "Meikel Brandmeyer (kotarak)" wrote: > And (dorun (map )) is creating a cons with a random value (most likely nil) > and traverses it and throws it away at every seq

Re: string to S-value

2012-01-10 Thread Armando Blancas
user=> (first (read-string x)) a On Jan 10, 12:36 pm, Bartek wrote: > hello everyone, > > It's true that: > > (first '(a b)) > is: > a > > And now I have: > > (def x "(a b)") > > How can I use 'x' as S-expression like in the example above? > > (first (>>some-functions<< x)) > and should give: > a

Re: Clojure list syntax sugar: f(x) notation

2011-12-30 Thread Armando Blancas
>  However, let's turn it around for a > moment and ask another question: why is it that some newcommers year after > year think that the choice of this syntax is arbitrary? Some people come with lots of baggage from other languages they like. That's why various complaints and proposals are so sup

Re: How to deal with parameters unused by intermediate functions?

2011-12-03 Thread Armando Blancas
If foo is their only caller, bar and baz can be locals inside foo and thus giving baz direct access to foo's params. Checkout (letfn): http://clojuredocs.org/clojure_core/1.2.0/clojure.core/letfn On Dec 2, 7:34 pm, Jim Crossley wrote: > Hi, > > I have a public function foo that uses two private f

Re: clojure-jsr223 and shibboleth ScriptedAttributeDefinition

2011-11-14 Thread Armando Blancas
Here's a patch: http://code.google.com/p/clojure-jsr223/downloads/list Feel free to file bugs here: http://code.google.com/p/clojure-jsr223/issues/list On Nov 13, 9:52 am, Francesco wrote: > I was trying to write a simple script attribute definition for > shibboleth as > in:https://wiki.shibbol

Re: clojure-jsr223 and shibboleth ScriptedAttributeDefinition

2011-11-14 Thread Armando Blancas
The compile call is a no-op and makes no difference since the engine evaluates the script. That looks like a bug in getAttribute(). I use put and get from the engine directly and may have overlooked something in the attr calls. I'll upload a fix in google code asap. On Nov 13, 9:52 am, Francesco

Re: Clojure as scripting language in a Java Application

2011-11-03 Thread Armando Blancas
There are two libs with that name; I maintain the one in google code. In case that's the one you found, here's a status. It supports the spec, but there are two differences described in issues #4 and #5 (#3 is fixed) that arise from the spec's assumption that you'll use an interpreter. Works with

Re: Rich Hickey: "Simple Made Easy" from Strange Loop 2011

2011-10-21 Thread Armando Blancas
> (because test cases are written by the coder who has a > specific intention in mind) > Good observation. When I see figures of tests coverage I wonder how many flow paths aren't being covered simply because they don't exists but they should. -- You received this message because you are subscr

Re: SICP sqrt function generates unexpected NullPointerException

2011-10-14 Thread Armando Blancas
With 1.3/OSX this code worked up to: user=> (sqrt 1) 100.0 and then hanged here: user=> (sqrt 10) ~ $ On Oct 13, 7:04 pm, "Alan O'Donnell" wrote: > Hi everyone, > > I've encountered an unexpected NullPointerException while translating > some early SICP code into Clo

Re: Should intern obey :dynamic?

2011-10-12 Thread Armando Blancas
> Seems to me that if you're going to use metadata to communicate intention > about dynamic binding in *one* way of creating a new var, you should do it > with *all* ways of creating a new var. And you may be right. My point was that a var's dynamic nature is part of its state: it's primarily da

Re: Should intern obey :dynamic?

2011-10-12 Thread Armando Blancas
> The metadata tells you why: > >     user=> (meta #'*dynamo*) >     {:ns #, :name *dynamo*, :dynamic true, :line 1, :file ...} The var tells you why: user=> (.isDynamic (var *dynamo*)) true > > Now let's make another variable with `intern`, copying the metadata from > `*dynamo*`: >     user=> (

Re: defprotocol problem in 1.3?

2011-10-05 Thread Armando Blancas
I'd recommend that you file a bug; surely that's a regression. As you pointed out, this fails: user=> (defprotocol xyz) CompilerException java.lang.UnsupportedOperationException: Unknown Collection type, compiling:(NO_SOURCE_PATH:1) But the expansion works if you evaluate it directly, which might

Re: Clojure embedded in a Java Application

2011-09-19 Thread Armando Blancas
> You can also do it the other way around, use gen-class > and write yourself a static entry point callable from Java. That's the right way to do it, IMO. Better yet, write a Java wrapper to offer Javadocs and to hide any interop code. That means extra work on both ends, but in Java shops Clojure-

Re: Is there a reason that def- isn't part of the core lib?

2011-09-17 Thread Armando Blancas
There are other nine defs in core that don't have a dash version, either. I guess if they were to take def- they'd have to add the others and then add any new defs in pairs. But there's no reason to write ugly code; just write your own or use a contrib, if available. On Sep 17, 7:54 am, Rob Lally

Re: Migration to 1.3 for mortals

2011-09-08 Thread Armando Blancas
There's this page: http://dev.clojure.org/display/doc/Clojure+Contrib Here's the main page for the new repos: https://github.com/clojure On Sep 7, 5:44 am, Jan Rychter wrote: > How do we mere mortals (that develop and maintain large apps) migrate > to 1.3? > > I thought I'd be able to at least e

Re: lambda function returning a constant?

2011-09-06 Thread Armando Blancas
> (#(true)), is this not calling a function that has no arguments and > returns true? But it still gives same exception Not really: user=> (macroexpand-1 '#(true)) (fn* [] (true)) > I guess I should forgo the macro > and go directly with (fn  [] true) For something like "=> true" try: user=> (de

Re: A re look at re-groups

2011-08-30 Thread Armando Blancas
> It seems like the loop/recur is non-idiomatic for this usage and could > be done with either a map or reduce. It could be that it's faster that way. How does you code perform? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, s

Re: Clojure 1.3 Beta 2

2011-08-29 Thread Armando Blancas
False alarm. Some trouble with the VPN line. On Aug 29, 9:06 pm, Armando Blancas wrote: > The change to beta2 isn't working for me: > >     >       org.clojure >       clojure >       1.3.0-beta2 >     > > 1.3.0-beta1 works fine. > > On Aug 29

Re: Clojure 1.3 Beta 2

2011-08-29 Thread Armando Blancas
The change to beta2 isn't working for me: org.clojure clojure 1.3.0-beta2 1.3.0-beta1 works fine. On Aug 29, 7:28 am, Christopher Redinger wrote: > Clojure 1.3 Beta 2 is now available at > > http://clojure.org/downloads > > The list of changes: > >   * clojure.test/*

Re: I/O

2011-08-25 Thread Armando Blancas
> I think part of the reason for > this is the conception (maybe misconception) that most people are > familiar with java and since there is java interopt they should be > able to figure this out.  As more and more schools are starting to use > Python as their beginning CS language, this may well n

Re: Spitting out a lazy seq to file???

2011-08-16 Thread Armando Blancas
You can put the line break back into each line (" added stuff\n") and then do: (spit "output.txt" (reduce str (map change-line old-data))) On Aug 16, 8:26 am, Thomas wrote: > Hi everyone, > > I have been struggling with this, hopefully, simple problem now for > quite sometime, What I want to do i

Re: Small bug in clojure.core/bases?

2011-08-15 Thread Armando Blancas
> I think a function should generally return the same types for > different input. A seq and a Java array are two very different things > even though Clojure often lets us pass both to the same functions. It > seemed like a small fix, but I guess not everyone agrees. That's clearly a bug; they for

Re: rebind var for all threads

2011-08-11 Thread Armando Blancas
> My code calls a function in 3rd party library A, which in turn calls a > function in 3rd party library B.  The lib B function uses blacklisted Java > classes, causing my app to crash when lib A calls it.  I would like to > replace that function with a safe version, so that lib A is forced to use

Re: One name space / Multiple Modules

2011-08-05 Thread Armando Blancas
You can see a concrete example of Meikel's answer right there in the Clojure sources: files core.clj, core_deftype.clj, core_print.clj, and core_proxy.clj define the clojure.core namespace. On Aug 5, 4:57 am, octopusgrabbus wrote: > Sure. module = .clj file > > On Aug 5, 2:35 am, Laurent PETIT w

Re: New to Clojure -- Errors Are Frustrating

2011-08-02 Thread Armando Blancas
> It's encouraging to see the community is thinking of > ways to improve this. We shouldn't, however, expect any significant improvements, IMO. For the reasons explained, and the fact that lisp has almost no syntax, this is a difficult problem to solve. Not that it has prevented people from trying

Re: Best Way To Load and Run Clojure program in REPL

2011-06-07 Thread Armando Blancas
Sounds like you're looking for (load-file "test.clj") http://clojure.org/evaluation On Jun 7, 12:47 pm, octopusgrabbus wrote: > I've been searching the documentation -- which is quite good by the > way for experienced programmers new to Clojure -- to find out how to > load a test.clj into REPL a

Re: :gen-class possibly missing a compile time check when extending abstract classes that implement interfaces

2011-05-30 Thread Armando Blancas
> I was a bit surprised and I wonder if Clojure is > effectively generating abstract classes rather than concrete classes? > (Do we have no way to specify the difference? Is that only an artifact > of the Java compiler, not the JVM bytecode?) I don't think Clojure will generate abstract classes; t

Re: Recur and primitives?!?

2011-05-27 Thread Armando Blancas
> I doubt it. Rather, m is now an int so (dec m) can be a valid recur for h. Yeap, that makes more sense, after all the change was on m. Maybe the error message could read "h must receive matching primitive." -- You received this message because you are subscribed to the Google Groups "Clojure"

Re: Recur and primitives?!?

2011-05-26 Thread Armando Blancas
Coercing m to int somehow prevents h from being boxed: user=> (defn bin-search [v k c] (loop [l 0 h (dec (count v))] (if (> l h) false (let [m (int (quot (+ l h) 2)) m-v (v m)] (cond (> m-v k) (recur (inc m) h) (> k m-v) (recur l (dec

Re: Books on Java Objects and Primitives

2011-05-23 Thread Armando Blancas
Maybe something like this: Java for Programmers [Paperback] Paul J. Deitel (Author), Harvey M. Deitel (Author) You can start with the basics of the language and then move on to using the libraries as needed. The docs api (linked above) is a great reference but not a place for learning how to use t

Re: Clojure 1.3 Alpha 7

2011-05-20 Thread Armando Blancas
That's right. Database tables are much flatter than the typical object composition, which you can do after you bring in a tuple into a record. Here's probably where this limitation in Clojure hurts the most, even when tables are fully normalized. On May 20, 11:37 am, pmbauer wrote: > Use Case: Au

Re: Clojure example code snippets

2011-05-19 Thread Armando Blancas
Just in case I'll mention that Meikel's use of (with-open) will automatically close the reader. On May 19, 11:40 am, dokondr wrote: > On May 19, 6:52 pm, Meikel Brandmeyer wrote: > > > Hi, > > > something like the following should work. > > > (with-open [rdr (java.io.FileReader. "file.txt")] > >

Re: Type hinting inconsistencies in 1.3.0

2011-05-11 Thread Armando Blancas
Thanks for the link to the new documentation. > That's how one hints a non-primitive return type; that's been the case for a > long time now. I know, but haven't needed it; I guess it's for Java interop. > hinting arg vectors in order to indicate function return types is a > syntactically poor

Re: Type hinting inconsistencies in 1.3.0

2011-05-11 Thread Armando Blancas
Have you seen this? http://www.assembla.com/wiki/show/clojure/Enhanced_Primitive_Support •hint for return goes on arg vector ◦e.g. (defn ^:static foo ^long [x] …) ◦this so it supports multi-arity with varied returns I couldn't find a practical use of doing (defn ^String foo [] ...) what's hinting

Re: possibly non-intuitive behaviour of clojure.set/rename-keys and possible enhancement suggestion

2011-05-11 Thread Armando Blancas
This renames keys to avoid collisions, using an array map to preserve the order of the keys: user=> (rename-keys {1 :a 2 :b 3 :c} (array-map 3 4 2 3 1 2)) {2 :a, 3 :b, 4 :c} On May 11, 7:22 am, Armando Blancas wrote: > > (clojure.set/rename-keys {1 :a 2 :b 3 :c}  {1 2 2 3 3 4}) >

Re: possibly non-intuitive behaviour of clojure.set/rename-keys and possible enhancement suggestion

2011-05-11 Thread Armando Blancas
> (clojure.set/rename-keys {1 :a 2 :b 3 :c}  {1 2 2 3 3 4}) > > returns > > {4 :a} That's caused by the collision between new and existing keys. Renaming 1 to 2 blows [2 :b]: {2 :a, 3 :c}; then renaming 2 to 3 blows [3 :c], leaving {3 :a}; and the last just renames 3 to 4: {4 :a}. -- You receive

Re: Hi, simple problem from a newbie

2011-05-10 Thread Armando Blancas
Don't be put off by these initial difficulties; this stuff is really different. I found this paper a very good read: http://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf It puts the finger on a common problem: "Such a catalogue of “advantages” is all very well, but one must not be surpri

Re: clojure.java.jdbc 0.0.1 released

2011-05-09 Thread Armando Blancas
Cool. I look forward to having approved 1.0.0 releases of contrib libraries. On May 9, 3:28 pm, Sean Corfield wrote: > On Mon, May 9, 2011 at 2:38 PM, Armando Blancas > > wrote: > > Having no clue what to make of 0.0.1 precisely w.r.t. its previous > > versions numbers, I

Re: clojure.java.jdbc 0.0.1 released

2011-05-09 Thread Armando Blancas
Having no clue what to make of 0.0.1 precisely w.r.t. its previous versions numbers, I gathered it's because you can't make out anybody's modules anyway, in which I agree. On May 9, 11:34 am, Sean Corfield wrote: > On Mon, May 9, 2011 at 8:22 AM, Armando Blancas > >

Re: clojure.java.jdbc 0.0.1 released

2011-05-09 Thread Armando Blancas
Yeap. Release numbers have become meaningless; your point is well taken. On May 8, 7:11 pm, Sean Corfield wrote: > The library formerly known as clojure.contrib.sql has had it's first > non-snapshot release. > > Features added: > * returns generated keys for single record inserts > * supports nam

Re: Eval destroys equality

2011-05-05 Thread Armando Blancas
In 1.3 the function will (eval) to itself: Clojure 1.3.0-alpha6 user=> (defn id [x] (list id x)) #'user/id user=> (id 7) (# 7) user=> (eval (id 7)) (# 7) user=> (= (id 7) (eval (id 7))) true On May 5, 6:04 am, Dominikus wrote: > My observation is best distilled with the following definition of a

Re: Closures in macros

2011-05-04 Thread Armando Blancas
> 3. (defmacro z [] `(let [a# ~((fn [x#] (fn [] x#)) 0)])) > > All three calls fail, (x) and (y) and (z). > I see no plausible reason why it *should* be that way. As it's been pointed out, the compiler won't re-compile compiled code. Those macros work if you don't unquote the expressions: (defmacr

Re: Key order of literal maps

2011-05-03 Thread Armando Blancas
Keys from literal maps aren't sorted; you need a sorted map. user=> (keys {:z 1 :f 2 :a 0}) (:z :a :f) user=> (keys (sorted-map :z 1 :f 2 :a 0)) (:a :f :z) On May 3, 4:08 am, David Jagoe wrote: > Hey everyone, > > I'm busy implementing a macro whose usage looks like this: > > (defentity Person >

Re: Parallelism

2011-05-02 Thread Armando Blancas
Thanks for the link; that helped me read the pmap code properly. So it's not a single thread but n that get initially started, and, if the consumer keeps up, pmap will start a thread when a result value is taken, this staying ahead with max cpu usage. If I understand this correctly, it's the (drop

Re: Parallelism

2011-04-30 Thread Armando Blancas
> does access to > lets say second part of partitioned range cause first part to be > materialized or no? Yes, it does. > My second question is connected to first. If we have 4 cores and *pmap *starts > 4 threads to perform our function on 4 parts of partitioned range, is this > happening in para

Re: SubVector's (via 'subvec') do not support 'transient'

2011-04-30 Thread Armando Blancas
Check this out: http://clojure.org/Transients On Apr 29, 10:54 am, Nathan Sorenson wrote: > (transient (subvec [1 2 3 4 5] 0 2)) fails with a class cast > exception. Is this expected/unavoidable? How do I know whether the > vectors I'm passed are regular vectors or come via subvec? > > I'm assumi

Re: dead simple compile to jar file

2011-04-28 Thread Armando Blancas
Before maven, I used the repl and jar. My root dir had src\myapp \*.clj, ... and "classes". 1-In directory classes: "jar xf path\to\clojure.jar", same for any other deps. 2-In root, "java -cp src;classes clojure.main"; -> "(compile 'myapp.main)" 3-Back to classes: "jar cfe myapp.jar myapp.main *.*"

Re: "closed" maps / reducing runtime errors due to mistyped keywords

2011-04-22 Thread Armando Blancas
With regard to mistyped keys in general, a simple option is to use named keys; then the compiler will flag undefined ones. (def k :key) ... (k m) On Apr 21, 10:44 pm, Christian Schuhegger wrote: > I am taking up a discussion from > 2010:https://groups.google.com/group/clojure/browse_frm/thread/6

Re: Sharing a frustrating bug: using an atom to a hash as a hash

2011-04-21 Thread Armando Blancas
A type hint makes no difference because the param "state" is treated as an Object instance. user=> (:x @*aa*) 3 user=> (.invoke :x @*aa*) ; [16] invoke : Object (Object) 3 Besides, I don't think it's a good idea trying to setup some sort of static type-checker and strongly-typed functions. You're

Re: Understanding the Clojure source-code and functionality

2011-04-18 Thread Armando Blancas
You may want to follow this thread and look for the latest version of Clojure in Small Pieces: http://groups.google.com/group/clojure/browse_thread/thread/460417fe45f314c3/db1e7b58031efc7e On Apr 17, 12:27 pm, Terje Dahl wrote: > I would very much like to study and understand how Clojure works >

Re: You should fix this before next release!

2011-04-15 Thread Armando Blancas
> New development is happening in new, per-library > repositories athttp://github.com/clojure BTW, last night I noticed that this file hasn't been updated for 1.3: https://github.com/clojure/clojure-contrib/blob/master/modules/repl-utils/src/main/clojure/clojure/contrib/repl_utils/javadoc.clj bu

Re: You should fix this before next release!

2011-04-15 Thread Armando Blancas
I'm using: org.clojure.contrib repl-utils 1.3.0-SNAPSHOT ... clojure-snapshots http://build.clojure.org/snapshots ... My user.clj has: (use '[clojure.contrib.repl-utils :only (show run run*)]) And I launch the repl with: java -cp "C:\Documents and

You should fix this before next release!

2011-04-14 Thread Armando Blancas
Could "before next release" be changed to something like, er, "real soon"? (at least for c.c namespaces) Var *feeling-lucky-url* not marked :dynamic true, setting to :dynamic. You should fix this before next release! Var *feeling-lucky* not marked :dynamic true, setting to :dynamic. You should fix

Re: partial vs anonymous function?

2011-04-14 Thread Armando Blancas
Interesting. Thanks for your response. On Apr 14, 10:06 am, Ken Wesson wrote: > On Thu, Apr 14, 2011 at 12:26 PM, Armando Blancas > > wrote: > > I wonder in which cases this code is a good choice: a function that > > returns uneval'ed code. Something about macros not b

Re: partial vs anonymous function?

2011-04-14 Thread Armando Blancas
I copy that. FWIW, I'm not in the eval-is-evil camp, so didn't have an opinion one way or the other. I've seen code like that in posted samples and wanted to know if that's a technique useful to have around. On Apr 14, 9:34 am, David McNeil wrote: > > Will this be any > > better or worse: (defn m

Re: partial vs anonymous function?

2011-04-14 Thread Armando Blancas
I wonder in which cases this code is a good choice: a function that returns uneval'ed code. Something about macros not being an option where a function is expected, or a kind of lazy eval? Will this be any better or worse: (defn m [f s] (fn [] (map f s))) then doing (foo) instead of (eval foo)? On

Re: 1.3.0alpha5: gen-class, java.io.Serializable, readObject, writeObject....

2011-04-13 Thread Armando Blancas
You're right, I didn't consider that those methods are public. I don't think you're making any mistakes; that's just not supported. In you case I'd probably write a Java class with all the requirements and internally consume Clojure functions done with a simpler usage of gen- class or deftype. I cu

Re: Enclojure REPL problems

2011-04-13 Thread Armando Blancas
> what makes you think posting to a general-interest list will have the effect > you desire? (LOL) Indeed. And to prove it, here's the de rigueur retort of opensourceland: you fix it. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this g

Re: 1.3.0alpha5: gen-class, java.io.Serializable, readObject, writeObject....

2011-04-11 Thread Armando Blancas
Write a Java interface with these two methods and have your gen'ed class implement it. The gen'ed methods won't have a throws clause but will work with the serialization mechanism all the same. On Apr 11, 12:50 pm, Jules wrote: > I'd like to provide : > >  private void writeObject(java.io.ObjectO

Re: Clojures macro system is essentially hygienic -- In the good sense.

2011-04-11 Thread Armando Blancas
That's because of the order of the definitions of foobar and let. Thus: guik.evil=> (macroexpand '(foobar 10)) (let* [a__44__auto__ 10] (clojure.core/+ a__44__auto__ a__44__auto__)) But defining let before foobar: guik.evil=> (macroexpand-1 '(let)) (guik.evil/let*) guik.evil=> (macroexpand-1 (ma

Re: help--reading keyboard input from Clojure is surprisingly difficult

2011-04-08 Thread Armando Blancas
> My modest proposal: [snip] Have you considered a grant from the National Science Foundation? Dennis Ritchie is still around in what remains of Bell Labs; maybe he could help us read from standard input. -- You received this message because you are subscribed to the Google Groups "Clojure" grou

Re: help--reading keyboard input from Clojure is surprisingly difficult

2011-04-08 Thread Armando Blancas
> Can anybody suggest anything > that will enable me to write this simple program that any middle- > school student would find, well, basic if written in BASIC? Thanks. Write your own read function to delegate to (read-line) or, in debug mode, read the next line from some file; then keep various f

Re: Simple Clojure/Java interop

2011-04-07 Thread Armando Blancas
There's nothing wrong there. Would need to see the java snippet how is called. On Apr 6, 11:03 pm, MohanR wrote: > This is a beginner's question but I thought I might be missing > something. > > I am setting a System property and testing for it like this. It > passes. > >  ( deftest testlogger >

Re: How to add a java library (that is not in maven) as a dependency for a clojure library?

2011-04-07 Thread Armando Blancas
You may want to contact the library's developer to request it be published as a component, or do it yourself since it's open source and they won't mind the added exposure. Once that lib is up in clojars you continue as normal. On Apr 7, 6:49 am, j1n3l0 wrote: > Hi, > > I've written a little cloju

Re: Access constructor and fields with default (package) access level

2011-04-06 Thread Armando Blancas
> Should I file a bug about this ? File it. Access to package-private fields is a legitimate implementation decision. It's self-defeating for Clojure to put up obstacles when its adoption will most likely grow mixed with Java, and for maintenance. It makes no difference if you can use reflection o

Re: Clojure Conj 2011 Call For Speakers Now Open

2011-04-05 Thread Armando Blancas
> I could write a number of abstracts representing different approaches to > presenting the same core material, but that would seem disingenuous... Since you've got the credentials of "an otherwise great speaker", should your topic be taken they might have you talk about Ruby. Or, that call for t

Re: How to use params in java?

2011-04-03 Thread Armando Blancas
use invoke. On Apr 3, 11:18 am, monyag wrote: > Hello, Armando! do you can give me short example? I have some > RuntimeExaptions :( > > On 3 апр, 01:31, Armando Blancas wrote: > > > You need to use a few more classes from jvm/clojure/lang. For example, > > with Persi

Re: How to use params in java?

2011-04-02 Thread Armando Blancas
You need to use a few more classes from jvm/clojure/lang. For example, with PersistentVector#create(Object...) and one of the Keyword#intern() calls you should be able to construct myParams. On Apr 2, 4:32 am, monyag wrote: > Hi! I use clojure from java. And I don't know how to send params to > c

Re: Example to introspect a class

2011-04-01 Thread Armando Blancas
You'd have to not back-quote Region and then eval the reseult: user=> (def Country {'fields '((int x) (double y {reference Region}))}) #'user/Country user=> ((nth (nth (Country 'fields) 1) 2) 'reference) Region user=> (eval ((nth (nth (Country 'fields) 1) 2) 'reference) ) {fields ((datatype x) (da

Re: NB/Enclojure issues

2011-04-01 Thread Armando Blancas
> I particularly like the bleeding-edge attention Amazon gives to their AWS >plugin[1] and the GUI builders that Google open-sourced sometime last year[2]. Well, those gui builders are now free of charge, so there's something to like right there. If that were the way products get built, or even p

Re: NB/Enclojure issues

2011-04-01 Thread Armando Blancas
That's how it is with these bloated IDEs. My day job is mainly Eclipse plug-in/rcp dev, so I'm also guilty of putting an absurd burden on others (disk footprint, startup time, memory use, unresponsiveness), but that's what's passes for effective tooling these days. On Apr 1, 4:10 am, Chas Emerick

Re: Clojure Interop With Java Using Eclipse.

2011-03-31 Thread Armando Blancas
> So, really, all the current ccw behaviour wrt auto-compile, in background or > not, concept of "Clojure Application" will be reworked. One thing that ccw handles with ease is compiling Java for use right there in Clojure. With auto-compile one could do the opposite just as easy for dependent pro

Re: Clojure Interop With Java Using Eclipse.

2011-03-31 Thread Armando Blancas
> Your problem is probably that you only export the clj file. But the clj file > corresponds to a namespace with a gen-class. A gen-class must be compiled. > And yours is probably not. I'd think that's what the ccw.builder is there for. Then it'd be up to the user to decide what to export. Having

Re: A newbie's summary - what worked, what didn't

2011-03-28 Thread Armando Blancas
> IntelliJ w/ La Clojure - > Could get a REPL, couldn't figure out how to do anything else.  In > particular, I followed some specific instructions from somewhere > (can't remember where) for how to set up a project, edit a source file > (hello world or whatever), and "run" that source file.  All I

Re: Java Interop - Generics - Hmmm...

2011-03-24 Thread Armando Blancas
For interop I write interfaces in Java. This way I can provide type- specific signatures, constants, javadocs and generics; then implement them all in Clojure. I also write exception classes in Java for use in Clojure since I find it simpler and cleaner than gen-class. You don't have to give up any

Re: Jesus, how the heck to do anything?

2011-03-23 Thread Armando Blancas
> I have been offered money > to program in java in the past.  I turned it down, turning the phrase > "you couldn't pay me to program in java" into a reality.  It's fair to > state that I hate java more than any other language.  I'd rather > program in COBOL than java. That's quite alright. Nine o

Re: Can't "recur" from within a "catch" expression.

2011-03-18 Thread Armando Blancas
Here's a version with a similar simulated exception but caught in the main loop, with a bit of tracing code to show the retries. Clojure 1.2.0 user=> (import java.io.IOException) java.io.IOException user=> user=> (defn some-io-operation [] (let [n (rand-int 30)] (if (> n 10) (throw (I

Re: Software Engineering Practices for Marking Algorithms?

2011-03-16 Thread Armando Blancas
> However, the visited field has nothing to do with the actual Node > class. It's simply for other functions to use as a marker. > > This solution is kludgy, but I cannot see any other *performant* way > of doing this. I don't think markers are a kludge. Besides modeling, data structures must supp

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-15 Thread Armando Blancas
> Yes, I know. It disproved the suggestion that it was expanding macros > there *before* checking for special symbols. That was precisely my > point with that demonstration. I must have misread your comments. > When the macro expands into a special form, or a form involving a > special subform, t

Re: Polymorphic functions in Clojure (or how to stop thinking in objects)...

2011-03-15 Thread Armando Blancas
Another choice is to construct shapes as closures with auto-dispatch. So a circle could be made thus, with no data structure per se: (defn make-circle [x y r] (fn [method] (case method :draw (fn [color] ...) :rotate (fn [degrees] ...) :r (fn [] r) :x (fn [] x) :

Re: Evaluation of Symbol Bindings vs. Special Forms

2011-03-15 Thread Armando Blancas
> If so, it's only the subforms not in operator position that get > macroexpanded first. Otherwise > > user=> (defmacro qqq [] 'if) > #'user/qqq > user=> ((qqq) (even? 42) "boo!") > # in this context (NO_SOURCE_FILE:607)> > > would instead produce "boo!", as (qqq) would be expanded to if and > then

<    1   2   3   >