Re: Fully lazy sequences are coming - feedback wanted!

2009-02-16 Thread Mark Engelberg
Browsing the source code for LazySeq, I noticed that isEmpty is implemented as follows: public boolean isEmpty() { return count() == 0; } Since count realizes the whole list, this seems like a bad way to test for empty on a lazy sequence. --~--~-~--~~~

Re: How do I do this in clojure?

2009-02-16 Thread Mark Engelberg
Suggestion: Provide a statement of purpose as to what this function is supposed to do. What are its inputs and what is its output? Can you break it down into smaller functions? Right now you have a complicated function that takes no inputs and always produces the same string. It seems somewha

Re: Fully lazy sequences are coming - feedback wanted!

2009-02-17 Thread Mark Engelberg
Since there is no canonical empty sequence, this makes me wonder whether one particular empty sequence might have some kind of performance benefit over another. For example, if I were going to give a name to one empty sequence to reuse within my code, would one of these be preferable?: (def empty

Re: new laziness: terminology help

2009-02-24 Thread Mark Engelberg
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 subtle differences between these terms after all the discussions about this. I think that with the new changes the intent is: seq (noun) = sequence = ISeq, i.e., anything you

Re: new laziness: terminology help

2009-02-25 Thread Mark Engelberg
On Wed, Feb 25, 2009 at 6:59 AM, Stuart Halloway > I believe it would be simpler to leave out this footnote. In my > perfect world, seq/ISeq/sequence are synonyms, and nillability is a > property only of *functions*: seq and next. I understand why it is useful to use the noun "seq" to mean the fo

(rest ())

2009-02-27 Thread Mark Engelberg
Maybe it doesn't matter in practice, but does it seem odd to anyone else that (rest ()) returns () rather than nil? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email t

Re: (rest ())

2009-02-27 Thread Mark Engelberg
> Were you thinking of what's now called "next" and used to be called "rest"? No. > > Why did you expect nil from rest in this case? I expect: (rest [1]) -> () (rest []) -> nil Starting with the new lazier branch, we have a concept of an empty sequence. So the rest of a singleton yields an em

Observations about new lazy branch

2009-02-27 Thread Mark Engelberg
I just finished porting my combinatorics code to the new lazy constructs, and I discovered some subtleties to using lazy-seq that were not at first apparent. To begin with, consider the two versions of map: The old way: (defn map ([f coll] (when (seq coll) (lazy-cons (f (first coll)) (

Re: Observations about new lazy branch

2009-02-27 Thread Mark Engelberg
On Fri, Feb 27, 2009 at 8:33 PM, Jason Wolfe wrote: > > If lazy-cons makes your life easier, I think you can still have > something very much like it: > > (defmacro lazy-cons [x s] >  `(lazy-seq (cons ~x (lazy-seq ~s As you pointed out, in most contexts, this will double the number of lazy-s

Re: (rest ())

2009-02-28 Thread Mark Engelberg
As Rich explained in one post, in Lisp-like languages, there is a certain amount of intertwining between two views of a sequence which is a series of linked nodes. One way is to think about these nodes as just nodes with a first and rest. Another way is to think about each node as representing a

Re: Observations about new lazy branch

2009-02-28 Thread Mark Engelberg
On Sat, Feb 28, 2009 at 6:09 AM, Rich Hickey wrote: > I think your fundamental hangup is on looking at (rest x) as a > calculation/effect triggered by a consumer. (rest x) is logically just > a slot lookup that obtains another seq. The laziness of that seq is > its constructor's problem. Right,

Re: Observations about new lazy branch

2009-02-28 Thread Mark Engelberg
On Sat, Feb 28, 2009 at 6:09 AM, Rich Hickey wrote: > Clojure's fully-lazy now pretty much follows the "even" model > described by Wadler: > > How to add laziness to a strict language without even being odd: > > http://homepages.inf.ed.ac.uk/wadler/papers/lazyinstrict/lazyinstrict.ps OK, I just

Questions about nested associative structures

2009-03-05 Thread Mark Engelberg
1. What is the most elegant way to create/initialize a nested vector, such as to represent a double-dimensioned array? 2. There's get-in for nested structures and get for flat. There's update-in for nested structures, why not plain update for flat? 3. What would you predict to be the most effici

Comparing lists

2009-03-05 Thread Mark Engelberg
I know that this has been brought up several times here, but I don't recall whether there was ever any resolution: It seems reasonable to expect (compare '(1 2 3) '(4 5)) to do a lexicographic comparison of the two lists, just like (compare [1 2 3] [4 5]) does. Is there an intentional reason why

hash-map based on identity

2009-03-06 Thread Mark Engelberg
Is there a variation of hash-map which supports comparison of keys using identical? rather than = ? Ditto with sets. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

Re: hash-map based on identity

2009-03-07 Thread Mark Engelberg
Here's why it would be useful to have the option of hash maps that use identity... Let's say my keys are rather long lists. Equality comparison will be slow. But if I know that the keys are always the exact same long lists (perhaps because I traversed the key sequence to find a key with a certa

Re: Workflow poll?

2009-03-07 Thread Mark Engelberg
Anyone using IntelliJ or Netbeans as their primary development environment, or is that stuff too experimental? I've been using the Clojure-in-a-box setup for Windows, which was absolutely instrumental in getting me to try out Clojure. But if I keep downloading the latest versions of Clojure, it

Re: hash-map based on identity

2009-03-07 Thread Mark Engelberg
On Sat, Mar 7, 2009 at 2:57 PM, Rich Hickey wrote: > Identity is tested first in equality, if identical, equal, full stop. > So if you are using identical and unique collections as keys you'll > find them without a value-by-value comparison. If they are not > present, it's unlikely you'll get a m

Re: On the importance of recognizing and using maps

2009-03-08 Thread Mark Engelberg
On Sun, Mar 8, 2009 at 10:44 PM, mikel wrote: > Clojure doesn't have to provide these facilities (though I wouldn't > mind if it did); it just needs to stay out of my way when I decide I > need to add them. Yeah, as much as I like maps, I feel like there are several common uses cases for maps th

Re: naive euler43 blows heap, why?

2009-03-09 Thread Mark Engelberg
On Mon, Mar 9, 2009 at 9:55 AM, Tuomas J. Lukka wrote: > > You are "holding on to the head". Try replacing "def perms" with "defn > perms []" and calling it when you start using it. That way the > permutations are let go as soon as they come. I noticed this with some > scripts that go through lar

Re: Static type guy trying to convert

2009-03-10 Thread Mark Engelberg
I think the key to feeling confident in dynamically typed code is to go ahead and write out the "contract" for the function in your comments. You should always state what the "domain" and the "range" of the function are, so that you and other people can use the function appropriately. A static t

Re: Debugging support for clojure?

2009-03-11 Thread Mark Engelberg
On Wed, Mar 11, 2009 at 12:21 AM, Tassilo Horn wrote: > Investigated it a bit more (doing the algorithm step by step in the > repl) and now I know what's the culprit:  The `expt' function from the > math contrib library is dead slow. Dead slow? Compared to what? A naive expt function just mult

Question about throwing errors

2009-03-11 Thread Mark Engelberg
I'm thinking about implementing a backtracking mechanism that throws errors as a way to escape out of the current computation and try another possibility. I'd want to create a specific error to escape, and the backtracking mechanism should only catch this very specific error. Now, I vaguely reca

Re: Static type guy trying to convert

2009-03-11 Thread Mark Engelberg
I know of someone who tracked all his bugs in a year of coding in both Scheme (dynamic) and ML (static). He said that there was no real difference. The kind of bugs that are caught by static type systems are also quickly identified upon an initial run with a few basic test cases in a dynamic typ

Java equivalent to Python's Imaging Library (PIL)

2009-03-12 Thread Mark Engelberg
Can anyone point me to a PIL-like library that will work from Clojure? Thanks. --~--~-~--~~~---~--~~ 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 unsubs

Re: Performance tips for Clojure

2009-03-13 Thread Mark Engelberg
list doesn't do what you think it does. You've just created a list of one element. On Fri, Mar 13, 2009 at 12:10 AM, Sergio wrote: > (def ls (list (range 100))) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Question about IntelliJ Plugin

2009-03-13 Thread Mark Engelberg
If I split my code across files, how do I make it so that the REPL can "see" all the code? For example, if I have a main.clj and a tests.clj, when I run the REPL from one of the two files, it only sees the definitions from that file, not everything in the project. What's the right way to do this?

Re: errors?

2009-03-13 Thread Mark Engelberg
But how do you get rid of the (NO_SOURCE_FILE:0) messages for every single error? I'd really like to know the line number of the function that threw the error. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojur

Re: Which Java book(s) to order

2009-03-16 Thread Mark Engelberg
Of course, with respect to Clojure, probably the most important thing is to learn the Java *libraries*. What are good books about that? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Re: Behavior of 'empty'

2009-03-16 Thread Mark Engelberg
On Mon, Mar 16, 2009 at 3:54 PM, Frantisek Sodomka wrote: > (empty (seq [1 2])) => nil Now that there is the concept of empty sequences, maybe this should actually return an empty sequence, such as (). --~--~-~--~~~---~--~~ You received this message because you a

Re: Request Feedback on Clojure Blog Article

2009-03-16 Thread Mark Engelberg
On Mon, Mar 16, 2009 at 9:44 PM, Timothy Pratley wrote: > > Hi Keith, > > I don't follow the 'lazy-init' part... It seems to me that you create > a delay but force it immediately which is effectively just running > create-a-text-field. That behavior seems different from the factory > style return

Re: Request Feedback on Clojure Blog Article

2009-03-18 Thread Mark Engelberg
On Wed, Mar 18, 2009 at 10:40 PM, Stephen C. Gilardi wrote: > Because parallel bindings are also useful, I think it's an interesting idea > to extend let to allow it to take parallel bindings in a map instead of a > vector. These would act like Common Lisp's "let": > >        (def a 4) >        (

Re: What's a convenient way of calling super.method()?

2009-03-21 Thread Mark Engelberg
On Sat, Mar 21, 2009 at 1:38 PM, CuppoJava wrote: > (mymethod (assoc object :tag :super-class)) > which is a little clumsy. Not only is it clumsy, but if mymethod returns a fresh object that is based off of this object in some way (e.g., a non-destructive "setter"), the return value will have th

Shouldn't all defs have a - version?

2009-03-23 Thread Mark Engelberg
defn- is pretty useful. But wouldn't it be equally useful to have def-, defmulti-, defmacro-, etc.? I'm aware that it is possible to add the private tag to the metadata of the var, but in many code samples I've seen, people routinely get this wrong (I believe you need to attach the metadata to t

Re: What's a convenient way of calling super.method()?

2009-03-23 Thread Mark Engelberg
On Sun, Mar 22, 2009 at 1:17 PM, CuppoJava wrote: > So, considering it seems that not many other people have run into this > issue, can I assume that most people just haven't had a need to call a > super multi-method? Is it a bad design choice to call your inherited > methods? I haven't needed t

Information Hiding

2009-03-23 Thread Mark Engelberg
I've been thinking quite a bit about the OO side of Clojure the past couple of days, and trying to figure out how common OO design patterns would look when ported over to Clojure's way of doing things. The most obvious thing that others have noted is that you can effectively simulate a mutable ob

Re: Mapping a function over a map's values

2009-03-23 Thread Mark Engelberg
On Sun, Mar 22, 2009 at 11:53 PM, Jeff Valk wrote: > For the record, I think the original approach is the most clear. And it's > actually shorter. > > (defn mapmap [f m] >  (zipmap (keys m) (map f (vals m But it traverses m twice, which is likely to be less efficient. --~--~-~--~--

Re: Clojure talk at TSS

2009-03-23 Thread Mark Engelberg
On Mon, Mar 23, 2009 at 1:45 AM, Howard Lewis Ship wrote: > If you have a long running process that continually modifies a > collection and retains the new version ... does the new version retain > the old version?  For how long? In general, I think it's safe to assume that anything in the old v

Re: Information Hiding

2009-03-23 Thread Mark Engelberg
Yes, the :private metadata tag is probably the simplest way to make the whole object private, and then just expose the manipulation functions. The closure solution is similar in this regard. I guess the point I failed to convey is that I'm really wondering if there's a way to effectively make so

Re: Information Hiding

2009-03-23 Thread Mark Engelberg
On Mon, Mar 23, 2009 at 10:09 AM, Konrad Hinsen wrote: > You seem to envisage exposing some aspects of your data structure as > part of the public API and have others reserved for use by > "authorized" support function. Could you give an example of a > situation where this would be advantageous c

Re: I need help tracking down a performance problem.

2009-03-23 Thread Mark Engelberg
On Mon, Mar 23, 2009 at 7:31 PM, Vincent Foley wrote: > More generally, is it possible that I'm just doing this whole thing > wrong?  That using vectors to represent binary fields and records in a > declarative is just a bad idea and that I should try and explore lower- > level alternatives? >

Re: oo

2009-03-25 Thread Mark Engelberg
On Wed, Mar 25, 2009 at 1:44 AM, Konrad Hinsen wrote: > Could you elaborate a bit on this? I haven't met any major obstacles > with multimethods yet. The dispatch functions give quite a lot of > flexibility in practice. In what situation did you find them > inconvenient? To summarize, I think th

Re: Clojure + Java compilation and IntelliJ IDEA plugin

2009-03-25 Thread Mark Engelberg
If we've already downloaded the first plugin, what's the best way to upgrade? Do you have to delete the first one, or just install the second on top? Is there a way to update the plugin from within the IDE? Thanks. --~--~-~--~~~---~--~~ You received this message

Re: Is Clojure's lack of support for forward referencing a feature or a bug?

2009-03-25 Thread Mark Engelberg
On Wed, Mar 11, 2009 at 5:18 PM, Timothy Pratley wrote: > It is also quite trivial to patch the compiler to auto-def symbols as > it finds them instead of throwing an error. I would be interested in knowing how to do such a patch. When I work on code, I like to organize my functions in a way th

Re: oo

2009-03-27 Thread Mark Engelberg
I'm very interested in this thread. I'm having trouble figuring out exactly which situations require prefer-method and which do not. One thing that would help me understand the issues more deeply would be if someone could post the simplest possible multimethod that requires prefer-method to disa

Re: oo

2009-03-27 Thread Mark Engelberg
I think I've answered at least part of my own question. This is the simplest ambiguous case I've found: ab | | -- | c user> (defmulti test-prefer :tag) #'user/test-prefer user> (defmethod test-prefer ::a [h] "a") # user> (defmethod test-prefer ::b [h] "b") # user

Re: bug in clojure.contrib.math/exact-integer-sqrt

2009-03-29 Thread Mark Engelberg
Fixed. Thanks for the report. Aside from being a helper function for sqrt, exact-integer-sqrt is available in some Lisp and Scheme implementations. At first glance, you might think that calling (floor (sqrt n)) is sufficient, and no special function is needed. But for large integers which are

Quick slime/emacs questions

2009-03-29 Thread Mark Engelberg
When I have two windows open, and hit C-x-C-b, it pops up a list of buffers in the OTHER window from where the current focus is. Any idea why it's doing that, and how I can alter the behavior so it pops up the list of buffers in the current window? Also, where can I look up the names of various

Re: bug in clojure.contrib.math/exact-integer-sqrt

2009-03-29 Thread Mark Engelberg
If you don't care about the "leftover" portion that exact-integer-sqrt returns, you can do something like: (let [[floor-sqrt _] (exact-integer-sqrt n)] ...) or (first (exact-integer-sqrt n)) so I didn't want to expose another function which returns only half of the information that this one does.

Set bug?

2009-03-30 Thread Mark Engelberg
(def a (BigInteger. "123")) (= a 123); this prints true (= (hash a) (hash 123)) ; this also prints true So how come (count #{a 123}) prints 2 ? I'm aware that a and 123 have different types, but I was under the impression that the hash set implementation was supposed to just rely on hash co

Re: Quick slime/emacs questions

2009-03-30 Thread Mark Engelberg
I have CUA mode enabled, and it does most of those remappings, but not the C-s for save. I know searching is common, which is why I plan to remap C-f to search. Don't need existing binding for C-f since the arrow keys work just fine for moving around. I don't mind the normal Emacs bindings, exc

Re: Suggest patch to math.clj - integer-length

2009-03-30 Thread Mark Engelberg
This brings up an interesting question. Does Java guarantee that on all architectures and all future versions that Integers will be 32-bit and Longs will be 64-bit? I think the answer is yes, that this is part of the specification, but I'm not certain. --~--~-~--~~~-

Re: Set bug?

2009-03-30 Thread Mark Engelberg
My own opinions: I don't expect 1 to equal 1.0 (because I think of inexact numbers as fundamentally different from exact numbers). I think of 1.0 as a "number that's so close to 1 that we can't tell the difference, but it still might not be 1". I do expect 1 to equal 1/1, and I expect a long 1 to

Re: Set bug?

2009-03-30 Thread Mark Engelberg
On Mon, Mar 30, 2009 at 10:45 AM, Mark Engelberg wrote: > I don't know whether this fix would be worth the performance penalty, > though, but it's what would "feel right" to me. > If it's not practical to always reduce integers when used as keys, then I think

Re: Possible Solution for Left-Right Precedence and More when using Multimethods? (was re: oo)

2009-03-31 Thread Mark Engelberg
On Tue, Mar 31, 2009 at 9:45 AM, Konrad Hinsen wrote: > I think this should be sufficient to cover all cases you mentioned, > but of course it needs to be tried in practice. I think your idea of specifying a sequence of items to try in the dispatching function, at the point of definition for the

Re: Request for improved error reporting

2009-04-01 Thread Mark Engelberg
On Wed, Apr 1, 2009 at 9:10 AM, hughw wrote: > I don't mind scrolling through the long stack crawl to discover where > my error is. but I do wish the initial error report could somehow give > me the information, rather thanrequiring the two step process (and > switching windows when using the sli

Re: The Path to 1.0

2009-04-17 Thread Mark Engelberg
On Fri, Apr 17, 2009 at 6:21 AM, Rich Hickey wrote: > Overall, I'm getting feature requests (more change!) and not a strong > drive for 1.0 stability. If you feel otherwise, please speak up. > Otherwise, my conclusion is that 1.0 may be more important for not-yet- > users wary of working from sou

Re: a functional/persistent priority queue

2009-04-19 Thread Mark Engelberg
I'm curious to know how this approach compares to using Clojure's sorted sets or hash tables. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups

Re: Modifying data structures without changing their interface

2009-04-20 Thread Mark Engelberg
On Mon, Apr 20, 2009 at 1:27 PM, Bradbev wrote: > If you promise that > functions will accept and return maps with certain keys, then you must > keep that promise moving forward. I think you're missing part of the point of the original post. You don't really want to promise that your functions

Re: Abstract data types in functional languages

2009-04-21 Thread Mark Engelberg
On Mon, Apr 20, 2009 at 11:00 AM, Timo Mihaljov wrote: > Is the concept of Abstract Data Types [1] useful in Clojure? > > If yes, how would you implement one? I have composed a lengthy response to this question, and added it to my blog: http://programming-puzzler.blogspot.com/2009/04/adts-in-clo

Re: ICFP 2009

2009-04-22 Thread Mark Engelberg
Try your hand at one of the older contests, like this one: http://www.boundvariable.org/task.shtml --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googleg

Re: Abstract data types in functional languages

2009-04-23 Thread Mark Engelberg
In Clojure, the closest thing to an object (short of implementing a class in Java or using gen-class) is the map. But the more I play around with using maps to implement the kinds of things that objects are used for in other languages, the more I'm feeling that maps don't quite cut it. One probl

Re: Abstract data types in functional languages

2009-04-24 Thread Mark Engelberg
On Fri, Apr 24, 2009 at 2:21 AM, AndrewC. wrote: > If client code is using assoc and get then you haven't really started > thinking of your map as a new data type - you're still thinking of it > as a map. I disagree with this assertion, and the comparison to the SICP example. Unlike Scheme, Clo

Re: Abstract data types in functional languages

2009-04-24 Thread Mark Engelberg
Laurent, I think we're actually mostly in agreement here, although we differ on some of the details. I agree with the Principle of Uniform Access. One interpretation of this principle is that coders should never have a public field, and should always use getters and setters, to make the API futu

Re: Abstract data types in functional languages

2009-04-24 Thread Mark Engelberg
On Fri, Apr 24, 2009 at 3:36 PM, David Nolen wrote: > Is this really so hard? Are you telling me that you routinely write accessors for all your data structures in Clojure using those macros? I'll bet very few people do this. People make use of the facilities conveniently available to them. U

Re: Metadata for Any Object

2009-04-30 Thread Mark Engelberg
On Thu, Apr 30, 2009 at 6:01 AM, Rich Hickey wrote: > Then, you need to know which operations require metadata propagation. > That's built into the Clojure data structures but can't be retrofitted > to arbitrary types. Is there a list of which operations propagate metadata? I know I've been sur

Re: Metadata for Any Object

2009-04-30 Thread Mark Engelberg
On Thu, Apr 30, 2009 at 9:46 AM, Rich Hickey wrote: > However, there isn't a list, and metadata propagation could use an > audit. If there's a specific case where you think it should and it > doesn't please let me know. I think it just took me a while to figure out that cons does not preserve me

Printing to REPL from other threads in Slime

2009-05-05 Thread Mark Engelberg
I'm using Clojure Box's Emacs/Slime setup. When I invoke println from a newly-spun thread, I don't see the output in the REPL. Suggestions? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post

Re: The Santa Claus Problem

2009-05-05 Thread Mark Engelberg
I think that part of the point of the Santa Claus problem is to keep everything carefully synchronized. The Erlang and Erlang-inspired solutions are all inherently asynchronous, which means that other threads may be able to observe inconsistencies in state. This problem is compounded if you allo

Re: The Santa Claus Problem

2009-05-07 Thread Mark Engelberg
On Wed, May 6, 2009 at 12:38 AM, bOR_ wrote: > If i remember correctly, any agents send (or send-off?) within a > dosync are only send off after the dosync completed. Yes, that's the kind of semantics I want, but it would be rather clunky to have to set up an agent and fake a transformation of i

implicit dosync?

2009-05-11 Thread Mark Engelberg
I'm curious, wouldn't it be possible for every ref-set to be implicitly wrapped in a dosync? That way, you wouldn't have to explictly wrap ref-set in a dosync for the times where you just want to change one ref. You'd only need to explicitly call dosync when you need to wrap more than one ref-se

Breaking out of infinite loops

2009-05-12 Thread Mark Engelberg
I often write code that I just want to run in an infinite loop. The code generates lots of random things, and logs the interesting ones to a file. In Python, I'd write such code inside a try block that catches the Ctrl-C exception. So, when I want to use my computer for something else, I just h

Re: list vs vector

2009-05-16 Thread Mark Engelberg
In my own experimentation, I was really surprised to find that traversal over vectors seemed to be faster than lists, so I tend to use vectors rather than lists for any "fixed collection" that I'm basically just traversing once I've built. Haven't benchmarked recently, though, so this could have

Question about building modular code in Clojure

2009-05-16 Thread Mark Engelberg
So I've built a file/namespace with several functions. There are several globals defined at the top of the file (for example, *gravity*) which many of the functions refer to. I made them globals precisely because it would have been a pain to thread them through every single function that uses th

Re: Question about building modular code in Clojure

2009-05-17 Thread Mark Engelberg
Thanks for your questions. I'll try to explain better. First, I'll explain that my line of work is to build tools to generate puzzles. I often have a module which generates the puzzles through various random processes, using certain probabilities and parameters. Then, I have another module that

Re: Question about building modular code in Clojure

2009-05-17 Thread Mark Engelberg
On Sun, May 17, 2009 at 2:18 PM, mikel wrote: > I'm still not quite clear on exactly what you're trying to accomplish. > You showed how to accomplish your purpose in Clojure, but then > suggested that the result was not 'clean'. It's not quite clear what > you mean by 'clean'--that is, what featu

Re: Question about building modular code in Clojure

2009-05-17 Thread Mark Engelberg
On Sun, May 17, 2009 at 8:12 PM, David Nolen wrote: > Have you looked at the immigrate function in Compojure? This imports public > vars from a different namespace into a namespace as if they were defined > there.  Maybe this is enough to get the behavior that you want? Not really. Consider the

Re: Question about building modular code in Clojure

2009-05-17 Thread Mark Engelberg
David, that seems to work. I think I can achieve my objectives with this strategy. However, I must admit, I find it rather unsettling that collections of functions written inside of namespaces are fundamentally less composable than those that are not. It means that to remain extensible, I need

Re: Question about building modular code in Clojure

2009-05-17 Thread Mark Engelberg
BTW, for those of you interested in reading academic papers about modules in functional programming langs, I found this list of articles: http://www.readscheme.org/modules/ I remember reading about PLT Scheme's units several years ago, and I think it's pretty much what I'm looking for, with the a

Re: Question about building modular code in Clojure

2009-05-18 Thread Mark Engelberg
On Sun, May 17, 2009 at 11:48 PM, Konrad Hinsen wrote: > It's the approach of "cloning and > mutating" something that smells of "quick and dirty", although I > agree it is quite convenient in the prototyping phase. I disagree that incremental extension of a module is a "quick and dirty" prototy

Re: Question about building modular code in Clojure

2009-05-18 Thread Mark Engelberg
On Mon, May 18, 2009 at 1:17 AM, Adrian Cuthbertson wrote: > (alter-var-root (var say-grav) (fn [_] (fn [x] (prn "my-version-grav:" x But this only works if you only want one variation, and you no longer care about the original version, right?. If you want to benchmark your variation agains

Re: Question about building modular code in Clojure

2009-05-18 Thread Mark Engelberg
On Mon, May 18, 2009 at 4:23 AM, Laurent PETIT wrote: > The most modular I can think of right now is just about creating a > gravity type and using multimethods for all your functions. > > This way you would have dynamic resolution of methods that do not work > with precompiled fns. Can you elab

Re: Question about building modular code in Clojure

2009-05-18 Thread Mark Engelberg
On Mon, May 18, 2009 at 2:16 AM, Meikel Brandmeyer wrote: > If that is true, you should maybe consider some glue. > >     /- Analysis > Glue -- Solve >     \- Create > > The Glue part combines/uses the different modules. There you > could change parameters easily with binding, swap in another > a

Re: Clojure at JavaOne

2009-05-18 Thread Mark Engelberg
For me, persistent vectors was the killer feature that drew me to Clojure. Don't know how to convey the value of that in 4 minutes, though. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to

Re: Question about building modular code in Clojure

2009-05-19 Thread Mark Engelberg
On Tue, May 19, 2009 at 6:18 AM, Meikel Brandmeyer wrote: > I think the idea of decoupling is called "inversion of control" > or "dependency injection". I'm sure it works for you, but it > sure did in this (admittedly) simple example. There are > various ways at passing around parameter: > - glob

Re: Question about building modular code in Clojure

2009-05-19 Thread Mark Engelberg
On Tue, May 19, 2009 at 9:08 PM, George Jahad wrote: ]> It seems like what you are really trying to do is simulate > inheritance/overriding in clojure.  What's wrong with using > gen-class and proxy for that? I guess it's still an open question as to whether gen-class and proxy are mainly for Ja

Re: Question about building modular code in Clojure

2009-05-22 Thread Mark Engelberg
On Wed, May 20, 2009 at 8:14 AM, Konrad Hinsen wrote: > Here is another solution that I consider preferable to the use of > load. Konrad, this is an interesting approach, and it does feel like a better way to organize similar modules than using load. However, there seems to be one way that this

Re: Question about building modular code in Clojure

2009-05-22 Thread Mark Engelberg
On Fri, May 22, 2009 at 1:37 AM, Konrad Hinsen wrote: > As long as it uses the same variables as the template, it would still > work, but (like the load-and-redefine method) it would fail as soon > as the template author decides to change the names of his variables. > I suppose that to some exten

Re: compilation and classpath

2009-05-22 Thread Mark Engelberg
I also had lots of problems getting compilation to work. I think perhaps Clojure is making some assumptions about where your working directory is located relative to your clojure.jar and classpath, and if you have a different directory structure, things fail. For me, the solution was to explicit

Re: Question about building modular code in Clojure

2009-05-22 Thread Mark Engelberg
OK, after looking at deftemplate with macroexpand, it's starting to make more sense. I suppose one downside to this versus load is that it's probably much more difficult to debug (just because all your code is wrapped in a macro), but basically I like the idea. --~--~-~--~~--

Scoping question

2009-05-27 Thread Mark Engelberg
Is there any practical difference between: (let [x 2] (defn f [] x)) and (def f (let [x 2] (fn [] x)))? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to cloju

Re: Scoping question

2009-05-27 Thread Mark Engelberg
No, I was just worried that using def/defn not at the top level, but inside a let, might have unforeseen consequences. On Wed, May 27, 2009 at 3:48 AM, Rich Hickey wrote: > No, are you experiencing one? > --~--~-~--~~~---~--~~ You received this message because yo

Re: Clojure Book example that has unexpected effect in trunk version of Clojure

2009-05-31 Thread Mark Engelberg
I posted about this recently. In emacs/slime, printed output on other threads does not appear. I have not found a workaround, other than running such code in a standard REPL. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: Clojure Book example that has unexpected effect in trunk version of Clojure

2009-06-01 Thread Mark Engelberg
What happens to compile errors once you make that change. Do they end up in the REPL too? --~--~-~--~~~---~--~~ 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

Re: Clojure for Scientific and other CPU-intensive Computing

2009-06-30 Thread Mark Engelberg
On Tue, Jun 30, 2009 at 12:29 AM, Konrad Hinsen wrote: > What is particularly nice about Clojure is that in most situations > you don't need to switch to Java for speed. You can optimize your > code by adding type hints and switching to low-level data structures > (unboxed ints and floats, arrays,

Re: loneclojurian at ICFP programming contest

2009-07-01 Thread Mark Engelberg
On Wed, Jul 1, 2009 at 2:08 PM, Daniel Lyons wrote: > > > On Jul 1, 2009, at 2:24 PM, fft1976 wrote: > >> Isn't it strange that Clojure with type declarations (that some people >> say should be as fast as Java) was only as fast as Python (which does >> not allow type declarations and does not exac

Bug with struct-maps and *print-dup*

2009-07-09 Thread Mark Engelberg
I'm running Clojure 1.0. Could someone please check and see whether this is still a bug in the most current version? (use 'clojure.contrib.duck-streams) (defstruct t :a) (def x (struct-map t :a 1)) (def s (binding [*print-dup* true] (with-out-str (pr x (read-string s) ERROR: java.lang.Runti

Re: Clojure vectors

2009-07-13 Thread Mark Engelberg
On Mon, Jul 13, 2009 at 8:15 AM, Jan Rychter wrote: > And while we're on the subject -- any hints for implementing a stack > with a fast item count? (apart from a list with a separate counter) Using conj and pop on vectors for stack operations should work just fine. Don't use subvec though; nest

Re: Bug with struct-maps and *print-dup*

2009-07-13 Thread Mark Engelberg
On Fri, Jul 10, 2009 at 6:52 AM, J. McConnell wrote: > > On Thu, Jul 9, 2009 at 11:31 PM, Mark Engelberg > wrote: >> >> I'm running Clojure 1.0. >> >> Could someone please check and see whether this is still a bug in the >> most current version? &g

Clojure emacs formatting of letfn

2009-07-14 Thread Mark Engelberg
I'm using Clojure Box on Windows, corresponding to version 1.0. I'm unhappy with the way it formats the letfn special form. It doesn't seem to know that this form is used for defining functions, so the formatting doesn't look anything at all like a function definition. Any suggestions on how to

<    1   2   3   4   5   6   7   8   9   10   >