Re: Atn: Konrad Hinsen -- suggested change to letfn in contrib

2009-02-11 Thread Konrad Hinsen
On 10.02.2009, at 19:18, Jeffrey Straszheim wrote: I suggested the following changed to letfn: http://code.google.com/p/clojure-contrib/issues/detail?id=26 and have been informed that you manage this code. Does this change look good to you? Fine! It's applied and committed. Thanks!

Re: A Clojure documentation browser

2009-02-11 Thread Konrad Hinsen
On Feb 10, 2009, at 18:02, Craig Andera wrote: One of the challenges with learning any new platform is learning the libraries. As a way to improve both that an my knowledge of Clojure itself, I whipped together doc-browse, a Clojure library that will spit out an HTML page that contains

Re: A Clojure documentation browser

2009-02-11 Thread Konrad Hinsen
On Feb 11, 2009, at 13:07, Christian Vest Hansen wrote: I suppose I need to add javax.xml to my classpath, but where do I get it from? I searched a bit and it looks like this is in the standard Java distribution, but in which jar file? It was added in Java 6. Could you perchance be running

Re: with-local-vars vs. let

2009-02-13 Thread Konrad Hinsen
On Feb 13, 2009, at 13:31, Mark Volkmann wrote: What are some reasons to use with-local-vars instead of let or binding? Let just creates bindings for a lexical scope. They cannot be modified at all. Binding and with-local-vars deal with vars, i.e. mutable references. Binding creates a

Re: with-local-vars vs. let

2009-02-13 Thread Konrad Hinsen
On Feb 13, 2009, at 15:35, Adrian Cuthbertson wrote: Have a look at compojure - a good example of with-local-vars is where a servlet request is executed. Each (get, post) request occurs in its entirety on a single (jetty or tomcat) thread. The compojure call to the application service

Re: Fully lazy sequences are coming - feedback wanted!

2009-02-15 Thread Konrad Hinsen
On 15.02.2009, at 20:48, Vincent Foley wrote: I'll play around with the lazy branch this week, and this is just a name suggestion: what do you think of first/tail/rest where (rest s) == (seq (tail s))? tail is already used in other functional languages such as Haskell and OCaml to represent

Re: Fully lazy sequences are coming - feedback wanted!

2009-02-15 Thread Konrad Hinsen
On 15.02.2009, at 18:18, Rich Hickey wrote: I've been working on this for a few months, in lieu of more interesting things, because I knew it would be a breaking change and we're trying to get the biggest of those behind us. I appreciate any effort you spend in trying to provide informed

Re: Fully lazy sequences are coming - feedback wanted!

2009-02-16 Thread Konrad Hinsen
On Feb 16, 2009, at 3:44, Rich Hickey wrote: There will need to be good descriptions of these, but the similarity is more in names than anything else - seqs are what they always were - cursors, and sequences are just collections. That distinction is quite clear, the problem is indeed just in

Anonymous recursive functions

2009-02-16 Thread Konrad Hinsen
I just discovered a nice feature that I don't remember having seen discussed or documented before: there is a way to write recursive functions without having them associated to any var/symbol in any namespace. The optional name of a function can be used for a recursive call. Example:

Re: state monad transformer

2009-02-17 Thread Konrad Hinsen
On 16.02.2009, at 23:38, jim wrote: Here's a shot at implementing a monad transformer for the state monad. Any chance of getting it added to clojure.contrib.monads? If you are on the list of contributors (those who have signed a contributor agreement), yes, of course! Konrad.

Re: terminology question re: binding

2009-02-17 Thread Konrad Hinsen
On Feb 17, 2009, at 0:17, Stuart Sierra wrote: As I understand it, every Var has a name, which is a symbol, but the name is an inherent property of the Var and cannot be changed. You Unless you create a var using with-local-vars, right? Konrad.

Re: Fully lazy sequences are coming - feedback wanted!

2009-02-17 Thread Konrad Hinsen
On Feb 16, 2009, at 20:23, Rich Hickey wrote: It seems the Sequence/ISeq dichotomy was a sticking point for many. After some tweaking, I've been able to get rid of Sequence entirely, SVN 1284+ in lazy branch. This is source compatible with 1282 (first/ rest/next), except that sequence? no

Clojure.contrib: name changes in monads

