I'm watching Richs' excellent Clojure for Java developers videos. One
comment he makes puzzles me though. He is elaborating about how
powerful macro abstraction is. The specific argument he gives is
closing files in Java and how macros save you typing the exact thing.
I don't quite get what he
I'm watching Richs' excellent Clojure for Java developers videos. One
comment he makes puzzles me though. He is elaborating about how
powerful macro abstraction is. The specific argument he gives is
closing files in Java and how macros save you typing the exact thing.
I don't quite get what he
In Java, you often have to pair things, e.g. opening a file and
closing it, to avoid leaking resources like file handles.
These pairings are among many cases where Java code contains structure
that you can't extract and reify in your program.
Macros make it possible to extract any such pattern,
On Mon, Nov 29, 2010 at 3:29 PM, Ken Wesson kwess...@gmail.com wrote:
In Java, you often have to pair things, e.g. opening a file and
closing it, to avoid leaking resources like file handles.
These pairings are among many cases where Java code contains structure
that you can't extract and
That was really neat ken ... eval-with-local-vars.. I think it should be
part of the core...
Sunil.
On Sun, Nov 28, 2010 at 8:02 AM, Ken Wesson kwess...@gmail.com wrote:
Caveat: since eval-with-local-vars is a macro you won't be able to
directly use it in HOFs. Wrapping it in a closure works,
Hi,
From today, I will not receive updates from this group, so if
anyone cares to answer this question, please send me an email:
dil...@gmail.com. I do think that this is an important question to
many people that liked a lot the Clojure concurrency model but cannot
use Clojure in their day
Hi Ken,
Just wrapping your macro with the following would save you the trouble of
having to enumerate the local variables ...
(defmacro eval-with-local-bindings [sexp]
`(eval-with-local-vars ~(apply vector (keys env)) ~sexp))
Sunil.
On Mon, Nov 29, 2010 at 6:22 PM, Sunil S Nandihalli
On Nov 22, 6:43 pm, Miki miki.teb...@gmail.com wrote:
Dr.Evilis a simple web debugger that provides a REPL to your web
application in a hidden location.
This is pretty useful, thanks!
I tried adding Dr. Evil into a test app, but I'm having trouble
switching namespaces in the REPL:
= *ns*
Performance.
why not change type compare functions do a compare on strings as
well?
(defn
([x] true)
([x y](if (string? x)
(. clojure.lang.Numbers (isPos (.compareTo x y)))
(. clojure.lang.Numbers (gt x y
([x y more]
(if ( x y)
(if
I'd say the former was more idiomatic Clojure. There's no need to make
refs compatible with atoms (otherwise why have two different
concurrency primitives in the first place).
Additionally, earmuffs (like *this*) should only be used on vars that
you expect to override in a binding, like *out* or
IMHO, any built-in string compare should support collations. I think
this belongs in contrib in string.
On Nov 29, 2:59 am, Tim Robinson tim.blacks...@gmail.com wrote:
why not change type compare functions do a compare on strings as
well?
(defn
([x] true)
([x y](if (string? x)
I think it will make more sense to branch on whether something is
Comparable or IComparable, than a string.
On Mon, Nov 29, 2010 at 08:59, Tim Robinson tim.blacks...@gmail.com wrote:
why not change type compare functions do a compare on strings as
well?
(defn
([x] true)
([x y](if
I must respectfully disagree with James's first point here. The first pattern
(read-ponder-update) is not concurrency-friendly. It isn't about atom vs. ref,
the important distinction is whether all the work can be done in a function
that gets sent *to* the ref. The latter formulation also can
2010/11/29 Stuart Halloway stuart.hallo...@gmail.com
I must respectfully disagree with James's first point here. The first
pattern (read-ponder-update) is not concurrency-friendly. It isn't about
atom vs. ref, the important distinction is whether all the work can be done
in a function that
I think it is because concurrent stuff can happen between let and
alter in the first example. Is it true that in that case, one would
have to use ensure to make the operation correct?
On Nov 29, 5:53 pm, Laurent PETIT laurent.pe...@gmail.com wrote:
2010/11/29 Stuart Halloway
2010/11/29 Jozef Wagner jozef.wag...@gmail.com
I think it is because concurrent stuff can happen between let and
alter in the first example. Is it true that in that case, one would
have to use ensure to make the operation correct?
That's my point (at least the way I understand it, I do not
This is pretty useful, thanks!
Glad someone other than me likes it :)
I tried adding Dr. Evil into a test app, but I'm having trouble
switching namespaces in the REPL:
= *ns*
#Namespace clojure.core
= (in-ns 'cv-test-1.core)
#Namespace cv-test-1.core
= *ns*
#Namespace clojure.core
It
I dunno,
Where is this arbitrary point people set where language improvements/
ease-of-use become less important than negligible performance impacts?
I ran several benchmarks, with warm up and correct time measurements,
and didn't get the impression the change was in anyway significant.
Take the
Hi,
Am 28.11.2010 um 21:33 schrieb Asim Jalis:
This looks like map rather than foldr.
On Sun, Nov 28, 2010 at 7:40 AM, tpeng pengt...@gmail.com wrote:
i have a one:
(defn lazy-foldr [f coll]
(lazy-seq
(if-let [[x xs] coll]
(cons x (lazy-foldr f xs)
it seems
On Mon, Nov 29, 2010 at 2:28 PM, Tim Robinson tim.blacks...@gmail.comwrote:
I dunno,
Where is this arbitrary point people set where language improvements/
ease-of-use become less important than negligible performance impacts?
I ran several benchmarks, with warm up and correct time
On Mon, Nov 29, 2010 at 6:28 AM, Petr Gladkikh petrg...@gmail.com wrote:
On Mon, Nov 29, 2010 at 3:29 PM, Ken Wesson kwess...@gmail.com wrote:
In Java, you often have to pair things, e.g. opening a file and
closing it, to avoid leaking resources like file handles.
These pairings are among
On Mon, Nov 29, 2010 at 8:31 AM, Sunil S Nandihalli
sunil.nandiha...@gmail.com wrote:
Hi Ken,
Just wrapping your macro with the following would save you the trouble of
having to enumerate the local variables ...
(defmacro eval-with-local-bindings [sexp]
`(eval-with-local-vars ~(apply vector
+1
String comparisons that don't support i18n collations are next to
useless, IMO. A bare or operator can't do the right thing in the
general case for strings.
Stuart's and David's points about performance are compelling too.
On Mon, Nov 29, 2010 at 7:24 AM, Alyssa Kwan
huh? Making a change to the function doesn't mean you *can't* write
high performance data structures in Clojure. It just means, you *may*
need to use a different fn name as opposed to the common one.
Similarly I could simply use a different name to accomplish my own
function that includes
On Nov 28, 5:36 pm, Takahiro Hozumi fat...@googlemail.com wrote:
Which style do you like?
This one:
(defn dec-or-dissoc! [key]
(dosync
(alter *counts*
(fn [m]
(let [n (m key)]
(if ( 1 n)
(assoc m key (dec n))
Hi Sunil,
This is one of those things that seems really useful for development,
but ends up being a lot of trouble down the road. For one thing, it's
hard to make it perform well. For another, it can lead to unexpected
results when you add in inheritance hierarchies and overloaded
methods.
-S
But the facilities for what you want are already there. Define a more
generic and exclude the ones from core.
I'm constantly excluding fns from core which have names I'd rather use
in my own source.
David
On Monday, November 29, 2010, Tim Robinson tim.blacks...@gmail.com wrote:
huh? Making a
I already do that, but that doesn't help general masses of people who
would benefit from consistent intuitive language constructs.
On Nov 29, 5:57 pm, David Nolen dnolen.li...@gmail.com wrote:
But the facilities for what you want are already there. Define a more
generic and exclude the ones
On Mon, Nov 29, 2010 at 8:07 PM, Sunil S Nandihalli
sunil.nandiha...@gmail.com wrote:
Hello everybody,
I have a small doubt. Suppose
(def s #{1 2 3 4 5 6})
(set s)
will calling set on an existing set shortcircuit the call and return the
same set or would it create a new one? I would like to
On Mon, Nov 29, 2010 at 7:42 PM, Stuart Sierra
the.stuart.sie...@gmail.com wrote:
On Nov 28, 5:36 pm, Takahiro Hozumi fat...@googlemail.com wrote:
Which style do you like?
This one:
(defn dec-or-dissoc! [key]
(dosync
(alter *counts*
(fn [m]
(let [n (m key)]
Thanks Ken,
I didn't realize I could test it so easily. But I would like it to ideally
return the same collection .. Shouldn't be hard to write a wrapper .. But I
think it should be the default behaviour.
Thanks again,
Sunil.
On Tue, Nov 30, 2010 at 7:05 AM, Ken Wesson kwess...@gmail.com wrote:
On Mon, Nov 29, 2010 at 8:05 PM, Tim Robinson tim.blacks...@gmail.comwrote:
I already do that, but that doesn't help general masses of people who
would benefit from consistent intuitive language constructs.
I've never wanted such a feature. But perhaps many people do. However from
what I've
Thanks Stuart. You are probably right. But may be there can be a modified
defn-auto-coerce .. Thats just a thought .. May be I will try to implement
it . .but would love to hear any pointers you may have in that direction
before I go it myself.. I am still an ametuer when it comes to Clojure .. so
On Sat, Nov 27, 2010 at 9:36 PM, Duane Searsmith dsearsm...@gmail.com wrote:
That doesn't make Wolfram a lunatic or a fraud. Remember that
mathematicians like Mandelbrot where also considered frauds at first.
mandelbrot came and talked at the place i was working ~5 year ago,
during a book tour
Hello everybody,
I have a small doubt. Suppose
(def s #{1 2 3 4 5 6})
(set s)
will calling set on an existing set shortcircuit the call and return the
same set or would it create a new one? I would like to extend the question
to hash-map and vec..
thanks,
Sunil.
--
You received this message
2. I agree with having both.
3. Lol. I love that you asked your wife and kids that's where I
always go.
However, I don't think they represent a reasonable audience. When I
say the general masses for intuition, I'm speaking about the average
programmer whom reasonably would want to compare
I had some fun with this and added assert-args:
(defmacro assert-args [fnname pred msg pred-msg-pairs]
`(when-not ~pred
(throw (IllegalArgumentException. ~(str fnname requires msg
(when (seq pred-msg-pairs)
(list* `assert-args fnname pred-msg-pairs)))
(def ascending compare)
Hi guys,
I've recently discovered the io! macro. Is this something to try to use all
the time.. or only in certain situations?
Alex
--
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
I certainly from time to time have to rewrite some comparator for strings
for GUI stuff (sort by label, etc.).
Even there, sometimes I need to sort without caring about capital letters,
sometimes I don't need ...
But indeed having some ready to use string comparators in a str package
could be
39 matches
Mail list logo