> On Jul 10, 10:28 pm, Stuart Halloway
> wrote:
>> binding to a thread. The snake game could be extended to be a
>> simulation that runs on multiple threads (or perhaps even multiple
>
> Makes sense. For the example in the book it just seemed completely
> redundant. And w
Hi Rowdy,
The snake uses refs because idiomatic Clojure code should not require
binding to a thread. The snake game could be extended to be a
simulation that runs on multiple threads (or perhaps even multiple
machines) without having to change the basic code. Normally, you
wouldn't build
I strongly recommend using grb (http://grb.rubyforge.org/) as a
wrapper for remote-branch-related stuff. It provides a convenient
terminal API, and will tell you the git commands it is using under the
hood.
Stu
> So I guess my unstated question is this: what is the GIT incantation
> to get
Corey Haines, the touring software journeyman, recently spent a few
days at Relevance (including a day pairing on a Clojure project). At
the end, he videoed a conversation with me [1]. In Part 2 of the video
we talk about Clojure.
The conversation does not go at all deep technically, but if
Hi Mark,
The balanced-test would be a great place to use "are" instead of "is".
Cheers,
Stu
>
> There is a challenge on the blog of Tony Morris at
> http://dibblego.wordpress.com/2008/09/05/haskell-scala-java-7-functional-java-java/#comment-2460
>
> .
> It's a parsing problem for which he com
I am working on a Clojure project that is becoming more and more
schedule-oriented. So far I have been using Clojure's native
concurrency constructs, but I am becoming tempted to use Java's
concurrency primitives to get interruptability, etc. -- or maybe even
wrap a Java library like Quart
If you are following the github head of the Clojure and contrib
projects, you will see that several libraries have moved from contrib
into Clojure:
* clojure.contrib.test-is becomes clojure.test
* clojure.contrib.stacktrace becomes clojure.stacktrace
* clojure.contrib.template becomes clojure
Hi Justin,
The easiest solution is to download the sample code for the book from
[1] (this is referenced in the Preface under "Downloading Sample
Code"). The sample code includes everything you need: clojure, clojure-
contrib, and the book samples, plus launch scripts that get all the
clas
#'user/dozen
> user> (binding [dozen 13] dozen)
> 13
> user> (#(binding [dozen 13] dozen))
> 13
> user>
>
> -the other Stuart
>
>
> On Jun 16, 2:08 pm, Stuart Halloway wrote:
>> This surprised me. What part of my mental model needs to be
>> adj
This surprised me. What part of my mental model needs to be
adjusted? :-)
user=> (def dozen 12)
#'user/dozen
user=> (binding [dozen 13] dozen)
12 ; hunh?
user=> (#(binding [dozen 13] dozen))
13
--~--~-~--~~~---~--~~
You received this message because you are s
Would be interesting to combine Clojure with NailGun for utility
scripting...
http://sourceforge.net/projects/nailgun/
> Due to the startup cost of the JVM, Clojure and Java probably aren't
> the best choices for tiny five to ten line utility scripts. That being
> said, Clojure works well for
Hari,
I agree--dependency injection is not about OOP. It is about working
around limitations in certain languages where it is difficult to
decouple components for testing and flexible deployment.
I have not encountered similar limitations in Clojure. Do you have an
example in Clojure that
uld get the
> best of both worlds with no destructive global function changes. Go
> figure I come up with this after reading the entire "clojure modules"
> thread and starting a solution using deftemplate :)
>
> - Matt
>
> On Jun 11, 8:36 am, Stuart Halloway wrot
Matt is signing the CA and I will be adding test-expect to contrib.
Stu
>
> Can I help from the test-is side? Could test-expect be added to
> clojure-contrib?
> -Stuart
>
>
> On Jun 10, 1:36 pm, Matt Clark wrote:
>> Thanks for these ideas, I will give them a try tonight and update the
>> adapt
Matt Clark's test-expect library includes two versions of a report-
problem function: a standalone version, and another that integrates
with test-is. The comments suggest two ways to active the test-is
version: wrapping calls to expect in a binding, and interning the
specialized version of
Hi Matt,
I would definitely like to see test-expect added to contrib. If you
will sign the CA I will move it there. I have a bunch of existing
tests that are simply using binding to do cheap stubbing, and will be
converting those tests to test-expect over the next several days.
Thanks for
Hi Matt,
I would like to move this to contrib, if you will sign the CA. I'll be
moving my simple binding-based stubs to use this and will send along
suggestions if I have any.
Thanks for writing this!
Stu
P.S. Apologies if variants of this message show up twice. Mail client
wonkiness...
I think Clojure addresses (at the language level, and better) all the
issues that Spring addresses. So in the long run Spring is unnecessary
in a Clojure world.
But in the short run you have the codebase you have, and the skills
that you have. So if it makes sense, do it.
Stu
> At this po
>> 2) put the unit tests in a separate file, in the same namespace
This works for me, but since it won't work with the normal use/require
idiom, I would like to see a standard convention evolve to make it
easy to read other people's code.
Stu
--~--~-~--~~~---~--~
Hi Allen,
You could write a function that uses the clojure.contrib.with-ns/with-
ns macro to dip into the namespace being tested and return the private
function, assigning it to a local name in the test namespace.
I need this too, and have been meaning to ping the other Stuart about
either
Ditto what everyone else said, plus let's get rid of the duplicated
call to Math/log by splitting the iterate into an iterate + a map:
(take-while
(fn [[_ second]] (< second 10))
(map (fn [x] [x (/ x (Math/log x))])
(iterate #(* % 2) 2)))
Stu
>
> On 02.06.2009, at 17:35, Wilson
I would like to see defstruct take an optional docstring. Would such a
patch be welcome?
Stu
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroup
People keep looking at me funny when I point out variables as code
smells during code review...
Stu
>
> Same here with the commas. Since I've been neck deep in Clojure, I've
> been pathologically forgetting to add them with other languages.
>
> On Jun 2, 10:06 am, Shawn Hoover wrote:
>> On Tu
Hi Glen,
(1) Real-world example: I use polymorphism on the types of two
different arguments to define implicit conversions:
(defmulti coerce
(fn [dest-class src-inst] [dest-class (class src-inst)]))
(defmethod coerce [java.io.File String] [_ str]
(java.io.File. str))
(defmethod coerce
given the ambiguity that names like "mapkeys" might be
misleading. Other suggestions?
Stu
>
> On 30.05.2009, at 17:11, Stuart Halloway wrote:
>
>> clojure.contrib.generic.functor.fmap will return a map with values
>> updated by a function. What if I wany *keys* upda
clojure.contrib.generic.functor.fmap will return a map with values
updated by a function. What if I wany *keys* updated by a function?
Does this exist yet? If not, what should I name it for inclusion in
contrib?
Stu
--~--~-~--~~~---~--~~
You received this m
When working through Part 3 of the monad tutorial [1], I am seeing the
following behavior for fib-trace:
(fib-trace 3)
=> [2 [[[1 1] [[[0 0] []] [[2 1] [[[1 1] [
According to the tutorial, it should be:
(fib-trace 3)
=> [2 [[1 1] [0 0] [2 1] [1 1]]]
Am I doing something wrong
FYI: I am working on an open-source CSV parser in Clojure. Splitting
on delimiters is rarely enough in my experience.
Stu
> would you consider adding support of a split by passing a delimiter?
> since parsing csv/tsv is a pretty common task.
>
> I know it can be done by using re-split. but it
I would love to see 1.0, and the sooner the better. At Relevance we
are doing real work in Clojure today.
As for wish list I would love to see improvements to the development
process:
* move from svn to git
* move regression tests from contrib into clojure itself
But neither of these need n
Yes to almost all of this (r662). I am not totally comfortable with
the false/"false" conversion.
Stu
> Hi Stuart H! Comment on:
>
> (defn set-system-properties
> [settings]
> "Set some system properties. Nil clears a property."
> (doseq [[name val] settings]
>(if val
> (System/se
or fixture.
>
> (defmacro with-tmp-properties-file [& body]
> `(binding [*tmp-properties-file* (File/createTempFile "temp"
> ".properties")]
> (spit *tmp-properties-file* "contents of the test file")
> ~...@body
> (.delete *tmp-properties-fi
I have Cobertura running and producing reports against contrib, sort-of.
Problems:
(1) AFAICT, cobertura *insists* in trying to parse the source code as
Java to do cyclomatic complexity analysis. This blows up, of course.
(2) The red/green coloring of the lines does not match what I know is
OK, I'll try Cobertura next.
There is a reason my Java knowledge sounds about 5 years old ... :-)
Stu
>
> Stuart Halloway wrote:
>> I will go and bug the emma folks, but first wanted to ask here if
>> there is any specific reason that Clojure-generated bytecode might
In r659 I added a unit test to clojure-contrib that needed to read and
write from the filesystem. I picked a dumb and simple convention, and
welcome review from other committers to move to something that is just-
smart-enough.
Stu
--~--~-~--~~~---~--~~
You re
10:55 am, Perry Trolard wrote:
>> I think the consensus is that 1.5 is the target, so I've attached
>> props.1.5.clj to the group, which is 1.5 compatiblle (i.e. uses
>> streams, not readers or writers).
>>
>> Best,
>> Perry
>>
>> On Apr 8, 6:49 pm
I spent a few minutes this morning trying to get an emma coverage
report over contrib. Short answer is that it doesn't work -- emma
throws an exception while instrumenting the code (see attached
console.txt).
I will go and bug the emma folks, but first wanted to ask here if
there is any sp
Lancet is more at proof-of-concept stage than ready for heavy lifting
-- I am using a mix of Ant and Rake on my own Clojure stuff. :-)
I am happy to contribute to solving some of these issues but don't
have time to lead the effort.
Stuart
> When you are building something real with Clojure
Changed to as-str (r654).
Stu
>
> In Compojure, I called this str*, but I think I like as-str a little
> better.
>
> - James
>
> On Apr 5, 5:19 pm, Stuart Halloway wrote:
>> Never worry about the distinction between symbols, keywords, and
>> strings when work
Perry's proposed props functions
(http://groups.google.com/group/clojure/browse_thread/thread/c8ec751b8e66b019/d56ed1200aa95bca
) uses some Java 6 methods.
Is it ok for me to add such things to contrib, or are we maintaining
Java 5 compatibility?
Stu
--~--~-~--~~~--
Perry,
Cool -- I will add this pending the result of the Java 6 thread I am
about to launch.
Stu
>
> Hi Stuart,
>
> Not sure if you saw my post at http://bit.ly/sRnfG (links to list), or
> the props.clj file in the Google Group. In short, it's got a
> Properties reader & writer function. It t
I don't like that if you treat properties as a seq you get Java
Hashtable$Entry objects, instead of a vector as you would with a map,
hence my "into {}". But maybe it is a silly quibble since
destructuring works fine with either.
Stuart
>> Can't you just write:
>> (.load (Properties.) (Fil
Does something like this (or better) already exist in Clojure? If not
I will add it to java-utils.
Thanks,
Stu
(defn read-properties [f]
(into
{}
(let [props (Properties.)]
(.load props (FileInputStream. f))
props)))
--~--~-~--~~~---~--~---
r652 is a breaking change to contrib. (powers-of-2) and (fibs) are now
functions and do not hold their heads. primes is still a sequence
because it needs to hold past values for efficiency.
Stuart
> On Apr 5, 2009, at 4:27 PM, Stuart Halloway wrote:
>
>> At quick glance it look
Hi Tom,
I think that the ant test tasks should depend on the compilation
tasks, and that users will just have to specify a clojure.jar.
Either that or the default test suite should be smart enough to skip
the pretty printer tests with ant.jar not specified.
Stuart
> By (semi-)popular deman
Good summary. Let's keep them separate until we feel pain.
- Stuart Halloway
> They work rather differently. duck-streams/file treats all arguments
> as strings, so
> (file "foo" "bar") =>
> I wrote it that way because I often want to construct a f
> I'd also like to get your latest thinking on your suggestions from
> some time ago about clojure.contrib.lazy-seqs. If they can be
> rewritten as you suggested as functions that return a new sequence
> rather than as "def'd" sequences, that's strictly more powerful and
> would be an impr
Doh! Missed that. The duck-streams and java-utils versions of file
have overlapping but disjoint functionality. Other-Stuart, I can take
a look at combining these, or we can just leave them separate for now.
--Stuart
> On Apr 5, 5:07 pm, Stuart Halloway wrote:
>> Never worry about
> I noticed the indentation changed for the ns form with your changes
> to sql.clj sql/internal.clj . Is the indentation you used produced
> by some tool?
>
> --Steve
No -- the intended change was from multiple :use forms to one :use
form with multiple namespaces. Any indentation changes ou
Don't work with the yucky properties API, just install a map of
properties for the duration of a block!
-
clojure.contrib.java-utils/with-system-properties
([settings & body])
Macro
setting => property-name value
Sets the system propertie
Never worry about the distinction between symbols, keywords, and
strings when working with Java APIs that know only strings!
(doc the-str)
-
clojure.contrib.java-utils/the-str
([x])
Returns the name or string representation of x
Notes:
(1) You will need to build c
Never worry about "foo" vs. (File. "foo") again!
(doc file)
-
clojure.contrib.java-utils/file
([arg] [parent child] [parent child & more])
Returns a java.io.File from string or file args.
Notes:
(1) You will need to build contrib from source to see this.
(2) This fu
http://blog.thinkrelevance.com/2009/4/4/programming-clojure-beta-9-is-out
--~--~-~--~~~---~--~~
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
To unsubscribe
Hi all,
I would like to pull together functions that help with Java interop
and place them in a new contrib: java-utils. Some examples:
(1) Pull out SteveG's properties fn, currently hidden in the internals
of clojure.contrib.sql
(2) reflective helpers for accessing private and protected va
No threads:
(ancestors (class (fn[])))
-> #{java.lang.Runnable java.io.Serializable clojure.lang.AFn
clojure.lang.Obj java.lang.Object clojure.lang.Fn
clojure.lang.AFunction clojure.lang.IObj clojure.lang.IFn
java.util.concurrent.Callable clojure.lang.IMeta java.util.Comparator}
What you a
Hi Geoff,
You should have no trouble using setAccessible. There are several
demos of this in the source code for the book [1] that use
setAccessible to check private fields in a unit test. (See lancet/test/
step-2-complete.clj [2], for instance).
Hope this helps,
Stu
[1] http://github.com
describe-key (usually C-h k) followed by a key will tell you what a
key is currently bound to.
On my setup C-x C-b is bound to ido-switch-buffer--it is not
immediately obvious how to make it pop the buffer list in the current
window.
You might find "What You Can Learn From ido.el" (http://
(1) Is there any reasonable way to attach handlers to lazy sequences
such that the handlers will still be in place outside the original
handler scope, when the sequence is finally evaluated? (It is not
obvious to me how to do this without making the handler system part of
the language core
ast
> book version (27 feb), because some function (sort of `lazy-eval')
> from clojure-contrib raised an error during compilation. Same result
> was obtained by compilation from command line, so I'm afraid some-
> thing wrong either with current clojure-contrib version or
Hi Ilya,
I would like to be able to demo the sample code from the book in IDEA.
Here are a few things I am seeing so far:
(1) When I set a breakpoint, I get a warning icon that says "no
executable code found at..." but the breakpoint does in fact seem to
work.
(2) The variable window corr
I am updating some of the examples in the FP chapter to use letfn, and
the book is already up-to-date on fully lazy seqs.
Any other new features jump out as "must discuss in book"?
Stu
> New release 20090320 -
> http://clojure.googlecode.com/files/clojure_20090320.zip
>
> Incorporates all th
Hi Adrian,
Here is one way:
(-> (into-array ["one" "two"]) (class) (.getComponentType))
-> java.lang.String
(-> (to-array ["one" "two"]) (class) (.getComponentType))
-> java.lang.Object
Stu
>
> I have a java object that either contains a String or an array of
> Strings.
>
> (instance? java
> All sequences are represented by (chains of) (possibly lazy) seqs, of
> type ISeq. So yes, sequence/seq(noun)/ISeq are technically synonyms,
> but [1]
Great.
> [1] In practice, a sequence fn (like map et al) may return an empty
> sequence, while seq/next will instead return a (forced) thing w
I like this, and I am OK with seq (function) being the oddball that
returns a seq or nil.
Rich, this is what Beta 8 of the book currently says -- ok with you?
Stuart
> I believe that one of Rich's stated purposes with the latest revision
> of the laziness branch was to get rid of some of the
I am wrestling the sequences chapter of the book into conformance with
the new laziness, and I am finding it tricky to infer accurate
definitions of the words sequence, seq (noun), seq (function), and
ISeq from the variety of extant documentation, code, email chats, and
IRC logs. I would a
Cool, thanks.
>
> On Tue, Feb 24, 2009 at 11:59 AM, Stuart Halloway
> wrote:
>>
>> Is there a way to programmatically retrieve the :tag of an argument?
>> The var metadata will return the tag of a return value...
>
> The :arglists metadata attached to the
Is there a way to programmatically retrieve the :tag of an argument?
The var metadata will return the tag of a return value...
Stu
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this g
Beautiful-thanks.
> Using a good old sequence of vectors:
> (defn fibo []
> (map first (iterate (fn [[a b]] [b (+ a b)]) [0 1])))
>
> Christophe
>
> Stuart Halloway a écrit :
>> I have updated the sample source from the book
>> (http://tinyurl.com/clojure
> code, I'll consider adapt clojure-dev to stick with this coloring
> scheme.
>
> Thanks in advance,
>
> --
> Laurent
>
> 2009/2/23 Stuart Halloway
>
> I have improved the clojure.js bits [1]. Various small changes, but
> the big issue was to disconti
I have updated the sample source from the book
(http://tinyurl.com/clojure-samples
) to the new laziness. Along the way, I replaced the lazy-cons based
implementation of the fibonacci numbers with this:
(defn fibo
([]
(concat [0 1] (fibo 0 1)))
([a b]
(let [n (+ a b)]
I have improved the clojure.js bits [1]. Various small changes, but
the big issue was to discontinue using \b for end of word, which does
not work well with names-like-this.
Feedback or additional improvements welcome.
Stuart
[1]
http://github.com/stuarthalloway/programming-clojure/blob/95
Thanks for the kind words, David. I hope many people will like
Programming Clojure and find it useful.
Clojure has a *ton* of goodness in it. I think many of the chapters in
Programming Clojure book could usefully be followed with an entire
book. Here is a partial list of recommendations fo
David Sletten sent me this erratum:
<<
At the beginning of section 2.4 we have "The symbol user/foo refers to
a var which is bound to the value 10." Under the next subsection
"Bindings" we have "Vars are bound to names, but there are other kinds
of bindings as well." The Common Lisp standar
I agree with Walt, and there is no need to pressure the Prags, we are
on it! :-)
That said, it would be *very* helpful to me if we could get the
lazyness thing settled this week...
Stuart
> Regarding Programming Clojure:
>
> I think that placing the burden of "book vs actual" incompatibilit
Thanks Rich! :-)
> , 2009, at 11:25 AM, David Nolen wrote:
>
>>
>> butlast, doall, dorun, doseq, dosync, dotimes, doto, fnseq, gensym,
>> macroexpand, macroexpand-1, mapcat, nthrest
>>
>>
>> -1
>>
>> Because they are similar to other Lisps I assume. The same reason
>> for println vs print-line.
(map vector [1 2 3] ['a 'b 'c] ["cat" "dog" "bird"])
-> ([1 a "cat"] [2 b "dog"] [3 c "bird"])
> Actually something closer to your exact expression is this:
>
> (apply (partial map (fn [& rest] (apply vector rest))) [[1 2 3] ['a
> 'b 'c] ["cat" "dog" "bird"]])
>
> On Sun, Feb 15, 2009 at 7:42 P
I prefer first/rest/next.
Because of where the book is in the production cycle, it will be
difficult for me to change the prose. But if this gets decided (and
clojure-contrib updated) in the next week or two I think I can get the
book printed with the changes incorporated throughout.
Cheer
Thanks Rich,
Expanding into the symbol is clever, but less readable (IMO) than just
expanding into the . form. Anyway, I get it now.
Stuart
> On Feb 15, 2009, at 9:06 AM, Stuart Halloway wrote:
>
>>
>> Does this clarify the point I was making?
>>
>> W
Does this clarify the point I was making?
When writing macros, you cannot dynamically build one of the syntactic
sugar forms. For example, you cannot write a macro that expands cls
and member into (cls/member):
(defmacro call-static [cls member] `(~cls/~member))
-> java.lang.Ex
Hi Berlin,
Your testDog needs a 'this' argument:
(defn -testDog [this]
(println "Dog called on " this))
I played with generating JUnit classes when I started writing the
book, and unless you have a specific need I would recommend using
something like test-is for Clojure testing.
Cheers,
Thanks Mark, Chouser,
I will update that section of the book with a corrected example in
Beta 7.
Cheers,
Stuart
>
> On Tue, Feb 3, 2009 at 11:26 AM, Mark Volkmann
> wrote:
>>
>> Now I remember what I was thinking about. This isn't so much a
>> difference between macros and functions as it is
Lancet
http://github.com/stuarthalloway/lancet
Stuart Halloway
Developer tool
Same License as Clojure
Lancet is a build tool like Ant or Rake. Lancet makes it easy to
create build targets: any Clojure function can be a build target.
Lancet can call Ant tasks, or shell out and call other
on [2] can now compile itself into a
standalone JAR. The technique used there is to unjar clojure and
contrib, drop your own code onto it, and rejar.
There is no "one size fits all" solution for packaging and deployment--
this is a fact if life that Clojure inherits from the Java wo
clj to keep your versions of the jar files and I restricted
> these jars usage to lancet tasks only.
>
> Thank you,
> Luc
>
>
> On Mon, 2009-01-26 at 14:34 -0500, Stuart Halloway wrote:
>>
>> Lancet is a build DSL written in Clojure, and a sample app in the
>> book
&
t" in the else case in your last
> if clause.
>
> On Mon, Jan 26, 2009 at 9:32 PM, Stuart Halloway
> wrote:
>>
>> Lancet's runonce function needs to wrap a function with runs-only-
>> once
>> semantics, *and* make subsequent callers wait for the
Lancet's runonce function needs to wrap a function with runs-only-once
semantics, *and* make subsequent callers wait for the return value
before proceeding. There was a thread on this last November where Rich
explained several approaches
(http://groups.google.com/group/clojure/msg/406be93eb
Lancet is a build DSL written in Clojure, and a sample app in the book
[1]. It combines ant tasks with a Clojure build language, and uses
Chouser's shell-out to implement a system call for jumping to OS level
stuff.
Lancet's own build script is below. There isn't much in the way of
docs,
In SVN 412 I have made the following changes to contrib:
* a test_contrib.clj file which does for contrib what test_clojure.clj
does for clojure
* a test_clojure task in build.xml
* a test_contrib task in build.xml
* a test task to aggregate all test tasks
This is *very* minimal, but I wanted
I would like to convert the following ruby/rake code to Clojure:
Dir.chdir ENV["CLOJURE_HOME"] do
system "git svn rebase"
system "ant jar"
end
Since Java does not have the notion of a current directory, one way to
go about this would be to modify clojure.contrib.shell-out/sh as
Thanks Joshua,
This is fixed in the next beta.
Stuart
> A related point about the validator function (for Refs), possible
> the result of the same change in the Clojure codebase
> On page 133 of Beta 5.0,
>
> (def messages (ref () :validator validate-message-list)
>
> The code samples,
Hi Mark,
set takes a single argument, a coll, and #{} is a literal form that
can have a variable number of args.
To make them equivalent:
(set "aeiou")
-> #{\a \e \i \o \u}
#{(seq "aeiou")}
-> #{(\a \e \i \o \u)}
Stuart
>
> On Fri, Jan 23, 2009 at 2:51 PM, Chouser wrote:
>>
>> On Fri, J
I don't think the function passed to "some" should be called a
predicate, since it is not constrained to true/false. The docstring
agrees with you, however.
Stuart
> Hi,
>
> It means that some of the maps can be nil, but at least one of them
> has to be non-nil. "some" requires a predicate,
super-deep structures at the REPL is
particularly important, but I am curious how you would go about
implementing it.
Stuart
> On Jan 21, 8:43 pm, Stuart Halloway wrote:
>> Consider the function deeply-nested:
>>
>> (defn deeply-nested [n]
>> (loop [n n
>>
Consider the function deeply-nested:
(defn deeply-nested [n]
(loop [n n
result [:bottom]]
(if (= n 0)
result
(recur (dec n) [result]
If you print it at the REPL for small values of n, no problem:
(deeply-nested 25)
-> [[:bottom]
That's simpler than the example I was typing up, so I will stop now. :-)
Another problem is that you might want the binding to be in effect
while defining a sequence, but not while realizing it. Haven't come up
with any realistic examples of that, though.
Cheers,
Stuart
> Uh oh, I see what
Hi Hugh,
I don't see how this would work in general, which is why a I suggested
a special-purpose macro before. Surely you would not want a binding to
force all sequences while that binding is in effect. And if not that,
what would the general strategy be for deciding which sequences to
f
All of them, if you use in-ns:
(in-ns 'foo)
#
> str
java.lang.Exception: Unable to resolve symbol: str in this context
(clojure.core/refer-clojure)
-> nil
str
-> #
>
> I'm trying to get into more of how namespaces work. The refer function
> refers to all the public variables of a library.
> OK, good, thanks for the explanation.
>
> Is it desirable behavior? Is there some case where a programmer wants
> this behavior?
>
> It's pretty scary to have to consider these hidden effects. Sort of
> the opposite of FP.
If you write functions that work differently depending on a binding,
t
Doh. Disregard my code example. :-) The reasoning is correct however.
Stuart
> Hi
>
> On Tue, Jan 20, 2009 at 7:01 AM, Stuart Halloway
> wrote:
>>
>> Lazy evaluation is a harsh mistress.
>>
>> user=> (def b1 (binding [*num* 1024] (f1)))
>> #'u
Lazy evaluation is a harsh mistress.
user=> (def b1 (binding [*num* 1024] (f1)))
#'user/b1
user=> (def b2 (binding [*num* 1024] (f1)))
#'user/b2
user=> b1
(16)
user=> b2
(16)
The difference between the example above and your example is the
interaction with the REPL. Your f1 is lazy, and is not
Hi Berlin,
Probably ref, if the state must be coordinate with other state, or
atom, if it is totally independent. But you might be able to avoid
using mutable state at all. We would need a larger example to tell.
Stuart
> On Jan 16, 11:10 am, BerlinBrown wrote:
>> I am working on this GUI
601 - 700 of 875 matches
Mail list logo