2009-02-18 Thread Konrad Hinsen
The latest Clojure version broke many of my code by introducing the function sequence whose name collided with my sequence monad. So I decided that since now is the time for breaking changes, I should solve that kind of problem thoroughly. I just renamed all monads in

Re: Parenscript in clojure?

2009-02-18 Thread Konrad Hinsen
On Feb 18, 2009, at 9:39, Jan Rychter wrote: Is anyone working on a Parenscript (http://common-lisp.net/project/parenscript/) for Clojure? There's Chouser's ClojureScript in clojure.contrib. I don't know if it is similar to Parenscript, but it has similar goals: compile Clojure (or at

Re: Clojure.contrib: name changes in monads

2009-02-18 Thread Konrad Hinsen
On 18.02.2009, at 22:40, jim wrote: Here's an updated state-m monad transformer. I dropped my CA in the mail today. I figure if I post a snippet of code to the list, it's public domain, so do with it as you wish. Or wait till Rich gets my CA. Thanks! It's in my working copy of the

Re: Clojure.contrib: name changes in monads

2009-02-22 Thread Konrad Hinsen
Jim, As long as your breaking things in monads, what would you think of changing m-seq to this. ... so that it doesn't accept a list of monadic values but instead lets you call it with any number of mv's. Instead of: (m-seq [mv1 mv2 mv3]) you would write (m-seq mv1 mv2 mv3) That

Re: where is contrib?

2009-02-23 Thread Konrad Hinsen
On 21.02.2009, at 18:25, Frantisek Sodomka wrote: For example, lazy-cons is still present in: combinatorics.clj lazy_xml/with_pull.clj monads/examples.clj In monads/examples, it is used inside a macro that chooses lazy-seq or lazy-cons according to which version of Clojure is running, so

Re: Clojure Questions

2009-02-23 Thread Konrad Hinsen
On 21.02.2009, at 19:57, Christian Vest Hansen wrote: I *think* that Clojure does not require anything from Java 6, and thus can work on any compliant Java 5 or greater. I run it with Java 5, which is the latest Java available for MacOSX 10.4 on a PowerPC. It works fine. Konrad.

Re: Directed Graphs for Contrib

2009-02-23 Thread Konrad Hinsen
On 22.02.2009, at 02:59, Jeffrey Straszheim wrote: As part of my Datalog work I'm putting together some directed graph algorithms, mostly things like finding strongly connected components, and building dependency stratifications (think topological sort but with the results groups in

Another look at streams

2009-02-23 Thread Konrad Hinsen
I have been playing a bit more with the concept of a data stream for building computational pipelines. The result has replaced my previous experimental stream-utils library in clojure.contrib: http://code.google.com/p/clojure-contrib/source/browse/trunk/src/

Re: Problem with svn checkout

2009-02-24 Thread Konrad Hinsen
On Feb 24, 2009, at 9:26, atreyu wrote: i get this error: svn: server sent unexpected return value (400 Bad Request) in response to REPORT request for '/svn/!svn/vcc/default' yes im a newbie with subversion and im behind a proxy in a windows pc. I try to configure the proxy settings but

Privacy problems with clojure-contrib mirrors

2009-02-24 Thread Konrad Hinsen
There are a couple of mirrors of clojure-contrib out there, for example: http://bitbucket.org/shoover/clojure-contrib-mirror/overview/ (Mercurial) http://github.com/kevinoneill/clojure-contrib/commits/ (git) While it is nice to have clojure-contrib accessible through different version

Re: Privacy problems with clojure-contrib mirrors

2009-02-24 Thread Konrad Hinsen
On Feb 24, 2009, at 17:55, Cosmin Stejerean wrote: But more importantly you can't expect that people go ahead and change all (any really) of the existing git or mercurial clones of the repository. You can probably trying filing bug requests with github or bitbucket to not show email

Re: Algebraic data types in clojure.contrib

2009-02-25 Thread Konrad Hinsen
On Feb 25, 2009, at 16:32, Jeffrey Straszheim wrote: Is there any reason they cannot be implemented as structs with some sort of type tag? I suspect that could be done, but some nice features would be lost: 1) User-friendly printing. I implement the multimethods print-method and print-dup

Re: Algebraic data types in clojure.contrib

