On Nov 13, 9:42 am, Sean Devlin 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 "baz docs" ([a
On Fri, Nov 13, 2009 at 8:50 PM, Mark Engelberg wrote:
> 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 a
On Fri, Nov 13, 2009 at 6:48 PM, ajuc 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 hilbert-ma
On Fri, Nov 13, 2009 at 5:16 PM, Mike Hogye 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.
It's a feature!
http
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 programming
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 :
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 messag
On Nov 13, 3:42 pm, Laurent PETIT 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 problem : doesn't the
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 wrote:
>> On Nov 12, 7:10 am,
On Nov 13, 1:01 pm, Constantine Vetoshev wrote:
> On Nov 12, 7:10 am, Rich Hickey 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 types, rather than making it
> autom
Hi,
2009/11/13 Stuart Sierra :
> On Nov 12, 7:10 am, Rich Hickey 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 nu
On Nov 12, 7:10 am, Rich Hickey 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
defprotocol. It d
On Fri, Nov 13, 2009 at 1:23 PM, Chouser wrote:
> On Wed, Nov 11, 2009 at 4:24 PM, John Harrop 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
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/). sec
On 13 Nov., 17:07, Rich Hickey 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 interface dispatch,
On Wed, Nov 11, 2009 at 4:24 PM, John Harrop 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
Clojure functions, no
I agree w/ Constantine. This would be very, very useful.
Sean
On Nov 13, 1:01 pm, Constantine Vetoshev wrote:
> On Nov 12, 7:10 am, Rich Hickey wrote:
>
> > [1]http://www.assembla.com/wiki/show/clojure/Datatypes
>
> Could you please elaborate on why you chose to make IPersistentMap an
> option
On 13.11.2009, at 17:11, Rich Hickey wrote:
> On Nov 13, 10:42 am, Sean Devlin 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 & c])
On Nov 12, 7:10 am, Rich Hickey 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 types, rather than making it
automatic?
I'm asking because I found the automatic defstruct-map eq
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 beh
On Nov 13, 9:24 am, James Reeves 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.
>
> (defn sql-get [table ke
Hi Mark,
2009/11/13 Mark Tomko :
>
> 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 value of prev
Is there an argument for putting it after the argument list? :)
On Fri, Nov 13, 2009 at 11:11 AM, Rich Hickey wrote:
>
>
> On Nov 13, 10:42 am, Sean Devlin wrote:
> > Rich,
> > I was wondering something about defprotocol.
> >
> > Here's your example:
> >
> > (defprotocol AProtocol :on AnInterfa
I place my vote for no data hiding.
On Fri, Nov 13, 2009 at 10:48 AM, Stuart Halloway wrote:
> >> But do
> >> people feel that some degree of data hiding is worthwhile?
> >
> > I don't.
>
>
> Hooray for benevolent dictators!
>
> --
> You received this message because you are subscribed to the G
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 imp
On Nov 13, 10:48 am, Stuart Halloway
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 Google
Groups "Clo
On Nov 13, 9:26 am, AlexK 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 multifns and protocolfns:
>
...
> This is what I
On Nov 13, 10:42 am, Sean Devlin 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 & c]) "baz docs"))
>
>
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 op
>> But do
>> people feel that some degree of data hiding is worthwhile?
>
> I don't.
Hooray for benevolent dictators!
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from
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 & c]) "baz docs"))
In this case, you provide the docs for each method after para
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
On Nov 13, 9:03 am, MikeM 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 notice that (extend
On Nov 13, 4:55 am, Alex Osborne 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 p
On Nov 13, 5:27 am, Chris Kent wrote:
> Mark Engelberg 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
> >
On Nov 13, 3:58 am, Konrad Hinsen 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 be an important
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, 2:13 am, Mark Engelberg 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 the strong overla
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.
(defn sql-get [table key]
(sql-query
(str "select * from " table " wher
> (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
On Nov 13, 7:35 am, Ross Thomas wrote:
> (ns seq-server
> #^{:author "Ross Thomas "}
> (:import (java.net ServerSocket)))
The metadata should come before the symbol it's applied to, i.e.
(ns #^{:author "Ross Thomas "}
seq-server
(:import java.net.ServerSocket))
Putting the metadata firs
On Fri, Nov 13, 2009 at 2:13 AM, Krukow wrote:
>
>
> On Nov 12, 1:10 pm, Rich Hickey wrote:
>> An early version of the code for a few important new language
>> features, datatypes[1] and protocols[2] is now available in the 'new'
>> branch[3]. Note also that the build system[4] has builds of 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 ser
Hi,
On Nov 13, 8:13 am, Mark Engelberg 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 time to discuss what kin
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
Mark Engelberg 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 I think that
On Nov 13, 9:13 am, Krukow 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 dot because the sp
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
> impleme
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 M
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] ...)
> Wh
It's a pet peeve of mine but, please, try hard not to use indices :-)
(or if you need indices pick a better suited data structure)
The code you try to write is hard to write because you are going
against the grain.
If you try to write swap for vectors (which support efficient random
lookup and ass
51 matches
Mail list logo