On 13 Nov 2009, at 08:13, Mark Engelberg wrote:
Is there a way to customize the way that types defined by deftype
print in the REPL?
Implement the multimethod clojure.core/print-method for the associated
type tag:
(deftype Foo ...)
(defmethod clojure.core/print-method ::Foo [x] ...)
With clojure-in-clojure on the horizon (if not around the corner) I wonder if
an imports clause would be appropriate, and solve some of the complexities
of discerning between clojure and java/clr/javascript/objectivec/(go?)
(ns foo
(uses clojure.contrib.repl-utils)
(imports java.util [List
Mark Engelberg wrote:
Protocols:
I don't understand whether there's any way to provide a partial
implementation or default implementation of a given
protocol/interface, and I believe this to be an important issue.
For example, a protocol for and that provides a default
implementation
On Nov 13, 9:13 am, Krukow karl.kru...@gmail.com wrote:
I was thinking this may make syntax irregular. I suspect this is a
deliberate design choice to distinguish clojure protocols from java
interfaces? Is this the case?
As far as I understand it, in defprotocol's case, I suspect there is
no
Mark Engelberg mark.engelberg at gmail.com writes:
I'm a little worried about the strong overlap between reify/proxy,
deftype/defstruct, and defclass/gen-class. I can just imagine the
questions a year from now when people join the Clojure community and
want to understand how they differ. So
Hello group,
First I'd like to thank Rich for such a great new tool. The assertion
in Programming Clojure that it feels like a general-purpose language
beamed back from the near future really sums things up very nicely.
Homoiconicity + FP + STM + JVM = epic win.
Anyway, thought I'd say hi, and
Hi,
On Nov 13, 8:13 am, Mark Engelberg mark.engelb...@gmail.com wrote:
Is there a way to customize the way that types defined by deftype
print in the REPL?
One can add a method to print-method for the type.
While these datatype and protocol constructs are taking shape, maybe
now is the
Hello,
and welcome on board ! :-)
One general remark : too much things done at the top level.
It's ok to define some globals such as (def listen-port 8555)
but having this
(def server-sock (ServerSocket. listen-port))
will raise the problem that as soon as you 'require your namespace,
the
On Nov 13, 7:35 am, Ross Thomas halfacan...@gmail.com wrote:
(ns seq-server
#^{:author Ross Thomas halfacan...@gmail.com}
(:import (java.net ServerSocket)))
The metadata should come before the symbol it's applied to, i.e.
(ns #^{:author Ross Thomas halfacan...@gmail.com}
seq-server
(deftype Foo [a b c])
(defprotocol P (bar [x] bar docs))
(extend ::Foo P {:bar (fn [afoo] :foo-thing)})
A common error may be to:
(extend Foo P {:bar (fn [afoo] :foo-thing)})
when (extend ::Foo ... is intended. I notice that (extend Foo...
doesn't throw - should extend check that it is
On Nov 13, 2:13 am, Mark Engelberg mark.engelb...@gmail.com wrote:
I'm still trying to get my head around the new features. Seeing more
code examples will definitely help. In the meantime, here is some
stream-of-consciousness thoughts and questions.
Datatypes:
I'm a little worried about
Hi everybody,
after playing around with protocols datatypes, I found them very fun
to use.
Some questions:
Performance
I don't see (with my limited benchmarking) any significant difference
between multifns and protocolfns:
user= (defprotocol Test (protocol-fn [it] Protocol-fn))
Test
user=
On Nov 13, 3:58 am, Konrad Hinsen konrad.hin...@fastmail.net wrote:
On 13 Nov 2009, at 08:13, Mark Engelberg wrote:
Protocols:
I don't understand whether there's any way to provide a partial
implementation or default implementation of a given
protocol/interface, and I believe this to
On Nov 13, 9:03 am, MikeM michael.messini...@invista.com wrote:
(deftype Foo [a b c])
(defprotocol P (bar [x] bar docs))
(extend ::Foo P {:bar (fn [afoo] :foo-thing)})
A common error may be to:
(extend Foo P {:bar (fn [afoo] :foo-thing)})
when (extend ::Foo ... is intended. I
On Nov 13, 4:55 am, Alex Osborne a...@meshy.org wrote:
Mark Engelberg wrote:
Protocols:
I don't understand whether there's any way to provide a partial
implementation or default implementation of a given
protocol/interface, and I believe this to be an important issue.
For example, a
On Nov 13, 5:27 am, Chris Kent cjk...@gmail.com wrote:
Mark Engelberg mark.engelberg at gmail.com writes:
I'm a little worried about the strong overlap between reify/proxy,
deftype/defstruct, and defclass/gen-class. I can just imagine the
questions a year from now when people join the
Heh, I was writing some networking stuff yesterday too. Small world.
I'd make one change. Add (:use clojure.contrib.duck-streams) to your
namespace definition. Then you can change handle-client to this
(defn handle-client [_ client]
(spit (.getOutputStream client) message)
(doto client
Rich,
I was wondering something about defprotocol.
Here's your example:
(defprotocol AProtocol :on AnInterface
A doc string for AProtocol abstraction
(bar [a b] bar docs :on barMethod)
(baz ([a] [a b] [a b amp; c]) baz docs))
In this case, you provide the docs for each method after
Yeah, and this code has the side effect of working on maps
user=(swap [:a :b :c :d] 0 2)
[:c :b :a :d]
user=(swap {:a 1 :b 2 :c 3 :d 4} :a :c)
{:a 3, :b 2, :c 1, :d 4}
Hmmm... is this worth keeping? Maybe use the name switch instead, to
avoid confusion with swap! (the atom operation).
On Nov 13, 10:42 am, Sean Devlin francoisdev...@gmail.com wrote:
Rich,
I was wondering something about defprotocol.
Here's your example:
(defprotocol AProtocol :on AnInterface
A doc string for AProtocol abstraction
(bar [a b] bar docs :on barMethod)
(baz ([a] [a b] [a b amp; c])
On Nov 13, 9:26 am, AlexK alexander.konstanti...@informatik.haw-
hamburg.de wrote:
Hi everybody,
after playing around with protocols datatypes, I found them very fun
to use.
Some questions:
Performance
I don't see (with my limited benchmarking) any significant difference
between
On Nov 13, 10:48 am, Stuart Halloway stuart.hallo...@gmail.com
wrote:
But do
people feel that some degree of data hiding is worthwhile?
I don't.
Hooray for benevolent dictators!
I was just putting in my vote :)
Rich
--
You received this message because you are subscribed to the
Indeed it does. I still think the array implementation of a heap is
probably worth using, in spite of its use of indexes, but rather than
use a generalized swap implementation to percolate elements up and
down the tree, I'll stick with a vector implementation and keep it all
hidden beneath the
Is there an argument for putting it after the argument list? :)
On Fri, Nov 13, 2009 at 11:11 AM, Rich Hickey richhic...@gmail.com wrote:
On Nov 13, 10:42 am, Sean Devlin francoisdev...@gmail.com wrote:
Rich,
I was wondering something about defprotocol.
Here's your example:
Hi Mark,
2009/11/13 Mark Tomko mjt0...@gmail.com:
I notice you used the '-' macro. Perhaps I'm a little dense, but I
haven't found the documentation for it to be terribly helpful. Do you
have simple, succinct explanation for what it does?
The - macro calls the given forms with the return
On Nov 13, 9:24 am, James Reeves weavejes...@googlemail.com wrote:
Are there any plans to use protocols to define polymorphic functions
like conj and get? Perhaps with an untype function to remove type
metadata so one could always get at the datastructures hidden by the
protocol. e.g.
On 13.11.2009, at 17:07, Rich Hickey wrote:
Admittedly, it is a difference from multimethods. With protocols, both
protocols and their functions/methods are immutable. Redefining or
extending a protocol modifies only the protocol and fn vars. I prefer
that, and don't consider the above
On 13.11.2009, at 17:11, Rich Hickey wrote:
On Nov 13, 10:42 am, Sean Devlin francoisdev...@gmail.com wrote:
Would the following be possible:
(defprotocol AProtocol :on AnInterface
A doc string for AProtocol abstraction
(bar bar docs [a b] :on barMethod)
(baz baz docs ([a] [a b] [a b
I agree w/ Constantine. This would be very, very useful.
Sean
On Nov 13, 1:01 pm, Constantine Vetoshev gepar...@gmail.com wrote:
On Nov 12, 7:10 am, Rich Hickey richhic...@gmail.com wrote:
[1]http://www.assembla.com/wiki/show/clojure/Datatypes
Could you please elaborate on why you chose
On Wed, Nov 11, 2009 at 4:24 PM, John Harrop jharrop...@gmail.com wrote:
One question: how would Java class imports be dealt with? I think it should
be unified:
(ns foo
(uses java.io :only [File FileInputStream] :as io))
I think this is a bad idea. Java (or other host) classes are not
On 13 Nov., 17:07, Rich Hickey richhic...@gmail.com wrote:
This kind of do-nothing microbenchmarking demonstrates nothing.
Protocol dispatching is significantly faster than multimethod
dispatching, and I haven't even looked into call-site optimization.
Protocol dispatch is not as fast as
That works, but I don't think it's satisfactory. first and second
aren't the intended functions to access a map entry's keys and vals—
but most importantly, it's been documented that second is very, very
slow compared to val (http://w01fe.com/blog/2009/01/more-on-clojure-
map-accessor-speeds/).
On Fri, Nov 13, 2009 at 1:23 PM, Chouser chou...@gmail.com wrote:
On Wed, Nov 11, 2009 at 4:24 PM, John Harrop jharrop...@gmail.com wrote:
One question: how would Java class imports be dealt with? I think it
should
be unified:
(ns foo
(uses java.io :only [File FileInputStream] :as
On Nov 12, 7:10 am, Rich Hickey richhic...@gmail.com wrote:
An early version of the code for a few important new language
features, datatypes[1] and protocols[2]
Very simple example here: http://paste.lisp.org/display/90329
This shows how to do arithmetic with complex numbers using deftype and
Hi,
2009/11/13 Stuart Sierra the.stuart.sie...@gmail.com:
On Nov 12, 7:10 am, Rich Hickey richhic...@gmail.com wrote:
An early version of the code for a few important new language
features, datatypes[1] and protocols[2]
Very simple example here: http://paste.lisp.org/display/90329
This
On Nov 13, 1:01 pm, Constantine Vetoshev gepar...@gmail.com wrote:
On Nov 12, 7:10 am, Rich Hickey richhic...@gmail.com wrote:
[1]http://www.assembla.com/wiki/show/clojure/Datatypes
Could you please elaborate on why you chose to make IPersistentMap an
optional interface for deftype'd
Initial gut reaction: would like a shortcut syntax for opting in(or
out), as this will be a very common use case. Suspect that most
classes would rather have it than not, but that may be the Ruby
programmer in me.
Stu
On Nov 13, 1:01 pm, Constantine Vetoshev gepar...@gmail.com wrote:
On
On Nov 13, 3:42 pm, Laurent PETIT laurent.pe...@gmail.com wrote:
Very simple example here:http://paste.lisp.org/display/90329
Why not have used add/sub/... instead of +/-/... in the extension of
Arithmetic for ::Complex ? :-p
Just a little simpler, that's all.
This example has maybe a
Using with-command-line from clojure.contrib.command-line, if the list
of command-line args is empty or nil, the usage message is printed
(and the nested code is not run), even if all the options have default
values.
The following (note that the first arg is the empty list) prints the
usage
Hello.
I've tried to translate nice Hilbert-curve-index calculating function
to clojure (http://blog.notdot.net/2009/11/Damn-Cool-Algorithms-
Spatial-indexing-with-Quadtrees-and-Hilbert-Curves).
I've got sth like that:
(def hilbert-map {
:a {[0 0] [0 :d], [0 1] [1 :a], [1 0] [3 :b], [1 1] [2
Rich, thanks for the extended explanation of the overlap between the
old and new constructs; I found this explanation much clearer than
what is currently on the wiki. Basically, the key for me was
realizing that these new constructs are all you're likely to need as
long as you are just
On Fri, Nov 13, 2009 at 5:16 PM, Mike Hogye stacktra...@gmail.com wrote:
Using with-command-line from clojure.contrib.command-line, if the list
of command-line args is empty or nil, the usage message is printed
(and the nested code is not run), even if all the options have default
values.
On Fri, Nov 13, 2009 at 6:48 PM, ajuc aju...@gmail.com wrote:
Hello.
I've tried to translate nice Hilbert-curve-index calculating function
to clojure (http://blog.notdot.net/2009/11/Damn-Cool-Algorithms-
Spatial-indexing-with-Quadtrees-and-Hilbert-Curves).
I've got sth like that:
(def
On Fri, Nov 13, 2009 at 8:50 PM, Mark Engelberg mark.engelb...@gmail.comwrote:
Rich, thanks for the extended explanation of the overlap between the
old and new constructs; I found this explanation much clearer than
what is currently on the wiki. Basically, the key for me was
realizing that
On Nov 13, 9:42 am, Sean Devlin francoisdev...@gmail.com wrote:
In this case, you provide the docs for each method after parameters.
Would the following be possible:
(defprotocol AProtocol :on AnInterface
A doc string for AProtocol abstraction
(bar bar docs [a b] :on barMethod)
(baz
45 matches
Mail list logo