2009-02-25 Thread Konrad Hinsen
On Feb 25, 2009, at 17:40, David Nolen wrote: Should print and println be multimethods? It seems the ability to custom print a data structure would be generally useful. It's already there, just not documented as far as I know. All the printing routines end up calling

Re: Algebraic data types in clojure.contrib

2009-02-26 Thread Konrad Hinsen
On 26.02.2009, at 08:47, Jeff Valk wrote: String representation obviously uses :type now in a very particular way. I'm not sure where this happens though. Can anyone shed some light on the details? print-method now dispatches on type, rather than class as it did before. There is no

Re: Algebraic data types in clojure.contrib

2009-02-26 Thread Konrad Hinsen
On 26.02.2009, at 01:51, Rich Hickey wrote: You raise interesting issues and I'd like to explore them further. I'm not sure the issues you have with type-tag-or-class dispatch are all that prohibitive. In any case, I've added a type function that returns the :type metadata or the class if

Re: Algebraic data types in clojure.contrib

2009-02-26 Thread Konrad Hinsen
On Feb 26, 2009, at 1:51, Rich Hickey wrote: You raise interesting issues and I'd like to explore them further. I'm not sure the issues you have with type-tag-or-class dispatch are all that prohibitive. In any case, I've added a type function that returns the :type metadata or the class if

Syntax-quote only as a reader macro?

2009-02-26 Thread Konrad Hinsen
I am trying to do the equivalent of a syntax-quote (converting unqualified symbols to namespace-qualified symbols) inside a macro, but it seems there is no built-in function to do this. Am I overlooking something? At the moment I am using the following function, which does a syntax- quote

Re: Waterfront - The Clojure-based editor for Clojure

2009-02-26 Thread Konrad Hinsen
On Feb 26, 2009, at 12:30, Itay Maman wrote: In Java6 @Override can also be attached to a method that overrides an interface-declared method. So, the code is not supposed to compile w/ a Java5 compiler. As for the Java6 compiler, my guess is that your compile is configured to be Java5

Re: Syntax-quote only as a reader macro?

2009-02-26 Thread Konrad Hinsen
On Feb 26, 2009, at 13:04, Konrad Hinsen wrote: Of course that should better be ... so that it doesn't mess up already qualified symbols. And even that is not good enough: it won't handle symbols/vars from other namespaces that are referred to. And that's where I am lost. I can't find

Re: Syntax-quote only as a reader macro?

2009-02-26 Thread Konrad Hinsen
On 26.02.2009, at 20:25, Chouser wrote: I've got essentially the same thing for use in error-kit: (defn- qualify-sym [sym] (let [v (resolve sym)] (assert v) (apply symbol (map #(str (% ^v)) [:ns :name] Except that you get the information from the metadata. I wonder

Re: Algebraic data types in clojure.contrib

2009-02-26 Thread Konrad Hinsen
On 26.02.2009, at 10:00, Konrad Hinsen wrote: I know, but as I said, my current implementation is just a proof of concept. It is not viable for production use for a variety of reasons. I was planning to replace it by something based on gen-class and proxy, but I will first try to get away

Re: Mathy operations on non-numerics (was Adding strings)

2009-02-26 Thread Konrad Hinsen
On 26.02.2009, at 20:18, Phil Hagelberg wrote: One approach that's been proposed in #clojure is to make these functions more capable by default, but then provide a fast-math library that could redefine them in terms of numerics-only. I'm a big fan of functions doing the most helpful

namespace docstrings

2009-02-26 Thread Konrad Hinsen
I have been trying in vain to get the namespace docstring of anything with print-namespace-doc. It doesn't say what exactly it wants as an argument (a symbol, a string, or a namespace object), but it calls ns-name, which wants a symbol, so I give it a symbol. But the symbol doesn't have

Patch for print-method

2009-02-26 Thread Konrad Hinsen
The attached patch to clojure.core fixes the printing problem for types that have no implementation of print-method. When such objects are printed or converted to strings, an infinite loop leads to a stack overflow. The reason is that the :default implementation for print-method calls str

Re: functions and macros in memory

2009-02-27 Thread Konrad Hinsen
On 27.02.2009, at 14:46, Mark Volkmann wrote: Is it correct to say that each loaded function is represented by an AFn object in memory? Each compiled function becomes a class that extends AFn. When the function is created in the Clojure code, an object is generated from this class. If you

Re: Algebraic data types in clojure.contrib

