Clean doesn't allow mutation, so it has to do tricks like this or else
you'd never be able to write a useful program.
Clojure gives you a set of data structures that do very fast
non-destructive update. Clojure also gives you tools like atoms,
refs, and full access to Java's mutable behavior to
On Jan 7, 7:14 pm, "Brian Doyle" wrote:
> (defn write-bytes
> "Writes the bytes from the in-stream to the given filename."
> [#^java.io.InputStream in-stream #^String filename]
> (with-open [out-stream (new FileOutputStream filename)]
> (let [buffer (make-array (Byte/TYPE
Thanks for your help with this problem, Bill.
The function you provided causes slime-repl-set-package to suggest the
correct namespace, which is convenient. It doesn't appear to have any
effect on my problem though.
--~--~-~--~~~---~--~~
You received this message b
A few days ago, Stuart Halloway and I had an offline discussion about
some of the "gotchas" related to Clojure's laziness. He encouraged me
to blog about my thoughts on the matter.
On a related note, about a month ago, I posted comments about
Clojure's laziness. Rich's response was:
"The argum
I have just added a new module for handling (finite) probability
distributions to clojure-contrib. Some examples are included as well,
but for those who want to see the examples without downloading the
clojure-contrib source code, I also uploaded them to the files
section of this group:
Hey Conrad, this is great. The only suggestion I'd make is that often
times you want a probability distribution which is updatable over
time. This happens in online learning as well as Gibbs sampling where
you always only implicitly store the posterior b/c it's changing
constantly. So in my resea
> Clojure gives you a set of data structures that do very fast
> non-destructive update. Clojure also gives you tools like atoms,
> refs, and full access to Java's mutable behavior to specify update in
> place if that's what you want.
Yes, I can see that one could implement this oneself
via Java
Hi Mark,
I don't think this approach works in Clojure / Swing, but I may be
mistaken, I often am.
The issue is the event thread. In Abhishek's original and it's derivatives
the Swing event thread is used and the timer pushes events into it so key
press events and the game timer run in the same
user=> (load-file "clj_record/core.clj")
I got clj_record/util not in system path. Why is it so?
Emeka
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to clojure@go
On 08.01.2009, at 11:22, Mark Engelberg wrote:
> So my blog post has a dual purpose. First, I explain the "gotcha"
> that Stuart and I discussed. Second, I report back to the community
> about the actual experience I had in the past month, exploring
> laziness in Clojure. I decided to blog it
On 08.01.2009, at 11:38, aria42 wrote:
> Hey Conrad, this is great. The only suggestion I'd make is that often
> times you want a probability distribution which is updatable over
> time. This happens in online learning as well as Gibbs sampling where
Definitely. The current module for transformi
On Jan 8, 7:26 am, Konrad Hinsen wrote:
> On 08.01.2009, at 11:22, Mark Engelberg wrote:
>
> > So my blog post has a dual purpose. First, I explain the "gotcha"
> > that Stuart and I discussed. Second, I report back to the community
> > about the actual experience I had in the past month, exp
On Thursday 08 January 2009 01:28, James Reeves wrote:
> On Jan 7, 7:14 pm, "Brian Doyle" wrote:
> > (defn write-bytes
> > "Writes the bytes from the in-stream to the given filename."
> > [#^java.io.InputStream in-stream #^String filename]
> > (with-open [out-stream (new FileOut
Hi.
I'm just wondering wether it's a feature or a bug:
(if (= (meta (with-meta [] {:test-key true}))
(meta #^{:test-key true} []))
"same"
"not same")
=>
"not same"
This behaviour is repeatable for empty lists, vectors and maps. Is
this intentional? Nonempty collections work as expe
On 08.01.2009, at 14:55, Rich Hickey wrote:
> difference to the consumers of your sequence" is simply untrue. The
> promise of the abstraction is not merely that the nth item/rest will
> be equal - it is that it will be identical. I.e. a seq is persistent
> and immutable. There's nothing wrong wi
Isn't there a (roughly) 64k limit on the bytecode for any given
method? There's definitely some kind of JVM limit.
RJ
On Jan 7, 12:12 am, Michiel de Mare wrote:
> I'm converting a Ruby DSL into Clojure, and I'm running into some
> problems. I keep getting errors like this one:
>
> java.lang.Cla
On Jan 8, 2009, at 8:55 AM, Rich Hickey wrote:
>
>
>
> On Jan 8, 7:26 am, Konrad Hinsen wrote:
>> On 08.01.2009, at 11:22, Mark Engelberg wrote:
>>
>>> So my blog post has a dual purpose. First, I explain the "gotcha"
>>> that Stuart and I discussed. Second, I report back to the community
>
Time for another person named Mark to chime in. I expect to hear from
all the other Marks before this thread is over.
I have three responses to your suggestion:
1. Data: Is this really a problem that is slowing down Clojure
programs in practice? Can you provide some data to that effect? I
On Jan 7, 12:19 am, "Phil Hagelberg" wrote:
> The problem with this is that now you have to repeat your classpath in
> two places: your SLIME config and the shell script that you use to
> launch your app. This is a DRY[1] violation.
I guess I just take that for granted with Java. The classpath
Nice work, Allen. I want to add stubs/mocks to test-is. One question
-- would it work without Var.pushThreadBindings, maybe using a
combination of "with-local-vars" and "binding"?
I was also thinking of modifying "report" to throw AssertionError,
like your "throwing-report", so that I can get a
On Thu, Jan 8, 2009 at 5:08 AM, Tom Ayerst wrote:
> Hi Mark,
>
> I don't think this approach works in Clojure / Swing, but I may be
> mistaken, I often am.
>
> The issue is the event thread. In Abhishek's original and it's derivatives
> the Swing event thread is used and the timer pushes events
I incorporated most of James ideas but I don't like the name pipe-stream.
(defn write-stream
"Writes the data from the istream to the ostream."
([#^java.io.InputStream istream #^java.io.OutputStream ostream #^Integer
buffer-size]
(let [buffer (make-array (Byte/TYPE) buffer-size)]
The point, for me, is that Mark Engelberg's construct allowed the system to
work with no mutation and I don't think you can do it with Swing implemented
the way it is (your latest version puts the mutation in an atom).
Given that, and the problems with to threads accessing the Swing layer, I
think
On Thu, Jan 8, 2009 at 2:01 AM, Zak Wilson wrote:
>
> Thanks for your help with this problem, Bill.
>
> The function you provided causes slime-repl-set-package to suggest the
> correct namespace, which is convenient. It doesn't appear to have any
> effect on my problem though.
The slime-find-buf
>
> Do people want it now?
>
I would vote for 1.0 ahead of streams if adding streams now will delay
1.0.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to clojure@
On Thu, Jan 8, 2009 at 11:05 AM, Tom Ayerst wrote:
> The point, for me, is that Mark Engelberg's construct allowed the system to
> work with no mutation
I don't yet see how that is possible. The detection of key presses has
to happen in the Swing thread (by getting a call to keyPressed). That
th
On Jan 8, 10:27 am, Stuart Sierra wrote:
> Nice work, Allen. I want to add stubs/mocks to test-is. One question
> -- would it work without Var.pushThreadBindings, maybe using a
> combination of "with-local-vars" and "binding"?
>
It should be possible to make that work with binding. I did it
Mark, I thought your blog post was really, really good. I have
forwarded it to a lot of people; I hope you don't mind!
As far as caching goes:
I think, regardless of the theoretical considerations of = that
caching a lot of objects is ridiculous from a performance
perspective. Access to ram ta
On Thu, Jan 8, 2009 at 5:55 AM, Rich Hickey wrote:
> The
> promise of the abstraction is not merely that the nth item/rest will
> be equal - it is that it will be identical. I.e. a seq is persistent
> and immutable.
I get that Clojure is making a promise of identity here, which is not
possible i
On Thu, Jan 8, 2009 at 12:05 PM, Tom Ayerst wrote:
> The point, for me, is that Mark Engelberg's construct allowed the system to
> work with no mutation and I don't think you can do it with Swing implemented
> the way it is (your latest version puts the mutation in an atom).
Isn't a GUI by defin
On Jan 8, 2009, at 1:06 PM, Mark Engelberg wrote:
>
> On Thu, Jan 8, 2009 at 5:55 AM, Rich Hickey
> wrote:
>> The
>> promise of the abstraction is not merely that the nth item/rest will
>> be equal - it is that it will be identical. I.e. a seq is persistent
>> and immutable.
>
> I get that Cl
On Jan 8, 5:05 pm, "Brian Doyle" wrote:
> I incorporated most of James ideas but I don't like the name pipe-stream.
Then wouldn't copy-stream be better? write-stream isn't specific
enough, IMO.
Also, I don't think there's a huge amount of gain to be had from an
Integer type hint in this case, s
On Thu, Jan 8, 2009 at 10:20 AM, Rich Hickey wrote:
> On Thu, Jan 8, 2009 at 5:55 AM, Rich Hickey
> I think the real test of non-cached seqs is to swap them in for
> regular seqs, rebuild Clojure and some user libs and see what breaks
> and why. Then you'll see the dependencies on caching that e
A little time with the Clojure source and a debugger has been
illuminating.
In genclass.clj:gen-interface, the line:
(let [options-map (apply hash-map options)
results in this value for options-map:
{:methods [[(quote foo) [] []]], :name mypkg.ICompileTest}
It looks like "(quote foo)" is bei
There are two issues here that I'm seeing, first is that the list and
vector have different behavior, my understanding is that they are both
sequences and one should be able to perform the same operations on
them.
Second issue is that the behavior is inconsistent, if it is not
possible to sort tu
Hi all!
I encountered some corner cases where overflow checking for "-"
doesn't work as I would expect:
user=> (- Integer/MAX_VALUE Integer/MIN_VALUE)
-1
user=> (- Long/MAX_VALUE Long/MIN_VALUE)
-1
The problem seems to be that negating MIN_VALUE yields MIN_VALUE
again, so it slips through t
On Jan 8, 2009, at 1:55 PM, Dmitri wrote:
There are two issues here that I'm seeing, first is that the list and
vector have different behavior, my understanding is that they are both
sequences and one should be able to perform the same operations on
them.
I don't know more about the underlyin
Hi,
Am 08.01.2009 um 19:38 schrieb Greg Harman:
It looks like "(quote foo)" is being taken as the literal string name,
rather than evaluating to "foo". And it happens that the hex ascii in
the generated method name translates to: [](quote foo).
Seems suspiciously like a macro-time vs fn-time th
Hi again,
Am 08.01.2009 um 19:38 schrieb Greg Harman:
A little time with the Clojure source and a debugger has been
illuminating.
(gen-interface
:name clojure.example.IBar
:methods [[bar [] String]])
You find this example and further information on clojure.org.
http://clojure.org/compil
On Thu, Jan 8, 2009 at 11:34 AM, James Reeves wrote:
>
> On Jan 8, 5:05 pm, "Brian Doyle" wrote:
> > I incorporated most of James ideas but I don't like the name pipe-stream.
>
> Then wouldn't copy-stream be better? write-stream isn't specific
> enough, IMO.
>
Sure, write-stream works for me.
On Thu, Jan 8, 2009 at 12:36 PM, Brian Doyle wrote:
>
>
> On Thu, Jan 8, 2009 at 11:34 AM, James Reeves
> wrote:
>
>>
>> On Jan 8, 5:05 pm, "Brian Doyle" wrote:
>> > I incorporated most of James ideas but I don't like the name
>> pipe-stream.
>>
>> Then wouldn't copy-stream be better? write-str
Everything is fully up to date.
The test works. Setting the ns with (ns test) works, but if I use a
more complex ns form like (ns test (:use clojure.xml)), it fails to
set the ns.
As a workaround, (in-ns test) after the ns definition seems to work.
Unless there's some reason not to, I'll just do
I tried this again with the latest build from svn, and it seems that
lists may be running into a race condition due to their lazy nature:
Exception in thread "main" java.lang.RuntimeException:
java.lang.ClassCastException: clojure.lang.LazyCons cannot be cast to
java.lang.Comparable
On Jan 8, 2:
2009/1/8 Mark Volkmann
>
> On Thu, Jan 8, 2009 at 11:05 AM, Tom Ayerst wrote:
> > The point, for me, is that Mark Engelberg's construct allowed the system
> to
> > work with no mutation
>
> I don't yet see how that is possible.
We agree then.
> ...
>
> Can you explain in more detail the issu
2009/1/8 Tom Ayerst
> 2009/1/8 Mark Volkmann
>
>>
>> > while cleanly painting the board; the two thread
>> > approach flickers terribly when the snake is short.
>>
>> I could be wrong, but I don't think that flicker is related to my
>> choice of doing the painting off the EDT. I think it's just
Lists are not comparable (i.e., you can't do something like (< '(1 2
3) '(4 5 6))). So you can't sort a collection of lists, but you can
sort a collection of vectors (provided the vectors contain comparable
things). This is always the case; there is no inconsistency.
The reason you are sometime
I'd vote for increased priority to reaching 1.0 also because of
workplace constraints.
Kev
On Jan 9, 4:23 am, MikeM wrote:
> > Do people want it now?
>
> I would vote for 1.0 ahead of streams if adding streams now will delay
> 1.0.
--~--~-~--~~~---~--~~
You recei
I was playing around earlier while following Mark Engelberg's blog
post, and I found that to my surprise, when I exhaust the heap
(java.lang.OutOfMemoryError), it basically fails to pop up the window
that gives me the exception (where you can normally abort or throw the
cause), and the REPL itself
If streams are not a breaking change, my vote is to ship 1.0 and then
add them.
Stuart
> I've been holding off on integrating this as it is a fairly
> substantial change (under the hood, no change at all for consumers),
> introduces a new abstraction (though no impact until you use it), and
>
On Tue, Jan 6, 2009 at 2:53 PM, rzeze...@gmail.com wrote:
>
> On Jan 4, 6:05 pm, "Brian Doyle" wrote:
>> Is there some place where all of these vars are defined? Is there some way
>> programatically I can find
>> them all? Thanks.
>
> I'm bored, and as an excuse to write some code I thought I
On Thu, Jan 8, 2009 at 11:57 AM, Zak Wilson wrote:
>
> Everything is fully up to date.
>
> The test works. Setting the ns with (ns test) works, but if I use a
> more complex ns form like (ns test (:use clojure.xml)), it fails to
> set the ns.
>
> As a workaround, (in-ns test) after the ns definit
I think the main issue is that sort should behave consistently.
Possibly sort could check if the elements implement Comparable before
attempting to sort them? I also don't see a reason as to why the lists
shouldn't implement Comparable.
On Jan 8, 4:17 pm, "Mark Engelberg" wrote:
> Lists are not
Thanks, Meikel.
I feel a bit silly, but I do have it working now.
* Not quoting foo is more than superfluous; it was the primary cause
of my problem. I did study that clojure.org example, just missed the
lack of quote...
* There wasn't an example of a void return type and I assumed that,
like an
On Fri, Jan 9, 2009 at 7:55 AM, Tom Ayerst wrote:
> 2009/1/8 Mark Volkmann
>>
>> On Thu, Jan 8, 2009 at 11:05 AM, Tom Ayerst wrote:
>> > The point, for me, is that Mark Engelberg's construct allowed the system
>> > to
>> > work with no mutation
>>
>> I don't yet see how that is possible.
>
> We
Hi all,
A little while ago I released clj-backtrace, a library that produces
more readable backtraces for Clojure programs. I originally conceived
of the library as just a better (.printStackTrace *e) for use at the
REPL, but I've since found some other neat uses. I'd just like to
share some scre
Mark McGranaghan writes:
> I'd also be happy to answer any questions you have about using the
> library and to hear any general comments.
This looks great! I love the way they're aligned.
Have you looked at the way Rubinius (a smalltalk-style Ruby VM) prints
backtraces? It's pretty similar, al
Hello,
There is a difference in using (require) on a namespace if it was
compiled via (compile) or if it uses plain clj source files.
The difference appears if in the source file, you have for example top
level (println) commands.
If you (require) the namespace from compiled classes, you will n
Hello,
It seems that (compile) generates .class files as expected, and also
loads the lib in the environment as well.
Is it a (apparently undocument) feature ? Or a bug ?
And also, it seems that (compile) does not load the lib from the
compiled classes, but from the source files.
I guess that,
Hi all,
I can use file-seq
(file-seq (File. "."))
But how can I filter out all files ending with .clj?
Do we use re-find, re-seq etc?
thanks
sun
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To p
Here's one of many ways to do this:
(filter #(.endsWith (.getName %1) ".clj" ) (file-seq (java.io.File. ".")))
On Thu, Jan 8, 2009 at 5:48 PM, wubbie wrote:
>
> Hi all,
>
> I can use file-seq
> (file-seq (File. "."))
> But how can I filter out all files ending with .clj?
> Do we use re-find, r
On Jan 9, 12:48 am, wubbie wrote:
> I can use file-seq
> (file-seq (File. "."))
> But how can I filter out all files ending with .clj?
> Do we use re-find, re-seq etc?
You can just use filter:
(filter
#(.endsWith (str %) ".clj")
(file-seq (File. ".")))
- James
--~--~-~--~~-
thanks,
Is there anyway to specify regular expression, instead of startsWith/
endsWith?
-sun
On Jan 8, 8:00 pm, James Reeves wrote:
> On Jan 9, 12:48 am, wubbie wrote:
>
> > I can use file-seq
> > (file-seq (File. "."))
> > But how can I filter out all files ending with .clj?
> > Do we use re-
Hi!
(filter #(re-find #".clj$" %) … )
see http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html
(Boundary matchers)
Kind regards,
achim
On 9 Jan., 02:39, wubbie wrote:
> thanks,
>
> Is there anyway to specify regular expression, instead of startsWith/
> endsWith?
> -sun
>
> On
On 9 Jan., 03:03, Achim Passen wrote:
> (filter #(re-find #".clj$" %) … )
correction:
(filter #(re-find #"\.clj$" %) … )
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, se
I tried
(filter #(re-find #"\.clj$" %) (seq (file-seq(java.io.File. "."
-> java.lang.ClassCastException: java.io.File cannot be cast to
java.lang.CharSequence (NO_SOURCE_FILE:0)
On Jan 8, 9:06 pm, Achim Passen wrote:
> On 9 Jan., 03:03, Achim Passen wrote:
>
> > (filter #(re-find #".clj$
This works:
(filter #(re-find #"\.clj$" (str %)) (file-seq(java.io.File. ".")))
On Thu, Jan 8, 2009 at 7:16 PM, wubbie wrote:
>
> I tried
>
> (filter #(re-find #"\.clj$" %) (seq (file-seq(java.io.File. "."
> -> java.lang.ClassCastException: java.io.File cannot be cast to
> java.lang.CharSe
thank, it was str as usual.
On Jan 8, 9:22 pm, "Brian Doyle" wrote:
> This works:
>
> (filter #(re-find #"\.clj$" (str %)) (file-seq(java.io.File. ".")))
>
> On Thu, Jan 8, 2009 at 7:16 PM, wubbie wrote:
>
> > I tried
>
> > (filter #(re-find #"\.clj$" %) (seq (file-seq(java.io.File. "."
>
Phil,
Indeed, clj-backtrace was largely inspired by Rubinius' "Awsome
Backtrace" feature.
I've implemented and pushed to GitHub an experimental implementation
of colorized backtraces for the REPL:
In addition to the usual (pst) to pretty-print the last exception, you
can now (pst+) to colorized-
On Jan 8, 7:28 pm, lpetit wrote:
> It seems that (compile) generates .class files as expected, and also
> loads the lib in the environment as well.
>
> Is it a (apparently undocument) feature ? Or a bug ?
It's a feature. I think it's documented somewhere. :)
> And also, it seems that (compile)
Hi Mark F,
Thanks for your responses.
> 1. Data: Is this really a problem that is slowing down Clojure
> programs in practice? Can you provide some data to that effect? I
> would suggest writing a couple of Java benchmarks - one that updates a
> simple structure in place and one that only create
On Thu, Jan 8, 2009 at 5:55 AM, Rich Hickey wrote:
> When you
> ask for the nth element/rest, you get the identical item every time.
I know this is nitpicking, but if this is really the promise that the
seq abstraction is supposed to fulfill, then Clojure already violates
this:
(def a (seq [1 2
I don't understand how to use it, can you post an example?
I have tried everything and have gotten it to work under circumstances
I'm not sure of. However it doesn't work now.
(ns progs.netflix.parsing
(:require (progs.netflix [pg :as pg]))
(:import (java.sql Date)))
(load-file "C:/cloj
Oh, I mentioned this in my blog post, but perhaps it bears repating.
If cycle, repeat, and replicate were implemented behind-the-scenes
with LazySeq as opposed to LazyCons, they would still implement the
promise of identical elements for separate traversals, but would be
more efficient. Also, ran
On 9 jan, 04:03, Stuart Sierra wrote:
> On Jan 8, 7:28 pm, lpetit wrote:
>
> > It seems that (compile) generates .class files as expected, and also
> > loads the lib in the environment as well.
>
> > Is it a (apparently undocument) feature ? Or a bug ?
>
> It's a feature. I think it's documente
On 9 jan, 07:54, lpetit wrote:
> On 9 jan, 04:03, Stuart Sierra wrote:
> > > Later on, if I call (load) (from a fresh clojure environment) from the
> > > compiled classes, the top level (println)s are not executed, since not
> > > compiled.
>
> > Yes, that's the expected behavior. "compile" on
On Thu, Jan 8, 2009 at 11:38 PM, Dmitri wrote:
>
> I think the main issue is that sort should behave consistently.
> Possibly sort could check if the elements implement Comparable before
> attempting to sort them?
> I also don't see a reason as to why the lists
> shouldn't implement Comparable.
On Thu, Jan 8, 2009 at 11:20 PM, Christian Vest Hansen
wrote:
> Comparable implies that an Object can be reduced to a scalar value, if
> only for the purpose of comparing. How do you imagine this should work
> on list of arbitrary things?
Lexicographic ordering. Compare the first elements, if e
77 matches
Mail list logo