dosync is a way of ensuring whole stateful operation is done atomically.
(ie as if everything was happening in one step.)
That contradicts b). During a whole dosync, you can only see one state
of the world.
If you do not need atomicity, do multiple dosync.
You should create another abstraction
Another proof:
Let study the sequence sn = 0....9 , with n 9s.
Or s0= 0 and s(n+1) = sn + 9 / 10 ^n
lim sn = 0.9...
and lim sn = 1.
so
If I remember my meth correctly,
the number 0... does not exist.
This not a legal decimal sequence.
(Any decimal sequence finishing
(defn iterate [s]
(let [a (atom s)]
(fn []
(let [s @a]
(reset! a (next s))
(first s))
but it's not very idiomatic in clojure.
(In Lisp it is traditional to hide a state in a closure. A lot of toy
object language work like that)
On Thu, Oct 14, 2010 at
On Tue, Oct 12, 2010 at 8:35 PM, cej38 junkerme...@gmail.com wrote:
The more that I think about it, the more I would rather have a set of
equalities that always work. float= was a good try.
The only way to do so is to have numbers with infinite precision.
For example as lazy-seq of their
If you want to be really precise, most real numbers are an infinite
number of decimals.
If you encode them as a lazy seq of decimals, + - and other ops are doable.
Comparison is semi-decidable only: it terminates only in certain case
(finite number of decimals)
or when the number are different.
I had a similar error last time I tried.
Didn't manage to solve it.
On Fri, Oct 8, 2010 at 10:49 AM, Sunil S Nandihalli
sunil.nandiha...@gmail.com wrote:
I forgot to mention the versions...
My cake version is 0.4.18
and ruby version is ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
On
There is no java definition for (Number, long) or (Number, int).
As 1 is now a primitive, I think it cannot find any corresponding function.
Strangely, putting 1M or (num 1) might be faster.
Can someone try?
On Fri, Oct 1, 2010 at 10:28 AM, David Powell djpow...@djpowell.net wrote:
So, if
David pointed out what should have been the obvious overhead (I'll
blame it on being up at 2am), and Nicolas pointed out the specific
problem.
two solutions:
- writing all combinations of unboxed/boxed for every function
- having a more clever code generator that try to box every
primitive
The two styles are ok.
Matter of taste.
(partial ...) have probably a slight cost I wouldn't worry about
except if profiler tells me to worry.
The (partial...) style is called point-less, because you directly
manipulate the arrows and not the points.
It is the same kind of question as : should
I hadn't time to read the whole post, but, I I understand it well, this snipset
(defmacro with-context [options body]
`(let [context# (create-context options)
thread# (create-thread context)
sources# (atom {})
receivers# (atom {})]
(binding [init-receiver (partial
On Tue, Sep 28, 2010 at 12:03 PM, David Cabana drcab...@gmail.com wrote:
My standard practice is to split the (Emacs) screen, one side is a
Clojure mode edit session, the other a repl. Best of both worlds.
One can easily build up complex expressions as required, and still
easily evaluate
doseq do not return anything. (It is for side-effect only).
You might be looking for 'for'.
(doc for)
-
clojure.core/for
([seq-exprs body-expr])
Macro
List comprehension. Takes a vector of one or more
binding-form/collection-expr pairs, each followed by zero or more
Difficult problem.
macro are syntactic tools. So they are not made to evaluate things at runtime.
You could expand to something that call eval at runtime but it is not
a good idea (It involves the compiler at each call)
If your (rest alist) is known at macro-expansion time, then it can
work but
Your code was simple enough for me to make a couple of educated guesses. For
more complex code I'd use VisualVM, https://visualvm.dev.java.net/
David
I use that too.
Sampling for a first look, profiling with instrumentation for a more
precise answer.
(Here, the sampling gives even? and the
On Sat, Sep 25, 2010 at 3:40 PM, Jules julesjac...@gmail.com wrote:
Maybe this: (min-key #(abs (- % 136)) xs)
Wouldn't that be (apply min-key #(abs (- % 136)) xs)?
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
After profiling even seems effectively the culprit.
Some method reflector shows up too.
On Fri, Sep 24, 2010 at 6:15 PM, David Nolen dnolen.li...@gmail.com wrote:
(defn next-term [n]
(if (= (mod n 2) 0) (/ n 2)
(inc (* n 3
(defn count-terms [n]
(if (= 1 n) 1
(inc
Try
(defn even?
Returns true if n is even, throws an exception if n is not an integer
{:added 1.0
:static true}
[n] (zero? (bit-and (long n) (long 1
before your example.
It is fast on my computer.
(I believe there is a reflective call, without the explicit cast.)
--
You received
If you have a fixed geometry of cells, it is quite easy to have one
ref per cell.
Which reduce a lot of contention.
For example, on a grid where ant can go instead of representing the
world as a ref
to a matrix, you can represent the world as a matrix of refs.
Those refs can then be update
A first good start is to put
(set! *warn-on-relection* true) at the start of the file and removes
all reflective access.
Before the 1.3 release, function cannot receive/returns primitive so
you might consider
(defmacro next-gaussian []
`(.nextGaussian ^Random r))
(^Random is here to make sure
I was just saying that not returning something that is a pair, for
example nil, is good enough.
(unfold (fn [x] (when (= x 10) [(* x x) (inc x)])) would work.
Both function can be written with each other anyway.
And they don't have the same number of args so they are compatible
with each
(defn unfold
([grow seed]
(lazy-seq
(if-let [[elt next-seed] (grow seed)]
(cons elt (unfold grow next-seed)
([grow finished? seed]
(unfold #(when (not (finished? %)) (grow %)) seed)))
(unfold (fn [x] [(* x x) (inc x)]) #( % 10) 0)
(0 1 4 9 16 25 36 49 64 81 100)
I think that unfold (or co-reduce, or generate) should find its way in contrib.
I am not sure we need finished arg though. The traditional finish in
the seq family is nil.
My own version of unfold:
(defn unfold
(unfold seed grow) use the seed and a function grow that returns an
element and
Your example can be solved with (binding ...)
For the proposal, I think it's a bad idea : huge potential for abuse
(and importing abuse from other namespaces written by other people)
and little benefit.
I wouldn't be so strongly against it if it was in a delimited scope.
In any case, you can
You can also use binding eval evil brother : alter-var-root.
On Wed, Sep 15, 2010 at 8:04 PM, Richard Newman holyg...@gmail.com wrote:
My suggestion is inline with other commenters: use binding. If that doesn't
satisfy you, consider using or writing a preprocessor like m4.
--
You received
On Tue, Sep 14, 2010 at 2:35 PM, Belun alexandrurep...@gmail.com wrote:
why isn't the type of a function : clojure.lang.IFn ?
Actually you assume the existence of an unique type.
In most OO-language, and Clojure inherits that from its host, an
object has multiple types.
Indeed an object can be
, Chouser chou...@gmail.com wrote:
On Sun, Sep 12, 2010 at 9:04 AM, Nicolas Oury nicolas.o...@gmail.com wrote:
Oooops.
Ansered my question.
Haven't seen the patch in the git repository.
Will try to apply it to clojure 1.2.
I imagine you'll have some difficulty with that.
ClojureScript
Thanks for the link.
Very interesting indeed.
Didn't know about it.
On Mon, Sep 13, 2010 at 11:38 AM, Daniel Werner
daniel.d.wer...@googlemail.com wrote:
On Sep 13, 9:40 am, Nicolas Oury nicolas.o...@gmail.com wrote:
I switched to Parenscript for my small JS project, even if I's rather
have
Dear all,
I cannot manage to make ClojureScript work from clojure 1.2.0.
It seems that *compiler-analyse-only* used to exist but do not exist anymore.
Does someone know what it was and what replaced it?
Best regards,
Nicolas.
--
You received this message because you are subscribed to the
Oooops.
Ansered my question.
Haven't seen the patch in the git repository.
Will try to apply it to clojure 1.2.
On Sun, Sep 12, 2010 at 1:52 PM, Nicolas Oury nicolas.o...@gmail.com wrote:
Dear all,
I cannot manage to make ClojureScript work from clojure 1.2.0.
It seems that *compiler
So the problem is solved for me, although I have to use eval. I'm not
sure exactly how dirty this trick is and especially *why* it is
considered a smell. I read it on Paul Graham's On Lisp and he
vehemently opposes its use but he doesn't explain why or where it is
acceptable. Note that he
Dear all,
I am trying to use ClojureScrip for fun. (FOr the REPL now).
I can not find a translation to the javascript:
var image = new Image();
(def image (Image.)) or (def image (new Image)) does not work.
Any idea?
Best regards,
Nicolas.
--
You received this message because you are
can always do without them.
Best.
Nicolas.
On Wed, Sep 8, 2010 at 2:27 PM, MohanR radhakrishnan.mo...@gmail.com wrote:
So actually it looks like I need to understand type theory to
understand this.
Thanks,
Mohan
On Sep 7, 7:04 pm, Nicolas Oury nicolas.o...@gmail.com wrote:
...and report
is returned, just the initial argument to the
function.
I really want to understand what I did wrong here :-)
Stefan
On Sep 9, 9:08 pm, Nicolas Oury nicolas.o...@gmail.com wrote:
Yes.
Have someone (for example your editor), do your indentation for you.
By typing on tab on a good editor
Dear all,
I want to write a generic code that use count when it is O(1) and not
when it is not O(n),
is it a way to do so?
Best regards,
Nicolas
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
http://github.com/clojure/clojure
--
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 new members are moderated - please be patient with your
first post.
To unsubscribe
Dear all,
Clojure 1.2.0
(deftype A [ ^{:unsynchronized-mutable true} foo ]
Object
(hashCode
[x] (set! foo :foo)
http://clojure.org/namespaces
You should require clojure.contrib.monad and bot use it.
(ns my-namespace
(:require (clojure.contrib.monad :as m))
m/m-bind, for example.
Then you can define your own m-bind without conflict with an existing one.
On Tue, Sep 7, 2010 at 1:13 PM, MohanR
Dear all,
is there a function to map a function to all values in a map, keeping
the same keys?
Reducing from the seqed map seems a bit slower that what could be done
directly...
Best,
Nicolas.
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post
Different reactions:
1. The reduce solution is O(n .log n) + time of mapping elements, as
inserting in a map is O(log n). A tree with n leafs and arity at least
binary is of size at most 2n. So a map on a map could be done
in O(n) + time of mapping elements, but it would need a bit of
support
Multiple things:
the internal type name for int arrays is [I
So you should try something like:
(deftype T [^[I keys ]
)
then you are looking to overload equals and hashCode from the Object interface
(deftype T [^[I keys ]
Object
(equals [x other]
(java.util.Arrays/equals key (.key
I am not convince that (make-array Byte/TYPE *numbytes*) creates an
array of primitives.
And I think byte [] is an array of primitives.
That would make a difference.
I don't know if clojure has a byte-array. It seems that there is no
byte-array as there is int-array.
Could you try your code
On Tue, Aug 31, 2010 at 1:53 PM, Nicolas Oury nicolas.o...@gmail.com wrote:
I am not convince that (make-array Byte/TYPE *numbytes*) creates an
array of primitives.
Actually it does, sorry for the noise.
Should check before sending emails.
Best,
Nicolas.
--
You received this message because
One solution to remove it is to use when.
(when (not (empty? s)
(println (str Item: (first s)))
(recur (rest s
As there is only one case for a when, you can give multiple
instructions for this case without grouping them
Even better:
(when-not (empty? s)
(println
Replace also (unchecked-add count 1) with (unchecked-add count (int 1))
(this should get easier in 1.3)
On Tue, Aug 31, 2010 at 4:20 PM, tsuraan tsur...@gmail.com wrote:
(defn countnl-lite
[#^bytes buf]
(areduce buf idx count (int 0)
(if (= (clojure.lang.RT/aget buf idx) 10)
This one is quite good for me.
(defn countnl
[#^bytes buf]
(let [nl (int 10)]
(areduce buf idx count (int 0)
(if (== (int (aget buf idx)) nl)
(unchecked-inc count)
count
It appears that == is not resolved for bytes. So converting to int works
On Tue, Aug 31, 2010 at 8:43 PM, tsuraan tsur...@gmail.com wrote:
In this situation, inlining (int 10) does not buy much.
interesting; for me replacing the 10 with (int 10) brings my times
from 28.7ms to 19.6ms.
I meant putting (int 10) instead of nl and a let.
Anyway, it seems that we can
Dear all,
when you write a deftype and want to define a hashCode method, it
would be really great to have access to a macro
(construct-hash arg1 argn)
that would compute the hash code of each arguments and combine them in
a good way to produce a hash-code.
Is there anything like that in
I haven't had a lot of problems with stack-traces.
I would be happy to have more information on the context, though.
And maybe better reporting of exception occuring in a delayed context.
(when forcing a seq and the excpetion occurs under a lazy.)
In this situation I have sometimes fonud that
You can probably boost n-body on 1.2 by replacing arrays with deftypes.
(definterface BodyIsh
(^double getMass [])
(setMass [^double x])
(^double getPosX [])
.)
(deftype Body [^double ^{:unsynchronized-mutable true} mass ^double
^{:unsynchronized-mutable true} posX .]
BodyIsh
Clojure 1.3's performance improvements will significantly impact perf on
some of the benchmarks. If you are trying these out, please try them on
both 1.2 and 1.3.
Has Clojure 1.3 been released?
No, but since the num/prim/equiv work specifically targets performance, we
want to collect
On Tue, Aug 24, 2010 at 5:33 PM, Isaac Gouy igo...@yahoo.com wrote:
Well when Clojure 1.3 is released...
The phrase idiomatic code often seems to be used to mean - code
written in a natural way for that language and as if performance
doesn't matter - whereas I seem to have the strange notion
On Mon, Aug 23, 2010 at 3:45 AM, Victor Olteanu bluestar...@gmail.com wrote:
Some examples to illustrate this would be very welcome.
Any macro is an example of that.
For example, from clojure/core.clj
(defmacro -
Threads the expr through the forms. Inserts x as the
second item in the first
And it's usage is far less generalised than macros in LISP.
It is not an usual solution to write acamlp4 preprocessor.
On Mon, Aug 23, 2010 at 1:06 PM, Meikel Brandmeyer m...@kotka.de wrote:
Hi,
On 23 Aug., 14:03, Nicolas Oury nicolas.o...@gmail.com wrote:
If the AST of LISP were more
This seemed to be in clojure.parallel, but parallel is deprecated. Why is
it deprecated,
and what's the replacement for it?
I'd like to know that as well!
I am not sure, so don't believe this blindly.
I think it is due to changes in the plan for Java 7 and JSR266y.
Some of the dependency
On Sun, Aug 22, 2010 at 11:30 AM, Belun alexandrurep...@gmail.com wrote:
why does everything have to be a data structure ? like (operation
parameter parameter ...)
Because it makes really easy to do meta-programming.
If you want to generate some code, it is easier to do so if you just
have to
On Sat, Aug 21, 2010 at 6:33 AM, Toni Batchelli tbatche...@gmail.com wrote:
P-impl.))
(dotimes [_ 10] (time (dotimes [_ 1] (.m1 my-simple-P hello ;
Elapsed time: 131.973 msecs
Elapsed time: 142.72 msecs
Elapsed time: 95.51 msecs
Elapsed time: 95.724 msecs
Elapsed time: 83.646 msecs
m1 I meant.
Apologies.
On Sat, Aug 21, 2010 at 8:36 AM, Nicolas Oury nicolas.o...@gmail.com wrote:
On Sat, Aug 21, 2010 at 6:33 AM, Toni Batchelli tbatche...@gmail.com wrote:
P-impl.))
(dotimes [_ 10] (time (dotimes [_ 1] (.m1 my-simple-P hello ;
Elapsed time: 131.973 msecs
Elapsed
Just my 2 cents:
sometimes these algorithms are easier to implement by constructing an
infinite lazy trees of all the game, and
then independently writing a few strategy to explore the tree.
John Hughes gives an example of that in Section 5 of Why functional
programming matters, that can be
Clojure whitin a `(...) context resolves the name space of symbols.
This is most often what you want and prevent some name collisions at
macro expension.
But as binders can not be name-space resolved this do not allow to write:
`(let [and ])
this would expand to (let [ns/and ...]) which
I am not sure but I think filter will always output a sequence.
You can either:
- write filter-array using a loop/recur.
- read/write lazily the file in a sequence and use sequence function.
If it is possible in your situation, I would advise this one.
On Sat, Aug 21, 2010 at 4:42 PM, Piotr
- why does (+ 4.2 8.4) return 12.601 and (+ 1.5 2.6) 4.1?
Since 4.2, 8.4 and (+ 4.2 8.4) are java Doubles why does it not behave
as expected? What does clojure do in the background?
That's not a bug. Doubles have a standard. Clojure implementation
follows the standard.
(as most
There is a size limit on methods on the jVM.
partial-evaluator would be a cool project, I think.
On Thu, Aug 19, 2010 at 6:38 AM, Tim Daly d...@axiom-developer.org wrote:
Could the compiler insert phantom method bodies around classes?
Or does the JVM insist that you can't lie about the code
In which situation nil is not treated as false in Clojure?
If I understand well, Clojure separates nil/false from (). In
particular, if you use next and not rest, your iteration
example will work if translated into Clojure.
empty? works in all case and is not ugly either.
For the java typing
A few remarks:
## begin
(defn f-to-seq[file]
(with-open [rdr (java.io.BufferedReader.
(java.io.FileReader. file))]
(doall (line-seq rdr
Do you need the doall?
(defn str-sort[str]
(if (nil? str)
str
(String. (into-array (. Character TYPE) (sort str)
Congratulations!!
I am very happy with 1.2, as everybody I think. Great improvements to
my favorite language.
Your announcement got me curious: what are the future call linkage improvements?
Thanks to all of you, it's great.
Best,
Nicolas.
--
You received this message because you are
I use Ctrl+D. But I am on Linux.
On Thu, Aug 19, 2010 at 4:28 PM, Abraham Varghese abev...@gmail.com wrote:
How to exit from REPL?
--
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
A big part of inheritance can be done by using defrecord, keywords and
functions instead of method, and getting read of the abstract class.
(defrecord Orange [:mass :energy :juice])
(defrecord Apple [:mass :energy :juice : family])
(defn get-juice [fruit] (:juice fruit))
--
You received this
Damon reply to me and not the list, so I forward.
On Thu, Aug 19, 2010 at 9:09 PM, Damon Snyder drsny...@gmail.com wrote:
Hi Nicolas,
Thanks for the suggestions. Regarding the first one: ah, I see. That
is a nice compact way to test to see if the str is nil. I added that
I reckon that
Dear all,
I have a simple problem I can't manage to solve.
I have a library of multiple namespaces( a b c) that I want to include
in one namespace lib, so user of
the library can only use/require lib and have access to all the
functions i a, b and c.
What is the standard way to do that?
Best,
That helps a lot. Thank you very much.
That is not very nice though. I quite would like a :reexport option to use.
Best,
Nicolas.
On Wed, Aug 18, 2010 at 11:17 AM, Meikel Brandmeyer m...@kotka.de wrote:
There is no standard way of doing that. There is immigrate of an old
Compojure version,
If you intern all the ns-public variable of a namespace, they will be
reexoprted?
Will there be an indirection at runtime or the JVM can sort that out?
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
This works
(deftype A [a])
(.a (A. 5))
This don't
(deftype A [^{:volatile-mutable true} a])
(.a (A. 5))
Is this normal? Is this a bug?
How could I access the field?
Best,
Nicolas.
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this
(defmacro fat-if)
On Wed, Aug 18, 2010 at 4:09 PM, Brian Hurt bhur...@gmail.com wrote:
Consider the following bit of code:
(let [ x (new java.lang.Boolean false) ] (if x trouble ok))
As you might guess from the fact that I'm calling it's a trick question, the
above code returns trouble,
And they need to be in an interface first?
--
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 new members are moderated - please be patient with your
first post.
To
And is the one that works (for non-mutable fields) reliable or just an
implementation accident that could change in the future?
On Wed, Aug 18, 2010 at 4:27 PM, Nicolas Oury nicolas.o...@gmail.com wrote:
And they need to be in an interface first?
--
You received this message because you
I am not an expert. Is it possible on some JDK to put a breakpoint on
Boolean constructor and look at the stack?
Or you can't put a breakpoint on standard library?
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
I have a solution :
(defn unfold [f as]
(if-let [[hd new-as] (apply f as)]
(lazy-seq
(cons hd (apply unfold f new-as)))
()))
unfold could be called co-reduce or coreduce. It is the dual operation
of reduce, in category theory.
Instead of reducing a seq to create a value, it
auto-indentation and parens highlighting are better than lines with
only one parens.
At least for me.
There is no law. Do what is best for you.
You might, or not, change your mind when you have more practice with
all those parens.
--
You received this message because you are subscribed to the
You can create a new project, even if you don't use it:
lein new experiments
inside it will create a project.clj.
Checks the dependencies look like that:
:dependencies [[org.clojure/clojure 1.2.0-RC3]
[org.clojure/clojure-contrib 1.2.0-RC3]
Type lein deps in the directory.
defprotocol is a new feature of Clojure 1.2.
A fantastic RC3 of this fantastic software is available.
A good way to get it is to use the amazing Leiningen.
On Tue, Aug 17, 2010 at 7:17 AM, Henrik Mohr lupos...@gmail.com wrote:
Hi there!
I'm a completely new newbie in the clojure sphere - old
Clojure golf is the most fun golf!
(defn nil-coalesce [a b]
(map #(or %1 %2) a (concat b (repeat nil
Or if you really want to treat nil and false differently:
(defn nil-coalesce [a b]
(map #(if (nil? %1) %2 %1) a (concat b (repeat nil
I am not sure to get it.
Won't map
It's a clever box containing a value.
You can open the box and read the current value.
But you can't modify the content of the box directly.
You need to change the value in a box in a transaction.
The cleverness of refs comes form the fact that all read and all write
in a transaction are
On Mon, Aug 16, 2010 at 10:51 AM, Martin DeMello
martindeme...@gmail.com wrote:
Sometimes there's simply no way around it. For instance, I recently
had some python code that (stripped to its simplest form) had two
classes, Document and Attachment, where Attachment was a specialised
subclass of
On Mon, Aug 16, 2010 at 3:29 AM, Matthew Phillips mattp...@gmail.com wrote:
;; Now, if I want any node's in-edges, I can't just call in-edges
;; because Node implementations won't have it, so I compute them in
;; that case.
(defn node-in-edges [n]
(if (isa? Node2)
(in-edges n)
In Common LISP, you can modify anything, anywhere.
In the ML family of language, there are refs, but, if they have the
same name, they do not share the concept. They are closer of
Clojure's atoms. There is no notion of transactions.
Haskell and a few other languages have Software Transactional
Dear all,
I spotted something than I thought was unusual in 1.2-RC2 (haven't try RC3 yet)
(defprotocol Test (test [x]))
(deftype Foo [] Test (test [x] (instance? Foo x)))
(test (Foo.)) = false
(instance? Foo (Foo.)) = true
Should I submit or I am missing something obvious?
It is never a
On Sat, Aug 14, 2010 at 5:32 AM, Matthew Phillips mattp...@gmail.com wrote:
One idea that I tried was to use extend-type on a protocol, say to
extend any Node to be a PrettyPrintableNode. Obviously this didn't
work, and I'm not sure it actually makes semantic sense, but it's
interesting that
Dear all,
In my project, I need (in order to share constant trees in rule
definitions), to define new variable during macro expansion.
What I do currently:
I keep all the constant definitions and the rules definitions in an
atom and at the end, I call a macro at top level that define
everything,
I believe they do not sue over the JVM but over Dalvik.
The OpenJDK is,I think, a bit protected frompatents by its license and
the fact t has been distributed by the patents' owner.
However, Clojure in Clojure and better support of other platforms
would be great.
On Fri, Aug 13, 2010 at 12:13
On Fri, Aug 13, 2010 at 1:17 PM, Rich Hickey richhic...@gmail.com wrote:
not. They *sometimes* use interfaces in the implementation, but not always.
At no point should one assume that because a type supports a protocol it
'isA' that protocol (or its interface).
That's very interesting. From a
On Fri, Aug 13, 2010 at 2:46 PM, Meikel Brandmeyer m...@kotka.de wrote:
Using extend is slower, but more dynamic (read: mix-in via map merge
vs. hard-wiring things with inline definition).
Interesting...
Is there a link explaining how it is implemented in the extend
situation and how much
No problem Evan,
(def constants (atom ()))
(defn add-constant [name x]
(let [sym (gensym name)]
(reset! constants (cons ([sym x]) @constants)
sym
))
Then when I produce code, I call add-constant and use the returned symbol.
(I only use it to produce new constants, which is the
On Fri, Aug 13, 2010 at 2:51 PM, Mike Anderson
mike.r.anderson...@gmail.com wrote:
2. It would be great to reduce the amount of memory allocations. Yes,
I know memory is plentiful and GC is very cheap, but it's still not as
cheap as stack allocation and any noticeable GC pauses are not good
I have been thinking of that too.
The approach of extending with maps is great but lacks of access to
the content of the instance variables of the type.
(def Foo [bar]
)
(extend
clever-automatic-construction
)
As far as I know, clever-automatic-construction cannot use bar in its
Oh. I forgot.
It could also be helpful to have an easy access (meta information, for
example) to the
fields (and their types) of a record type.
On Thu, Aug 12, 2010 at 7:57 PM, Nicolas Oury nicolas.o...@gmail.com wrote:
I have been thinking of that too.
The approach of extending with maps
Can I erase my last mails?
I just discovered (.bar (Foo. 5)) = 5
It is a bit embarrassing. Sorry about that. (I am not a Java person, I reckon)
As far as traits are concerned, I think they can be made with a couple
of macros.
I might try to have a go over the week-end.
Best,
Nicolas.
--
You
On Tue, Aug 10, 2010 at 2:40 AM, Mark Engelberg
mark.engelb...@gmail.com wrote:
arbitrary-sized lists is a primary goal. The posted code (minus the
call to recur), is an elegant recursive formulation that is idiomatic
in Scheme because Scheme is (typically) implemented in a way that
makes
On Tue, Aug 10, 2010 at 12:43 AM, Jules julesjac...@gmail.com wrote:
It is impossible (undecidable) to tell precisely which functions a
function will call. Therefore you will need to consider not exactly
set of functions that a function will call, but some superset of that.
Why not take as
On Tue, Aug 10, 2010 at 9:55 AM, Mark Engelberg
mark.engelb...@gmail.com wrote:
In Clojure, I find stack limitations are a real issue unless
I transform the algorithms into a tail-recursive accumulator style.
For lists, it's usually not hard. For trees, it can be a bit of a
pain.
Try
On Tue, Aug 10, 2010 at 10:08 AM, Laurent PETIT laurent.pe...@gmail.com wrote:
Naive question from someone who has not really used Scheme in practice :
beyond the memory footprint problem (which may or may not be a problem
depending on the memory size of an element in the initial list, and also
1 - 100 of 251 matches
Mail list logo