Re: How can I improve this?

2014-01-11 Thread Alex Osborne
On Sat, January 11, 2014 9:22 pm, Alex Baranosky wrote: > There is a class of problems where you want to track some state as you process a seq This is an interesting exercise. I find said class of problem comes up fairly frequently and I usually end up with something scary-looking using reduce or

Re: [ANN] clj-xpath 1.3.3

2012-11-21 Thread Alex Osborne
On 21/11/12 3:10 AM, John Gabriele wrote: Oh, thanks. My understanding was that current best practice was to choose a good name, and then if you're the original author, your project's group-id = artifact-id (and thus you get the https://clojars.org/my-proj url). The thought behind Clojars' conv

Re: java.lang.OutOfMemoryError when consuming many whole-numbers

2011-08-01 Thread Alex Osborne
Ben writes: > (defn whole-numbers [] (iterate inc 1)) > > If I use it like this at the REPL > > (take (whole-numbers)) > > I get: > Java heap space [Thrown class java.lang.OutOfMemoryError] > > This unexpectedly is the same result that I expectedly get when > binding whole-numbers to a t

Re: Libraries and build management hell

2011-07-31 Thread Alex Osborne
Mark Engelberg writes: > Phil makes a reasonable point that it is possible to create a single > "project" for one-off tasks. I'm not sure how well that would work > with the way I have things organized, and with my source control, but > it's something I can look into. I have a "scratch" project

Re: Libraries and build management hell

2011-07-29 Thread Alex Osborne
Lee Spector writes: > FWIW for some JVM newcomers (like me when I started) #6 involves some > mysteries related to where exactly the jar should be saved and how > exactly the other code can be told to find it. It varies depending on > how you run your code (e.g. whether you have to figure out how

Re: protocols and records -- use when?

2011-07-29 Thread Alex Osborne
Jeff Heon writes: > I'm puzzled when we say that Clojure is not particularly OO, but using > protocols and datatypes feel OO to me, > except that the namespace of the protocol method implementations is > decoupled from the namespace of the type. > > Perhaps my definition of OO is too loose and I

Re: Libraries and build management hell

2011-07-29 Thread Alex Osborne
Michal B writes: > To use libraries, you need to learn how to operate half a dozen build > tools and git because each library author distributes their library > differently. There is a simple de facto standard, which in typical Clojure-style we've inherited from the Java community for the sake

Re: protocols and records -- use when?

2011-07-28 Thread Alex Osborne
Oskar writes: > Why protocols (and records)? What benefits do I get? Alex mentioned > polymorphism; how is this different from/related to multimethods? As Andreas mentioned, yes protocols basically give you a subset of the polymorphism functionality of multimethods. But they also give you some

Re: protocols and records -- use when?

2011-07-28 Thread Alex Osborne
Oskar writes: > I have not heard much about records and protocols. What is a typical > use case in idiomatic Clojure code for them? Is it a good idea, for > example, to make a "Character" protocol and "Player" and "Monster" > records or something in a game. It feels a bit too much like OOP for >

Re: Code structure/design problems

2011-07-28 Thread Alex Osborne
Hi Oskar! Excellent questions. I totally agree with you that writing a simulation in a purely functional style is not the (only) answer in Clojure. After all the primary goal of the language is to deal with (necessary) state well, not to get rid of it or hide it. Oskar writes: > For the monst

Minimalist autocompile workflow for ClojureScript

2011-07-27 Thread Alex Osborne
Just sharing the stopgap method for "static HTML" (no server) ClojureScript development I'm using until someone cooks up a REPL that evals in the browser instead of Rhino. Nothing particularly exciting here, but really beats restarting the JVM on every compile. :-) This will only work on Linux as

Re: Wisdom sought for functional iterative processing

2011-06-14 Thread Alex Osborne
Matthew Phillips writes: > The only way I can think of to write it in Clojure is: > > (reduce > (fn [items op] > (let [items1 (if (:delete op) (drop-index (:delete op) items) > items)] > (if (:insert op) (cons (:insert op) items1) items1))) > items ops) > > i.e. I'm using a cascade

Re: Implementing search algorithm for binary tree

2011-02-23 Thread Alex Osborne
HB writes: > I'm trying to implement searching algorithm for binary tree. > > (defrecord Node [data left-child right-child]) > > (defrecord Tree [root]) > > (defn find-node [tree data] > "Search for a node" > (let [root (:root tree)] > (loop [current root] > (if (= data (:data curre

Re: Help with a ClassCastException

2011-02-08 Thread Alex Osborne
John Svazic writes: Snipping to the relevant portion of the exception (always look at the last "Caused by"): > Caused by: java.lang.ClassCastException: clojure.lang.Cons cannot be > cast to clojure.lang.Associative > at clojure.lang.RT.assoc(RT.java:664) > at net.auxesia.chromoso

Re: Records implementing IFn

2011-02-07 Thread Alex Osborne
Mark Fredrickson writes: > Is the following behavior correct or a bug: > > user> (defrecord Example [data] clojure.lang.IFn (invoke [this] this) > (invoke [this n] (repeat n this))) > user.Example > user> (def e (Example. "I am e")) > #'user/e > user> (e 2) > (#:user.Example{:data "I am e"} #:use

Re: extend-protocol with defrecord

2011-02-02 Thread Alex Osborne
Michael Ossareh writes: > You'll notice in the map returned after the second (extend-protocol) > that :impls has example.Extender1 listed twice. I assume this is > because they're different records, though the fact > that they share the same name is confusing (hence the example of the > exceptio

Re: Why won't leiningen install for me?

2011-01-24 Thread Alex Osborne
Hi Larry, As a quick temporary workaround you could just set your PATH environment variable so that it picks up the curl executable from /usr/bin instead of the broken MacPorts one from /opt/local/bin. $ which curl /opt/local/bin/curl $ export PATH=/usr/bin:$PATH $ which curl /usr/bin/curl You'l

Re: possible bug in `case'

2011-01-07 Thread Alex Osborne
"Eric Schulte" writes: > Hi, > > The following case statement > > #+begin_src clojure > (defn buggy-case [n] > (case (int n) > 0 :null > 1 :load > 0x7000 :loproc)) > #+end_src > > throws the following error > > No distinct

Re: probable bug in transients ..

2011-01-06 Thread Alex Osborne
Sunil S Nandihalli writes: > Hello everybody, > the following code is not producing what was expected of it in clojure > 1.2 .. has this been fixed the clojure 1.3? > > (let [x (transient {})] > (dotimes [i 10] > (assoc! x i (* i i))) > (persistent! x)) This is not a bug, it's a misuse o

Re: an object of class created using defrecord does not implement IFn .. while it behaves very similar to map otherwise ..

2010-12-30 Thread Alex Osborne
Alex Baranosky writes: > I've been playing with making a macro to encapsulate Stuart's post, like this: > > (defmacro defrecord-ifn [name & args] >   `(defrecord ~name ~...@args >     clojure.lang.IFn >     (invoke [this key] (get this key > > (defrecord-ifn Foo [a b c]) > > (def foo (Foo. "A

Re: circular references

2010-12-29 Thread Alex Osborne
Todd writes: > 3. alter ref2 to have a reference (pointer) to ref1 > > user=> (dosync (ref-set aref2 {:a aref1})) > {:a # # # # > > > {:java.lang.StackOverflowError > > > > 4. So, I've got a stack overflow... What's the proper way to deal with > this? Are circular references like this not allo

Re: requiring files

2010-12-29 Thread Alex Osborne
Laurent PETIT writes: > 2010/12/29 Nicholas Wieland wrote: > > [...@slicingupeyeballs:~/kenji]$ lein repl Hehe, nice hostname. :-) > REPL started; server listening on localhost:21669. > kenji.core=> (:require 'kenji.hello) > > Stop! > Unles, *cough*, ":require" is a placeholder for

Re: printf output from threads

2010-12-28 Thread Alex Osborne
Robert McIntyre writes: > So there's some sort of "boxing" going on here where the nil produced > as the values of s-expressions are actually Objects which are nulls, > while literal nils are actually nulls? No, there's no boxing going on. They're both just regular Java nulls (and null is not a

Re: printf output from threads

2010-12-28 Thread Alex Osborne
Robert McIntyre writes: > seems there's no type hint required: > > (def t nil) > (Thread. t) > > also works... > > How are you able to determine that it's calling the String constructor? > > --Robert McIntyre Ah, no I'm wrong. I was jumping to conclusions. It's the Runnable one: (let [^String

Re: printf output from threads

2010-12-28 Thread Alex Osborne
Robert McIntyre writes: > what the heck... > > mailing-list.print-from-threads> (Thread. ((constantly nil))) > # > mailing-list.print-from-threads> (Thread. ((fn []))) > # > mailing-list.print-from-threads> (Thread. ((fn [] nil))) > # > mailing-list.print-from-threads> (Thread. (let [this-is-ni

Re: printf output from threads

2010-12-27 Thread Alex Osborne
justinhj writes: > On Dec 26, 11:42 pm, Alex Osborne wrote: > (defn test-threads [n out] > (dotimes [x n] > (.start (Thread. (#(sleeper-thread %1 %2 %3) out x (+ 2000 (rand- > int 5000))) Ah. The problem is here. You're calling that lambda in the main thread

Re: printf output from threads

2010-12-26 Thread Alex Osborne
justinhj writes: > I tried passing *out* to my thread function and then binding it to > *out* in the thread, and this works but then makes the threads execute > one at a time, and I'm presuming that is because my use of *out* in > the binding block is blocking for the other threads which use it.

Re: Question about when to use protocol+record and compilation warnings

2010-12-26 Thread Alex Osborne
Ken Wesson writes: >> Actually you don't need to AOT compile records or types. They work fine >> for interactive development. > > Eh. That's not what I saw written elsewhere. Or is it just protocols? > Though usually those are used hand-in-hand with records. Perhaps you're thinking of gen-class?

Re: complex number performance enhancement...

2010-12-26 Thread Alex Osborne
Sunil S Nandihalli writes: > thanks Alex for your response . I tried it ... It compiled fine .. but the > double dispatch does not seem to work correctly .. > > It some how reverses the arguments and then dispatches to the correct > function for the reversed arguments and the function works prop

Re: Question about when to use protocol+record and compilation warnings

2010-12-26 Thread Alex Osborne
Ken Wesson writes: > On Sun, Dec 26, 2010 at 7:18 PM, Alex Osborne wrote: >> Struct maps were in the language for a long time before defrecord was >> added.  Records are supposed to replace them for most purposes.  So if >> in doubt between the two use a defrecord. >

Re: complex number performance enhancement...

2010-12-26 Thread Alex Osborne
Sunil S Nandihalli writes: > http://paste.lisp.org/display/93387 > > It uses protocols and deftype I noticed that it was an old post .. I > could not get it to compile to try it out.. I was complaining about > likes of trying to convert a name-space-qualified to a type name > .. w.r.t ::Complex .

Re: Question about when to use protocol+record and compilation warnings

2010-12-26 Thread Alex Osborne
Damon Snyder writes: > One of the decisions I wasn't sure about was whether to use a protocol > or a struct map for the (socket, reader, writer) tuple. I started > using a struct-map and then switched over to defprotocol/defrecord. > See > https://github.com/drsnyder/beanstalk/blob/82f301f1f825b

Re: partitioning iterative list

2010-12-24 Thread Alex Osborne
Glen Rubin writes: > Can I do the following without using loops?? > > I have list, e.g. > > '(4 6 66 33 26 6 83 5) > > I want to partition it so that I get a subset of lists that build up > to the original: > > ( (4) (4 6) (4 6 66) (4 6 66 33) ) (reductions conj [] [4 6 66 33 26 6 83 5]) =>

Re: pods?

2010-12-24 Thread Alex Osborne
Michael Ossareh writes: > Is there a go to place for a roadmap? http://dev.clojure.org/ perhaps? There's no roadmap as such, Clojure development is not calendar-oriented. ;-) Last December when people started asking this question Rich said: I don't like to publish roadmaps, as often the be

Re: leiningen run

2010-12-24 Thread Alex Osborne
Marek Kubica writes: > My project is currently quite simple. The program needs a single > argument, filename, to read from. So I added a :main entry into > project.clj and started > > $ lein run > > this took some time and crashed with an exception, because I did not > specify a file. Well, that

Re: Calling Clojure from Java

2010-12-22 Thread Alex Osborne
Mark Engelberg writes: > Looks easy, but your dance and speak methods don't return a value > which leaves a question in my mind... > > If the protocol implementation actually returns a value, do you have > to explicitly typecast it in Java from Object into the desired type? Yep, certainly. A Cl

Re: Calling Clojure from Java

2010-12-22 Thread Alex Osborne
Mark Engelberg writes: > Are there any examples available of creating a compiled > class/interface with deftype and defprotocol, and using these from > Java? It's pretty straightforward and works exactly how you might expect it to. Create a new project: $ lein new interop Define a type and

Re: Ah-hah! Clojure is a Lisp

2010-12-20 Thread Alex Osborne
Ken Wesson writes: >> * OO programs conflate value, state, and identity. > > Ah. So, like the confused situations you get with Java's mutable > collections. I just thought of a non programming language example which might help explain what "state and identity conflation" means. The web (as trad

Re: Ah-hah! Clojure is a Lisp

2010-12-19 Thread Alex Osborne
Ken Wesson writes: > Ah. So, like the confused situations you get with Java's mutable > collections. Two lists are equal if they have the same contents in the > same order -- but then you use one as a key in a hashmap, and then add > an item to it, and boom! Clojure separates this stuff out becau

Re: about the repl

2010-12-18 Thread Alex Osborne
Stuart Sierra writes: > If your REPL implementation runs each command in a new Thread (as most > of them do, I think) it can just stop the thread. That won't work in > every situation (for example, a thread blocked waiting for I/O) but it > will get you out of an infinite sequence. For just a

Re: Possible to use << from clojure.contrib.strint with a string variable

2010-12-16 Thread Alex Osborne
Michael writes: > I'm trying to use << from clojure.contrib.strint perform string > interpolation in a string variable. The following, > (def s "v: ~{v}") > (println (<< (str s))) > (println (<< s)) This is not going to be possible (at least not efficiently: you could technically do itwith &en

Re: Writing apps in clojure and/or java : Binary Search Trees

2010-12-15 Thread Alex Osborne
Todd writes: > At the end of the day, I'm not sure how valid this exercise is. I'm > certainly slowly learning clojure...but perhaps learning by way of > what not do do. Unfortunately I don't think there's yet any Clojure books that really focus on teaching functional programming itself like the

Re: Writing apps in clojure and/or java : Binary Search Trees

2010-12-15 Thread Alex Osborne
Alex Osborne writes: > Todd writes: > >> So far, my experience implementing basic BST functionality in clojure >> has felt contrived, and was definitely easier in java. > > As others have said, implementing mutable data structures in Clojure is > going against the gr

Re: Writing apps in clojure and/or java : Binary Search Trees

2010-12-15 Thread Alex Osborne
Todd writes: > My main question is, what tasks/apps is clojure ideally suited for? > > I've been playing with implementing Binary Search Trees in clojure and > Java as a way to learn clojure and compare the two languages. My > original thought was to implement some basic data types and algorithms

Re: Yegge's "Lisp is not an acceptable Lisp" - was he talking about Clojure?

2010-12-14 Thread Alex Osborne
javajosh writes: > Just ran across: > > http://steve-yegge.blogspot.com/2006/04/lisp-is-not-acceptable-lisp.html > > Whoah! I had no idea there was so much, uh, 'intricacy' going on > behind Lisp. :) > > Anyway, it was interesting to read it having a bit of Clojure under my > belt. With the exc

Re: OOM with Agents

2010-12-10 Thread Alex Osborne
Michael Ossareh writes: > There are 54874 companies in the companies var. The OOM tends to take place > when there are 1000 or so companies to process. > > What is likely to be causing this issue? I replied on IRC but just recapping here. I think you've probably been bitten by the way Java str

clojure@googlegroups.com

2010-12-09 Thread Alex Osborne
Sunil S Nandihalli writes: > I would like to know what meta info does &form that get passed to > your macro.. actually contain? I am able to only get the line > number.. Is there a way to get the file name aswell? The currently evaluating/compiling file (if it is a file and not the REPL or some

Re: Unable to run Clojure (jline is missing)

2010-12-08 Thread Alex Osborne
HB writes: > I checked clj script under the script directory: > > #!/bin/sh > > CLASSPATH=src/clj:test:test-classes:classes/:script/ > jline-0.9.94.jar:../clojure-contrib/target/clojure-contrib-1.2.0- > SNAPSHOT.jar > > if [ -z "$1" ]; then >exec java -server jline.ConsoleRunner clojure.main

Re: Why I'm getting StackoverflowError?

2010-12-05 Thread Alex Osborne
HB writes: > Ken & Alex, > Why you aren't calling empty? when you want to check if a collection > is empty? Here's the definition of empty? from clojure/core.clj: (defn empty? "Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than

Re: Why I'm getting StackoverflowError?

2010-12-05 Thread Alex Osborne
HB writes: > OMG, this is too much Clojure code for me to handle O.o > Alex, you just killed me :) Hehe, sorry. Just thought it might be helpful to show the progression of dealing with all the little edge cases. It perhaps looks much more fiddly, but you're doing more there than common lisp:

Re: Why I'm getting StackoverflowError?

2010-12-05 Thread Alex Osborne
HB writes: > I'm trying to write a function that calculates the length of a list: > > (defn list-length [col] > (if col > (+ 1 (list-length(rest col))) > 0)) > > > (list-length '(Java, Clojure, Scala)) > > Upon running it in the REPL, I got the error: > java.lang.StackOverflowError (tes

Re: Pre-expansion macro form

2010-12-05 Thread Alex Osborne
Brian Marick writes: > Is there any way to get the original call form? Something like &env? Some > hook into the reader? Try &form -- 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 t

Re: what does the value part of &env map automatically passed to all macros contain?

2010-12-03 Thread Alex Osborne
Sunil S Nandihalli writes: > I really like the &env. It has saved a lot of tedious work a couple of > times .. but I have only found use for the keys of the map that gets > passed like in the following example. > I don't understand what the val part of the map contains? I have > failed at attem

Re: Tailing a file in Clojure

2010-12-03 Thread Alex Osborne
patrickdlogan writes: > Java has a file watch API to avoid polling. I assume you're talking about the NIO 2 watch service? That's not yet in a released version of Java, it's coming in Java 7. > Stuart Sierra uses it to good effect in lazytest. It looks to me like lazytest polls the last modif

Re: Tailing a file in Clojure

2010-12-02 Thread Alex Osborne
viksit writes: > What would you recommend as the best method to tail a file using > Clojure? Are there any built in functions in contrib or core that > allow a program to read the last line of a file as it is appended to? > If not - how do people solve a problem like this? > > My aim is simple -

Re: Ring startup processing?

2010-12-01 Thread Alex Osborne
Ken Wesson writes: > It looks an awful lot like swap! itself is implemented with a polling > sleeplock instead of using the language's own lock. :) I suppose it's similar to a spinlock simply because it keeps retrying, like a spinlock keeps retrying to acquire. Very different semantics though:

Re: Ring startup processing?

2010-12-01 Thread Alex Osborne
Ken Wesson writes: > Retries? We were discussing an atom here, not a ref. A dosync > transaction may be retried. The obvious implementation for swap! would > be (locking inner_value (set! inner_value.contents (apply fun > inner_value.contents))) (warning: pseudocode, I assume this stuff > would a

Re: Ring startup processing?

2010-11-30 Thread Alex Osborne
Ken Wesson writes: > I put a println in a swap! function once and the world didn't end. For a println retries are usually harmless, it just means you'll occasionally get doubled output. But it's not a good thing for a general-purpose runonce fn whose entire reason for existence is to ensure som

Re: Ring startup processing?

2010-11-30 Thread Alex Osborne
Ken Wesson writes: > On Tue, Nov 30, 2010 at 5:27 PM, Robert McIntyre wrote: >> (defn runonce >>  "Create a function that will only run once. All other invocations >>  return the first calculated value. The function can have side effects. >>  Returns a [has-run-predicate, reset-fn, once-fn]" >>

Re: Clojure benchmark memory use and future improvements (Re: Clojure vs F# performance)

2010-11-28 Thread Alex Osborne
John Fingerhut writes: > Does anyone know a way from within a Java/Clojure program to determine > which GC algorithm is currently in use? I'm curious what the default > is when one is not specified on the command line, and accessing the > one being used from inside of a program would be one good

Re: Understanding clojure bindings

2010-11-27 Thread Alex Osborne
Andreas Kostler writes: > Is this a 'bug' with eval? No, eval is a simply a function and so like any other function it can't "see" the lexical (local) environment which it was called from. Doing this: (let [a 1, b 2] (eval '(+ a b))) Is similar to doing this: (defn cake [] (+ a

Re: Ring startup processing?

2010-11-27 Thread Alex Osborne
Mike Meyer writes: > My simple web app > (http://blog.mired.org/2010/11/x10-controller-in-clojure.html) has > some stuff that needs to happen just once (in this case, opening the > serial port). It's not clear how to get this to happen using ring. If > I do it inside my ring handler, then it gets

Re: Why isn't there a fold-right?

2010-11-27 Thread Alex Osborne
"nicolas.o...@gmail.com" writes: > I doubt there is a foldr that handles the infinite list. > To do anything, it would have to read at least one element: the last. > > Alex nice answer is a foldl. Actually I think you have them backwards. Wikipedia has a pair of diagrams which I find very usefu

Re: Use of nested class to acces an enum

2010-11-26 Thread Alex Osborne
Alex Osborne writes: > benjii writes: > >> (ns org.codingkata.unit.MyKata >> (:import (org.codingkata.unit.api.BaseKataSolution) >> (org.codingkata.unit.api.BaseKataSolution$Day)) >> (:gen-class >>:extends org.codingkata.unit.api.BaseKa

Re: Use of nested class to acces an enum

2010-11-26 Thread Alex Osborne
benjii writes: > Hi, i'm pretty new to clojure. > To help me to progress i'm trying to solve the kata available on > codingkata.org > I'm doing the ovie-tickets kata. > As you can se on the site, to complete this kata we need to acces to a > enum wich is a nested class. > > My problem is that

Re: Autodoc dependencies broken?

2010-11-26 Thread Alex Osborne
James Reeves writes: > I've just tried installing autodoc 1.7.1 and 0.8.0-SNAPSHOT via > Leiningen and Clojars, and it seems to be missing some dependencies > (specifically org.apache.maven:super-pom:jar:2.0). *sigh* This is a case of Maven being totally misleading and also a case of death by s

Re: Why isn't there a fold-right?

2010-11-26 Thread Alex Osborne
tpeng writes: >> (defn foldr [f coll] >> (reduce #(f %2 %1) (reverse coll))) > but this foldr can't handle the infinite list, am i right? Correct. In a lazily evaluated language like Haskell you can have a combining function which doesn't always evaluate its arguments and thus only partially

Re: sort-by reverse order?

2010-11-21 Thread Alex Osborne
Alex Baranosky writes: > So for the case I had that method worked.  I wonder though if I had > wanted to sort by multiple keys, with some of the keys sorting in > reverse order and others in regular order, how I could do that...  Say > last name ascending, date of > birth descending for example.

Re: sort-by reverse order?

2010-11-21 Thread Alex Osborne
Glen Stampoultzis writes: > (sort-by :last-name #(compare %2 %1) persons) > > > Actually having put forward that second example there I'm not sure how > it actually works. The docs suggest that the 2nd parameter needs to > implement Comparator (peeking at the source confirms this) but co

Re: sort-by reverse order?

2010-11-21 Thread Alex Osborne
Alex Baranosky writes: > I'm trying to figure out how to use sort-by in reverse order. I tend to do this: (sort-by :foo #(compare %2 %1) coll) -- 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: Jython Interoperability problem

2010-11-20 Thread Alex Osborne
Dilvan writes: > Do you know how can I "bootstrap" Clojure before using any Clojure > specific data structure (from Java or Jython)? It seems to be fine if you put it on the Java system classpath instead of python.path: $ jython -J-cp clojure-1.2.0.jar Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2

Re: why does (clojure.repl/source in-ns) not work while (doc in-ns) gives the documentation?

2010-11-20 Thread Alex Osborne
Sunil S Nandihalli writes: > why does (clojure.repl/source in-ns) not work while (doc in-ns) gives > the documentation? in-ns is implemented in Java code. There's no (Clojure) source for it to show you. Another one is load-file. -- You received this message because you are subscribed to the

Re: Ghost Vars?

2010-11-18 Thread Alex Osborne
Alyssa Kwan writes: > Perfect! That makes things so much easier! I assume that interning > vars is synchronized then? This is the second big source code read > FAIL in two days. Obviously I can't read. :) They're stored in an AtomicReference (basically an atom). > All persistence requires

Re: Ghost Vars?

2010-11-17 Thread Alex Osborne
Hi Alyssa, Alyssa Kwan writes: > For what I'm doing (making functions durable), it raises the > question: If you persist a function that points to a var, restart the > JVM, and deserialize/load the function from a data store, what should > happen? So you're doing something like this? (def

Re: Ghost Vars?

2010-11-17 Thread Alex Osborne
Alyssa Kwan writes: > I understand exactly why this situation exists. I just think the > behavior is unexpected. When I create a function with a dynamic > binding, I expect the function to keep a reference to the *name*, not > the var that the name resolves to at compile/clinit time. Oh, I see

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-17 Thread Alex Osborne
Alyssa Kwan writes: > In any case, I am using Github master and I thought I was using 1.2. > 1.2 has self-references lexically bound, as David Sletten points out, > which I agree is the correct behavior. But something has happened on > 1.3 alpha that has changed that. I don't know if it's inten

Re: Ghost Vars?

2010-11-17 Thread Alex Osborne
Hi Alyssa, Alyssa Kwan writes: > ns-unmap isn't typically used. But for durability, we can think of > JVM shutdown/startup as unmapping everything and starting fresh. > Therefore, expected behavior for ns-unmap should be the same as > behavior for deserializing and loading an object after a new

Re: Proposal: Digest

2010-07-12 Thread Alex Osborne
Hi David, David Soria Parra writes: > any feeback on this so far? >> A typical example would be: >> (digest-to-str (digest "hello world" :algorithm "SHA-1")) "digest-to-str" is a bit misleading as hexadecimal digits are not the only way you can represent a digest as a string: base 64 and base 3

Re: how to develop patches to libraries

2010-05-13 Thread Alex Osborne
Brian Wolf writes: > Whats the idiomatic or best method to develop patches to pre-exisitng > libraries using clojars, do I git the source to my computer, put put > [lein-clojars "0.5.0"] in project file, obviously renaming the > project, and do I take original dependenicies out, or leave in, or

Re: Primitive arithmetic and mod

2010-05-03 Thread Alex Osborne
Brian Watkins writes: > I'll try rem for time but I see that I still have to cast to long; > Clojure doesn't think (rem (long ) (long x)) is a long. The > error is "recur arg for primitive local: nf must be matching > primitive." Looks like it's casting it back to an integer. Also look

Re: About paths

2010-05-03 Thread Alex Osborne
Paulo Candido writes: > I have a script, say "foo.clj" in a namespace "com.company.ns". > "foo.clj" uses functions from another script, "bar.clj" in the same > namespace. "foo"'s namespace has the line "(:use com.company.ns.bar)". > It works in the REPL, it works inside Netbeans with Enclojure. >

Re: Clojure Concurrency Screencast Available

2010-05-01 Thread Alex Osborne
e writes: > Can you imagine how disruptive it would be at this point to do it the > other way around?  If you were starting out today without any Lisp > baggage, it seems TOTALLY obvious to me that lists would have been (1 > 2 3), and the *calling of a function* would have been the different > th

Re: rand-int with bignums

2010-05-01 Thread Alex Osborne
Lee Spector writes: > Sorry, the expression in my first sentence should have been "(. (new > java.util.Random) (nextInt X))", not "(. (new java.util.Random) > X)". In any event the real question isn't about this call but about > how Clojure's rand-int should handle bignum arguments and about how

Re: labrepl: kl...@feersum:~/projects/labrepl$ script/repl java.lang.ExceptionInInitializerError (control.clj:9)

2010-04-30 Thread Alex Osborne
klang writes: > laprepl starts up with the following error and localhost:8080 does not > respond > > kl...@feersum:~/projects/labrepl$ script/repl > Clojure 1.2.0-master-SNAPSHOT > java.lang.ExceptionInInitializerError (control.clj:9) Looks like labrepl is not locked to a particular version of Cl

Re: Does clojure.contrib.io.slurp work with binary files?

2010-04-29 Thread Alex Osborne
Hi Matt, Matt Culbreth writes: > I'm using slurp to read data from a file and send it to a stream, but > sometimes that's failing. I've got a theory that it has to do with > slurp not reading binary data correctly. Is that true? Do I need to > go down to the lower level Java classes and build

Re: Try + finally question

2010-04-29 Thread Alex Osborne
ka writes: > Above I wrote a macro with-open-flexi! ... which I'm planning to use > in my app's API . .. please let me know if there are any bugs / > gotchas / improvements etc... > > I didn't get any responses, so does it means there is something so > obviously wrong that you can't even begin wh

Re: Beginner's question regarding implementing a constructor using gen-class

2010-04-28 Thread Alex Osborne
Gregg Williams writes: > Now I'm working on > the "Graph Editor" program described at > http://www.piccolo2d.org/learn/grapheditor.html > . > > In this sample program (which you don't really need to look at) I need > to subclass a Piccolo2D class to create a class named GraphEditor , > but unlik

Re: Beginner's question regarding implementing a constructor using gen-class

2010-04-28 Thread Alex Osborne
Hi Gregg, Gregg Williams writes: > (ns genclassInteger > (:gen-class >:extends [java.lang.Integer]) > ;(:import (java.lang Integer)) ; < unnecessary, right? > ) > - > > This returns the error: > > Exception in thread "main" java.lang.ClassNotFoundException: > [java/lang/

Re: Adding an option to clojure.main

2010-04-24 Thread Alex Osborne
Phil Hagelberg writes: > So it seems like recently the only thing I use AOT for is producing > -main functions that can be easily run from the command-line. I've > found that an alternate to this is to use clojure.main -e, require the > necessary namespace, and then call (apply -main *command-lin

Re: Documentation (was: Re: duck-streams missing from clojure-contrib.jar file)

2010-04-22 Thread Alex Osborne
Douglas Philips writes: > Looking at the clojure.org front page, there is no "roadmap" link, or > anything that seems to be like that, to know what is on the radar, There's no formal roadmap as such, most open-source projects just don't tend to work that way. Working notes and ideas are often p

Re: request for comments/code-review - clojure implementation of unifier

2010-04-21 Thread Alex Osborne
Kevin Livingston writes: >> Not at all. next is basically #(seq (rest %)); you might want to use >> it when the extra bit of strictness is beneficial to your code and you >> shouldn't use it when it isn't. > > oh, ok. I saw some posts on using the new super-lazy lists / code and > it implied tha

Re: duck-streams missing from clojure-contrib.jar file

2010-04-21 Thread Alex Osborne
Stuart Halloway writes: > The second level header tells you the branch (e.g. master). On the > left hand side is a list of branches (so you can click on e.g. 1.1.x). > > Some ways I see this might be better: > > (1) make clear what master currently equals (right now it is 1.2 alpha) > (2) highlig

Re: Try + finally question

2010-04-21 Thread Alex Osborne
ka writes: > The whole code gets cluttered with all these try finally (and one > catch) statements. > > (try > (let [conn1 (API1/getConnection ..)] > (try > (let [conn2 (API2/getConnection ..)] > (try > ( ... Do something with conn1 conn2

Re: duck-streams missing from clojure-contrib.jar file

2010-04-21 Thread Alex Osborne
Hi Neal, Neal writes: > I'm trying to use duck-streams, but it is missing from the clojure- > contrib JAR file (at least in build #81). I have listed the contents > of the JAR file and confirmed that it is not in there. It sounds like you're using a 1.2 pre-release snapshot build of clojure-co

Re: Try + finally question

2010-04-21 Thread Alex Osborne
ka writes: > How can I do something like ... > > (try > (let [conn (API/getConnection ..)] > ()) > (catch ..) > (finally (if conn (API/closeConnection conn > > Problem is that conn is unavailable in the finally context. Why not just have two try blocks? (try (let [conn (API/g

Re: copious FAIL when building clojure-contrib HEAD

2010-04-20 Thread Alex Osborne
B Smith-Mannschott writes: > expected: nil > actual: java.lang.IllegalArgumentException: No method in multimethod > 'sqrt' for dispatch value: :clojure.contrib.complex-numbers/complex Just thought I'd expand on what the problem was. I was able to reproduce this on an older Linux machine and n

Re: numbers at the end of generated class name using compile

2010-04-13 Thread Alex Osborne
Travis writes: > I'm just curious where those numbers come from. For example, if I > compile the class bar.clj containing: > > (ns bar) > (defn foo [] > nil) > > I'll get three classes, one of which is: > > bar$foo__5.class The numbers are just a global incrementing counter (the same one used

Re: ANN: lein-search

2010-04-09 Thread Alex Osborne
Per Vognsen writes: > Nice! Towards a similar purpose, I wrote a little Emacs hack last week > that web-scrapes clojars.org and inserts the artifact declaration at > the cursor. Since I had to rely on their search feature, I couldn't do > proper regular expression matching. I've cronned a job t

Re: My non-ELPA Emacs swank-clojure setup

2010-04-08 Thread Alex Osborne
Tassilo Horn writes: > To get swank-clojure.jar I need to check out the project from github and > use "lein jar" to generate the jar, right? Or is it possible to > download a ready-made jar? You can just download it by hand from Clojars if you like: http://clojars.org/repo/swank-clojure/swank-

Re: My non-ELPA Emacs swank-clojure setup

2010-04-08 Thread Alex Osborne
Tassilo Horn writes: > To me, all this stuff seems to magical, for example that swank-clojure > downloads the required clojure/contrib jars (at least the comment in the > el-file says so). How do I know what version it will fetch? How does > it know when to update those jars? It will only down

  1   2   3   >