2009-03-02 Thread Konrad Hinsen
On 02.03.2009, at 01:50, Rich Hickey wrote: I was wondering if you considered using maps or struct-maps for this. One of my pet peeves with algebraic data types is the unnamed, positional nature of the components/fields. It always bothers me you have to rename the fields in every pattern

Namespaces, use, and refer

2009-03-02 Thread Konrad Hinsen
Over the last weeks, two additions to clojure.core broke several of my library modules by introducing names into the clojure.core namespace that I was using in my libraries as well. While this kind of problem is acceptable in a pre-release development period, I don't expect it to go away

Re: Namespaces, use, and refer

2009-03-02 Thread Konrad Hinsen
On Mar 2, 2009, at 18:35, srolls wrote: I think :exclude is what you want (ns my-ns (:refer-clojure :exclude [get replace])) Not quite, as exclude requires me to know what I want exclude. What I want is exclude everything that wasn't there in version X.Y. Konrad.

Re: conditions in monad comprehensions

2009-03-02 Thread Konrad Hinsen
On 02.03.2009, at 18:48, Matthew D. Swank wrote: Why is it necessary to pass a dummy result in the conditional code: (if (identical? bform :when) (list 'm-bind `(if ~expr (~'m-result ::any) ~'m-zero) (list 'fn ['_] mexpr)) ... Why not: (if (identical?

Re: Namespaces, use, and refer

2009-03-02 Thread Konrad Hinsen
On 03.03.2009, at 00:53, Laurent PETIT wrote: I'm able to do that from the REPL when done one by one : (clojure.core/ns-unmap *ns* (quote filter)) (clojure.core/defn filter [] oh my!) thus correctly redefining the binding of filter for the rest of use by the ns But I can't manage to

Re: sequences from Enumerations

2009-03-02 Thread Konrad Hinsen
On 03.03.2009, at 01:01, Stephen C. Gilardi wrote: The seq function is not able to provide a seq on either an Enumeration or an Iterator. clojure.core provides enumeration-seq and iterator-seq to create seqs on them. Yesterday I added a generic anything-to-seq multimethod to

Re: conditions in monad comprehensions

2009-03-03 Thread Konrad Hinsen
On 02.03.2009, at 19:52, Konrad Hinsen wrote: At first look it seems your simplified version is indeed equivalent. I will look at it again tomorrow after a good night's sleep :-) At second look, I still agree, so I update the implementation in clojure.contrib.monads. Konrad

Re: Waterfront 148 (was: Waterfront - The Clojure-based editor for Clojure)

2009-03-03 Thread Konrad Hinsen
On 27.02.2009, at 15:14, Itay Maman wrote: Revision 148 is available for download at http://sourceforge.net/project/platformdownload.php?group_id=249246 It addresses some of the requests that were raised in this discussion: * Changed default location of the divider * Fixed the command-key

Re: Waterfront 148 (was: Waterfront - The Clojure-based editor for Clojure)

2009-03-03 Thread Konrad Hinsen
On Mar 3, 2009, at 11:46, Tom Ayerst wrote: If you pull trunk out of subversion you can build it locally with Ant. Would that do it? Definitely, thanks! I pulled the latest revision and built it by typing ant. No compilation errors, but I can't run it either: Can't load plugin

Re: Waterfront 148 (was: Waterfront - The Clojure-based editor for Clojure)

2009-03-03 Thread Konrad Hinsen
Itay, Alternatively hoping that this is the only Java6-only dependency in the code, you can also apply this patch to clj/net/sourceforge/ waterfront/ide/plugins/file.clj (I didn't test is though - I am away from my machine, so no warranty...) Thanks for the quick fix, it works! I can now

Metadata on functions

2009-03-04 Thread Konrad Hinsen
Rich, is there a reason why metadata is explicitly disabled on function objects? I find myself wanting to put metadata on functions frequently. It seems even more important for functions than for anything else, given that there is no way to inspect a function object at all, it's a

Re: Inclusive-exclusive range

2009-03-04 Thread Konrad Hinsen
On Mar 4, 2009, at 14:06, Mibu wrote: On Mar 4, 2:46 pm, Michael Wood esiot...@gmail.com wrote: On Wed, Mar 4, 2009 at 2:07 PM, Mibu mibu.cloj...@gmail.com wrote: Why does range in Clojure use an inclusive-exclusive range? For what it's worth, Python's range function works the same way. I

Re: Clojure-contrib build fails

2009-03-04 Thread Konrad Hinsen
On Mar 4, 2009, at 18:21, timc wrote: After checking out the trunk of clojure-contrib (revision 565) and doing ant jar, I get this: compile_clojure: [java] Compiling clojure.contrib.accumulators to C: \eclipseWS1\clojure-cont rib\classes [java]

Re: Clojure's syntax design: macros vs functions

2009-03-05 Thread Konrad Hinsen
On 05.03.2009, at 02:03, Elena wrote: I wonder if Clojure does employ the same syntax either for macros and functions by design or it's just a remainder of Lisp. I think that a I am sure it's by design, just as for Lisp. Remember that Lisp has been around for 50 years and has been used by

Monad tutorial, part 1

2009-03-05 Thread Konrad Hinsen
For those who are interested in monads but don't want to learn Haskell first to understand the Haskell-based monad tutorials, I have started to write a Clojure monad tutorial. Part 1 is now available: http://onclojure.com/2009/03/05/a-monad-tutorial-for-clojure- programmers-part-1/

Re: Monad tutorial, part 1

2009-03-06 Thread Konrad Hinsen
On Mar 5, 2009, at 19:21, Konrad Hinsen wrote: For those who are interested in monads but don't want to learn Haskell first to understand the Haskell-based monad tutorials, I have started to write a Clojure monad tutorial. Part 1 is now available: Part 2 is now published as well: http

Re: What is Clojure NOT good for?

2009-03-06 Thread Konrad Hinsen
On Mar 6, 2009, at 14:15, Joshua Fox wrote: Is it fair to say that Clojure shines in algorithmic processing, string processing, concurrency management, but that there are better choices in other areas: I'd say that Clojure is probably suited for anything that the JVM is suited for. Its

Re: defining types and interfaces

2009-03-08 Thread Konrad Hinsen
On 08.03.2009, at 00:14, mikel wrote: You can do a lot of that in Clojure, too, but, unless I'm mistaken, there are some arbitrary limits as things stand right now. I don't know of a way in Clojure to define an interface; as far as I know, if Multimethods can be used very well to define

Re: Static type guy trying to convert

2009-03-11 Thread Konrad Hinsen
On Mar 11, 2009, at 3:31, Jon Harrop wrote: Most of the reasons given in this thread were red herrings and many of static typing's real issues were not even touched upon: ... I'd add two more: - Metaprogramming is a lot more complicated with static typing. Look at MetaOCaml or

Re: On the importance of recognizing and using maps

2009-03-11 Thread Konrad Hinsen
On Mar 8, 2009, at 18:53, Rich Hickey wrote: I know people usually think of collections when they see vector/map/ set, and they think classes and types define something else. However, the vast majority of class and type instances in various languages are actually maps, and what the

Re: On the importance of recognizing and using maps

2009-03-12 Thread Konrad Hinsen
On 11.03.2009, at 23:34, Chouser wrote: Interacting directly with a class dict feels a little dirty, because you could be circumventing the API provided by the class methods, making it easy to get the object into a bad state. Clojure's maps being immutable reduces the amount of trouble you

Re: Debugging support for clojure?

2009-03-12 Thread Konrad Hinsen
On Mar 11, 2009, at 19:04, Jerry K wrote: I had thought a while back about digging into building some math code for clojure contrib for applications like algebra and number theory, since Clojure's Lispyness makes it well suited for that, but wasn't sure anybody else was especially

Re: On the importance of recognizing and using maps

2009-03-12 Thread Konrad Hinsen
On Mar 12, 2009, at 10:59, Jeff Rose wrote: My main conclusion is that Clojure's system is a lot more flexible but also a lot more fragile. Any function can modify data of any type (as defined by metadata), even without being aware of this. Modifying type tags without being aware of it?

New version of clojure.contrib.types

2009-03-12 Thread Konrad Hinsen
After a lot of experimentation with types and interfaces, I have somewhat redesigned clojure.contrib.types. The new version contains some breaking changes, but the changes are minor. There are now two different ways to define types, one of them being algebraic data types, which are now

New clojure.contrib.stream-utils

2009-03-12 Thread Konrad Hinsen
I just checked in an almost complete reimplementation of clojure.contrib.stream-utils. It is now centered around an interface for data streams that consists of the single multimethod stream-next. It takes a stream state as its argument and returns the next value of the stream as well as

Re: ANN: A pretty printer for Clojure

2009-03-12 Thread Konrad Hinsen
On Mar 12, 2009, at 8:05, Tom Faulhaber wrote: I have now released the first version of my pretty printer as part of my cl-format library. It is released under the EPL. From what I have seen in my first tests, this is likely to become an essential part of my Clojure environment. Thanks!

Generic maths (was: Debugging support for clojure?)

2009-03-12 Thread Konrad Hinsen
On Mar 12, 2009, at 10:54, Konrad Hinsen wrote: Building a math environment is one of my long-term goals in working with Clojure, and my recent experiments with types and interfaces are partly motivated by this. What I have in mind is an infrastructure consisting of a few well-designed

Re: Symbols evaluated at compile time?

2009-03-16 Thread Konrad Hinsen
On 16.03.2009, at 11:35, Elena wrote: in this code: (defn main [] (check-services)) (defn check-services [] 1) if I call slime-eval-defun on main before calling it on check- services, Clojure aborts with: java.lang.Exception: Unable to resolve symbol: check-services in

Slash mystery

2009-03-18 Thread Konrad Hinsen
Consider the following session: user= / #core$_SLASH___3331 clojure.core$_slash___3...@7a916b user= clojure.core// #core$_SLASH___3331 clojure.core$_slash___3...@7a916b user= (ns-unmap *ns* '/) nil user= / java.lang.Exception: Unable to resolve symbol: / in this context (NO_SOURCE_FILE:0)

Re: Slash mystery

2009-03-19 Thread Konrad Hinsen
On 18.03.2009, at 19:03, Konrad Hinsen wrote: Why is user// an invalid token, whereas clojure.core// works perfectly well? I found out in the meantime that clojure.core// is indeed handled as a special case by the reader (line 276 in LispReader.java), but that still doesn't answer

Re: Can Clojure simulate Class?Lisp can do it!

2009-03-19 Thread Konrad Hinsen
On 19.03.2009, at 07:54, Edward Shen wrote: Can Clojure simulate Class?Lisp can do it! Anyone know it? Clojure can do it as well. Look here for a library that does it: http://github.com/swannodette/spinoza/tree/master Konrad.

Complex numbers in clojure.contrib

2009-03-19 Thread Konrad Hinsen
I just checked in clojure.contrib.complex-numbers, a complex number library. For the moment it implements only comparison and arithmetic, but I intend to add maths functions later. Complex numbers are represented by struct maps with two keys, :real and :imag. The real and imaginary parts

Re: Request Feedback on Clojure Blog Article

2009-03-20 Thread Konrad Hinsen
On Mar 20, 2009, at 14:35, Joshua Fox wrote: I thought of let as a sort of variable declaration, and so, one would want to keep it simple and not do complex calculations in the let binding expressions. On the other hand, the sequential mutually-dependent let bindings are of course

Defaults for multi-argument dispatch

2009-03-20 Thread Konrad Hinsen
Providing a :default implementation for multimethods is a very common and useful technique, but it is really useful only for multimethods that dispatch on a single argument. What I am looking for is an equivalent technique for multiple-argument dispatch. Suppose you have a multimethod + of

Re: Defaults for multi-argument dispatch

2009-03-20 Thread Konrad Hinsen
On Mar 20, 2009, at 16:35, Paul Stadig wrote: You could use multiple multi-methods: ... Not pretty, as you said, but also not quite the same in behaviour as a single multimethod dispatching on both arguments. Multiple dispatch can be made symmetric in the arguments, whereas a chain of

Re: Defaults for multi-argument dispatch

2009-03-20 Thread Konrad Hinsen
On Mar 20, 2009, at 16:18, Rich Hickey wrote: Providing a :default implementation for multimethods is a very common and useful technique, but it is really useful only for multimethods that dispatch on a single argument. I disagree about that. No dispatch value, composite or not, is still a

Re: Mapping a function over a map's values

2009-03-23 Thread Konrad Hinsen
On 22.03.2009, at 21:10, Jon Nadal wrote: I often need to map a function over the values of a map while preserving keys--something like: ... Is there a more concise way to do this in Clojure? If not, is this something that might be worth putting in the contrib? Look at

PATCH: universal parent type for Clojure hierarchies

2009-03-23 Thread Konrad Hinsen
The attached patch to clojure.core implements an optional universal parent type for Clojure hierarchies and defines such a type for the global default hierarchy. With this patch applied, Clojure passes the test_clojure and test_contrib test suites in clojure.contrib. I also tested it with

Re: March 20th 2009 Rich Hickey Appreciation Day!

2009-03-23 Thread Konrad Hinsen
On Mar 22, 2009, at 11:47, stephaner wrote: I join the crowd too, Me too! Like many here, I have used lots of languages over time, starting with Microsoft Basic in 1982 and ranging from various Assemblers via C and Fortran to more recent high-level languages. For the last twelve years,

Re: Mapping a function over a map's values

2009-03-23 Thread Konrad Hinsen
On Mar 23, 2009, at 12:15, Mark Volkmann wrote: Look at clojure.contrib.generic.functor/fmap. It does what you need for maps, for all the other Clojure collections (where it works like map except that its return value is a collection of the same type as the input value), and you can

Part 3 of the monad tutorial

2009-03-23 Thread Konrad Hinsen
I just published part 3 of my monad tutorial for Clojure: http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure- programmers-part-3/ This part's topics are - m-zero, m-plus, and :when clauses in domonad - the state monad As always, don't hesitate to leave your comments on the

Re: Mapping a function over a map's values

2009-03-23 Thread Konrad Hinsen
On Mar 23, 2009, at 14:26, Mark Volkmann wrote: That leaves the question whether there is still any need for the clojure.lang.ISeq implementation. At the moment it is used for lists, but that is not particularly consistent. I guess I will remove it. Maybe you should keep it to support

Re: What makes Clojure an easier Lisp?

2009-03-23 Thread Konrad Hinsen
On Mar 22, 2009, at 21:26, Joshua Fox wrote: I dove into Lisp and Scheme several times in the past, but only with Clojure did Lisp really catch? 1. Clojure abandons the 1950's cruft, with all-caps and abbreviations like SETQ and CDR. However, Scheme does this too, without achieving

Re: Mapping a function over a map's values

2009-03-23 Thread Konrad Hinsen
On Mar 23, 2009, at 16:36, Jeff Valk wrote: I prefer the into version which allows to write a mapmap that preserves the map type (eg sorted or hash): (defn mapmap [f m] (into (empty m) (for [[k v] m] [k (f v)]))) Agreed. If it were in contrib, this would make most sense. It is

Re: Information Hiding

2009-03-23 Thread Konrad Hinsen
On Mar 23, 2009, at 9:27, Mark Engelberg wrote: still be essential to the notion of equality). Any other tricks or techniques for helping to hide or separate out the portions of a data structure that are meant to be accessed or altered from the portions that should only be accessed and

Re: Information Hiding

2009-03-23 Thread Konrad Hinsen
On Mar 23, 2009, at 18:20, Mark Engelberg wrote: standard maps. I guess, loosely speaking, I was envisioning a model in which seq on a hash map would only traverse the public keys, so that library functions will work on your objects, without exposing innards. But perhaps there is no

Re: PATCH: universal parent type for Clojure hierarchies

2009-03-24 Thread Konrad Hinsen
On Mar 23, 2009, at 23:11, Meikel Brandmeyer wrote: This is not correct. defmulti may take any of Clojure's reference types containing the hierarchy. So it doesn't need to be a Var. A Ref, an Atom or an Agent are also possible. Thanks for pointing this out. Here comes a corrected patch!

Re: Generic functions again

2009-03-24 Thread Konrad Hinsen
On Mar 24, 2009, at 11:19, mikel wrote: Dispatch is wholly deterministic; you never need prefer-method. There Then what is the rule for choosing one method when there are several that match the arguments? In the scope in which a generic function is applied, next-method is always bound to

Re: simple debugging utility

2009-03-24 Thread Konrad Hinsen
On Mar 24, 2009, at 15:44, Mark Volkmann wrote: I'm wondering if there is a way to avoid that using a macro. The hard part is printing the expression. The following doesn't work. It outputs 3 = 3. (defmacro dump2 [expr] `(let [value# ~expr] (pr ~expr) (println = value#)))

Re: simple debugging utility

2009-03-24 Thread Konrad Hinsen
On Mar 24, 2009, at 16:00, Mark Volkmann wrote: Thanks! It looks like I don't need the let now. Indeed. Does a macro have to evaluate to one form? For example, this works, but it seems I can't drop the do. Yes, a macro has to evaluate to one form. This is actually not so much a

Re: oo

2009-03-25 Thread Konrad Hinsen
On 24.03.2009, at 19:29, mikel wrote: I personally like Haskell's philosophy in this area: there is a facility for defining data layouts, and there is a facility for defining protocols, and they are completely separate. You can define a I like that as well, and I have been trying to do

Re: oo

2009-03-25 Thread Konrad Hinsen
On 25.03.2009, at 10:13, Mark Engelberg wrote: 1. Structs don't inherently have a type. If you want to dispatch on type (a common use-case), you have to make a constructor that inserts the type information as part of the struct. Some have expressed And/or in the metadata. concern that it

Re: oo

2009-03-26 Thread Konrad Hinsen
On 26.03.2009, at 14:59, Rich Hickey wrote: Plus the inability to dispatch on other than class or eql, the inability to superimpose another taxonomy without redefining the class, the inability to have multiple independent taxonomies... The ability to have multiple taxonomies is indeed very

Re: oo

2009-03-27 Thread Konrad Hinsen
On Mar 27, 2009, at 9:25, Mark Engelberg wrote: I think I've answered at least part of my own question. This is the simplest ambiguous case I've found: ab | | -- | c Indeed. An ambiguous situation can occur whenever the type hierarchy graph is not a

PATCH: printing a ref with type metadata

2009-03-27 Thread Konrad Hinsen
On Mar 27, 2009, at 12:55, Konrad Hinsen wrote: I'd say yes. Here's what happens: Typing foo at the REPL causes a call to clojure.core/print-method. This is a multimethod that dispatches on the result of clojure.core/type, which is the value of the :type tag in the metadata if there is one

Re: printing a ref with type metadata

2009-03-27 Thread Konrad Hinsen
On Mar 26, 2009, at 22:44, srader wrote: When I type the following in at the REPL: (def foo (ref {} :meta {:type :t})) and then try to print it, I get the following error: java.lang.ClassCastException: clojure.lang.Ref (NO_SOURCE_FILE:0) [Thrown class

Re: oo

2009-03-29 Thread Konrad Hinsen
On 29.03.2009, at 07:25, mikel wrote: Enjoying the thread. Out of curiosity for which Clojure values is the return value of the type function undefined? Try this: (type (proxy [clojure.lang.IMeta clojure.lang.IRef][])) java.lang.UnsupportedOperationException: meta (NO_SOURCE_FILE:0)

Re: oo

2009-03-30 Thread Konrad Hinsen
On Mar 30, 2009, at 0:16, mikel wrote: Sure, that's right. Maybe constructing such a value in the first place is an error. I'd say so. If it were up to me to provide a fix for the situation you describe, I'd fix proxy to make it impossible to create an object that doesn't implement the

Re: Set bug?

2009-03-30 Thread Konrad Hinsen
On Mar 30, 2009, at 12:36, Mark Engelberg wrote: 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 codes and equality. Why does the type come into play, and is this really the desired behavior?

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

2009-03-30 Thread Konrad Hinsen
On Mar 30, 2009, at 11:57, Mark Engelberg wrote: 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

Re: Set bug?

2009-03-30 Thread Konrad Hinsen
On Mar 30, 2009, at 14:51, Rich Hickey wrote: Well, the community simply has to get together on what they want here, variously: - Clojure sets and maps should implement java.util.Set and Map Not something I care much about, though I understand those who do. - Clojure Numbers are the same

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

2009-03-31 Thread Konrad Hinsen
On Mar 31, 2009, at 16:32, Rich Hickey wrote: Here are some problems/limitations of existing OO/GF systems that I don't intend to repeat: ... I agree that these are not desirable features. I have had to work around some of them many times in the past. Traditional OO combines aspects that

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

2009-03-31 Thread Konrad Hinsen
On 31.03.2009, at 18:50, Mark Engelberg wrote: On Tue, Mar 31, 2009 at 9:45 AM, Konrad Hinsen konrad.hin...@laposte.net 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

  1   2   3   4   5   6   >