Re: Some questions about Clojure Protocols

2010-11-04 Thread Meikel Brandmeyer
Hi,

On 4 Nov., 04:58, ka sancha...@gmail.com wrote:

 (defprotocol OnlyHalfCooless x y z)

 Instead of
 (defn is-this-cool? [o] (satisfies? Coolness o))

 I need to now write:
 (defn is-this-cool? [o] (or (instance? Cool1 o) (instance? Cool2 o))
 or, (even worse)
 (defn is-this-cool? [o] (and (satisfies? OnlyHalfCoolness o)
 (instance? Comparable o) (instance? Serializable o))

May I ask a heretic question: Why don't you specify the contract in
the docstring of the protocol?

(defprotocol Coolness
  Yadddayaddablablablubber.
  Cool things have to be Comparable and Serializable.
  (x ..)
  (y ...))

If someone doesn't adhere to this contract, it's his program which is
broken, not yours.

Sincerely
Meikel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


A bug? Unbound Unbound in 1.3-alpha2 when a symbol is not set

2010-11-04 Thread Jacek Laskowski
Hi,

Is it intended in 1.3-alpha2? I think the error message in 1.2 is way
better (although not as user friendly as I wish to). Shall I report
it? Where? How?

devmac:~ jacek$ clj -13
CLOJURE_DIR:  /Users/jacek/apps/clojure
CLOJURE_CONTRIB_JAR:  /Users/jacek/apps/clojure-contrib-1.3.0-alpha2.jar
Clojure 1.3.0-alpha2
user= (def c)
#'user/c
user= c
#Unbound Unbound: #'user/c

devmac:~ jacek$ clj
CLOJURE_DIR:  /Users/jacek/apps/clojure-1.2.0
CLOJURE_CONTRIB_JAR:
/Users/jacek/apps/clojure-contrib/target/clojure-contrib-1.2.0.jar
Clojure 1.2.0
user= (def c)
#'user/c
user= c
java.lang.IllegalStateException: Var user/c is unbound. (NO_SOURCE_FILE:0)

Jacek

-- 
Jacek Laskowski
Notatnik Projektanta Java EE - http://jaceklaskowski.pl

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Supporting 1.2 and 1.3

2010-11-04 Thread Saul Hazledine
Hello,
  I've put some small libraries on github. At the moment they
specifically depend on Clojure 1.2 and contrib (since its the released
version). However, I have had requests to take out the dependencies on
clojure and contrib so that they don't infect projects that use them.
Is this standard practice? Would it catch people out?

I thought about alternative approaches but have no solution. For
instance, in Leiningen, it is possible to specify a minimal version
e.g
[org.clojure/clojure-contrib [1.2,)]

This would normally be fine but in 1.3 the dependency on contrib
changes:

[org.clojure.contrib/standalone 1.3.0-alpha2]

Has anyone hit this problem? What is the best way of dealing with it?

Thanks in advance for any help.
Saul

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Some questions about Clojure Protocols

2010-11-04 Thread nicolas.o...@gmail.com
I see your point.
Somehow, it is annoying to have to manipulate a set of protocols that
always go together.
And it would be nice to have a shorthand.

I have a very small prototype here:

git://nicolasoury.repositoryhosting.com/nicolasoury/type-classes.git

of some code to allow type-classes like deductions of protocols (ie
logical programming with protocols).

It is not really working, tested, maintained or nice currently.
(It was just a quick proof of concept)

The idea is to write a rule:

Serializable, Comparable, HalfCool = Cool  {implemenation of
functions that are not in the pre-condition}

Typically if you roll you own Eq protocol with eq,

Comparable = Eq {:eq (fn [x y] (compare x y)}

Then, for each protocol accessible on a right handside of a rule, it
extends Object with that protocol.

This default implementation try to apply all rules, in order to deduce
an implementation.
If it deduces an implementation, it extends the protocol with that
implementation, for the type of the argument.
(That way there is a derivation of implementation only on the first call)

The implementation is very bad (and not maintained) and I wouldn't
advise using it, but the idea can be useful sometimes.

Especially, it shows that the access you have to protocols at the
programmatic level, might help to solve the kind of problems you have.
(this kind of deduction are a bit of an overkill for the problem at hand)

I don't know if there is a similar programmatic  access to deftype. I
would like to know of it if there is.

Best,

Nicolas.

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Some questions about Clojure Protocols

2010-11-04 Thread Shantanu Kumar
For complex cases, you may like to fall back on multi-methods and
abstraction types. I blogged about typed abstractions few days ago
here:

http://bitumenframework.blogspot.com/2010/10/typed-abstractions-in-clojure.html

Regards,
Shantanu

On Nov 4, 1:25 pm, nicolas.o...@gmail.com nicolas.o...@gmail.com
wrote:
 I see your point.
 Somehow, it is annoying to have to manipulate a set of protocols that
 always go together.
 And it would be nice to have a shorthand.

 I have a very small prototype here:

 git://nicolasoury.repositoryhosting.com/nicolasoury/type-classes.git

 of some code to allow type-classes like deductions of protocols (ie
 logical programming with protocols).

 It is not really working, tested, maintained or nice currently.
 (It was just a quick proof of concept)

 The idea is to write a rule:

 Serializable, Comparable, HalfCool = Cool  {implemenation of
 functions that are not in the pre-condition}

 Typically if you roll you own Eq protocol with eq,

 Comparable = Eq {:eq (fn [x y] (compare x y)}

 Then, for each protocol accessible on a right handside of a rule, it
 extends Object with that protocol.

 This default implementation try to apply all rules, in order to deduce
 an implementation.
 If it deduces an implementation, it extends the protocol with that
 implementation, for the type of the argument.
 (That way there is a derivation of implementation only on the first call)

 The implementation is very bad (and not maintained) and I wouldn't
 advise using it, but the idea can be useful sometimes.

 Especially, it shows that the access you have to protocols at the
 programmatic level, might help to solve the kind of problems you have.
 (this kind of deduction are a bit of an overkill for the problem at hand)

 I don't know if there is a similar programmatic  access to deftype. I
 would like to know of it if there is.

 Best,

 Nicolas.

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure-backtracking-monads .. can it emulate prolog?

2010-11-04 Thread Sunil S Nandihalli
Thanks David.
I am reading it .. it has nice description of mini-kanren.
I was wondering if there is predicate corresponding to prologs nonvar in
mini-kanren.
Sunil.

On Wed, Nov 3, 2010 at 10:13 PM, David Nolen dnolen.li...@gmail.com wrote:

 On Wed, Nov 3, 2010 at 12:38 PM, David Nolen dnolen.li...@gmail.comwrote:

 On Wed, Nov 3, 2010 at 11:53 AM, Sunil S Nandihalli 
 sunil.nandiha...@gmail.com wrote:

 thanks Jim for your email. I will try to get my hands on Reasoned
 Schemer.. :)
 Sunil.


 William Byrd's dissertation, http://gradworks.umi.com/33/80/3380156.htmlis a 
 great source for context, additional info, prior research, papers, etc.

  --
 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 new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en


-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Supporting 1.2 and 1.3

2010-11-04 Thread Shantanu Kumar
Ring has a 1.3 branch to deal with the new version, for example. Maybe
that's one solution.

Regards,
Shantanu

On Nov 4, 12:44 pm, Saul Hazledine shaz...@gmail.com wrote:
 Hello,
   I've put some small libraries on github. At the moment they
 specifically depend on Clojure 1.2 and contrib (since its the released
 version). However, I have had requests to take out the dependencies on
 clojure and contrib so that they don't infect projects that use them.
 Is this standard practice? Would it catch people out?

 I thought about alternative approaches but have no solution. For
 instance, in Leiningen, it is possible to specify a minimal version
 e.g
 [org.clojure/clojure-contrib [1.2,)]

 This would normally be fine but in 1.3 the dependency on contrib
 changes:

 [org.clojure.contrib/standalone 1.3.0-alpha2]

 Has anyone hit this problem? What is the best way of dealing with it?

 Thanks in advance for any help.
 Saul

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Bug with instance? inside deftypes

2010-11-04 Thread Christophe Grand
To me its an implementation wart which is dictated by the use of the
reflection API in the compiler.
There is some work done by Stu to create a clojure reflection API with
several backends (eg ASM or Java Reflection).
However I won't bet on the *current* compiler being fixed.

my 2 cents

Christophe

On Thu, Nov 4, 2010 at 4:09 AM, ka sancha...@gmail.com wrote:

  I would guess the problem is referring to T inside the deftype.

 This also works:

 (deftype T [] Object (equals [this o] (if (= T (class o)) true
 false)))

 But as Meikel said hope that this is not the end of the story.

 --
 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 new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en




-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (en)

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: A bug? Unbound Unbound in 1.3-alpha2 when a symbol is not set

2010-11-04 Thread Ken Wesson
On Thu, Nov 4, 2010 at 3:41 AM, Jacek Laskowski ja...@laskowski.net.pl wrote:
 Hi,

 Is it intended in 1.3-alpha2? I think the error message in 1.2 is way
 better (although not as user friendly as I wish to). Shall I report
 it? Where? How?

 devmac:~ jacek$ clj -13
 CLOJURE_DIR:  /Users/jacek/apps/clojure
 CLOJURE_CONTRIB_JAR:  /Users/jacek/apps/clojure-contrib-1.3.0-alpha2.jar
 Clojure 1.3.0-alpha2
 user= (def c)
 #'user/c
 user= c
 #Unbound Unbound: #'user/c

 devmac:~ jacek$ clj
 CLOJURE_DIR:  /Users/jacek/apps/clojure-1.2.0
 CLOJURE_CONTRIB_JAR:
 /Users/jacek/apps/clojure-contrib/target/clojure-contrib-1.2.0.jar
 Clojure 1.2.0
 user= (def c)
 #'user/c
 user= c
 java.lang.IllegalStateException: Var user/c is unbound. (NO_SOURCE_FILE:0)

Looks like an attempt to make commonplace compile error messages less
verbose, to me.

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: clojure-backtracking-monads .. can it emulate prolog?

2010-11-04 Thread David Nolen
On Thu, Nov 4, 2010 at 6:16 AM, Sunil S Nandihalli 
sunil.nandiha...@gmail.com wrote:

 Thanks David.
 I am reading it .. it has nice description of mini-kanren.
 I was wondering if there is predicate corresponding to prologs nonvar in
 mini-kanren.
 Sunil.


Again, I don't know enough about Prolog, but isn't this considered one of
Prolog's non-logical operators? I think miniKaren attempts to avoid them.

David

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Some questions about Clojure Protocols

2010-11-04 Thread Paul Hobbs
Meikel,

Strong type systems make programming in the large easier.  It would be nice
if I didn't have to walk on eggshells when using a library.  Written
agreements are also known as gotchas.

--
Paul Hobbs


On Wed, Nov 3, 2010 at 11:30 PM, Meikel Brandmeyer m...@kotka.de wrote:

 Hi,

 On 4 Nov., 04:58, ka sancha...@gmail.com wrote:

  (defprotocol OnlyHalfCooless x y z)
 
  Instead of
  (defn is-this-cool? [o] (satisfies? Coolness o))
 
  I need to now write:
  (defn is-this-cool? [o] (or (instance? Cool1 o) (instance? Cool2 o))
  or, (even worse)
  (defn is-this-cool? [o] (and (satisfies? OnlyHalfCoolness o)
  (instance? Comparable o) (instance? Serializable o))

 May I ask a heretic question: Why don't you specify the contract in
 the docstring of the protocol?

 (defprotocol Coolness
  Yadddayaddablablablubber.
  Cool things have to be Comparable and Serializable.
  (x ..)
  (y ...))

 If someone doesn't adhere to this contract, it's his program which is
 broken, not yours.

 Sincerely
 Meikel

 --
 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 new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en


-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Some questions about Clojure Protocols

2010-11-04 Thread Laurent PETIT
Well,

I'm not totally sure about what I'll write below, but I'll still try
to make a decent job of sharing my current thoughts:

  * first, when I see calls to (instance?) (satisifies?), it rings a
bell in my head. design problem.
  * second, it seems like you're trying to fix in the concrete
something which may not have to. Having coolness be a static
property of implementing this and that protocol seems very fixed.
Beware the fixed hierarchies in java when you then have hard times
getting orthogonal code (given that java has no implementation
multiple inheritence, for example). But maybe it's just the example
(or even me not totally understanding the example).
  * third: looks like a protocol abuse. I have the impression that the
current trend is to see protocols as fine-grained extension points
of generic algorithms. Which implies that the public API is not
protocol functions, but those regular functions to which you pass
objects which happen to be extended to some protocols (with you the
consumer being aware of it or not).

So a library implementer has designed some interesting generic
functions. He organizes the way these generic functions deal with
different types of input by creating protocols and calling protocol
functions on the inputs, and extends those protocols to the most
relevant kinds of input types (for him). He then decides to make the
protocols part of his public API to let you, the user, have the
ability to benefit from the generic functions for your own specific
kinds of types.
In this scheme, the goal is less extending the protocol for the sake
of it than extending the protocol to be able to leverage existing
functions *using* the protocols to one's particular kind of
types/records.

If the design of your application requires the use of protocols at
all, which should generally not be an implicit assumption, IMHO.

2010/11/4 ka sancha...@gmail.com:
 AFAIK, it is not possible. You must implement all the different protocols.
 It might look desapointing, but on the other hand it is not necessary.
 (As there is no static typing in Clojure)
 What is your use-case?

 Current use case is that I want an abstraction which comprises of a
 set of operations I want + Comparable + Serializable

 Just define types that extend all the protocols.
 You can't. But you can define a type that extends both P and Comparable.

 Currently I'm struggling with the following problem - Suppose I
 consider something satisfying 'Coolness' property if it does x, y, z +
 is comparable + serializes.

 To do this I create a protocol 'OnlyHalfCoolness':
 (defprotocol OnlyHalfCooless x y z)

 and two deftypes Cool1, Cool2:
 (deftype Cool1 ... OnlyHalfCoolness .. Comparable .. Serializable)
 (deftype Cool2 ... OnlyHalfCoolness .. Comparable .. Serializable)

 Now I need to write a function: is-this-cool?

 Instead of
 (defn is-this-cool? [o] (satisfies? Coolness o))

 I need to now write:
 (defn is-this-cool? [o] (or (instance? Cool1 o) (instance? Cool2 o))
 or, (even worse)
 (defn is-this-cool? [o] (and (satisfies? OnlyHalfCoolness o)
 (instance? Comparable o) (instance? Serializable o))

 A type hierarchy is not required - but I think a way to compose
 (atleast union) abstractions would be nice.

 Are there some fundamental problems with - (defprotocol Coolness ..
 Comparable .. Serializable .. x y z) ?

 What do you mean by static functions?

 Normal functions which do not dispatch based on the type of their
 first argument. Forget about this - thinking more about it - they
 don't really make too much sense in protocols.


 --
 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 new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Some questions about Clojure Protocols

2010-11-04 Thread Mike Meyer
On Thu, 4 Nov 2010 00:50:35 -0700
Paul Hobbs paul_ho...@hmc.edu wrote:

 Strong type systems make programming in the large easier. 


Paul,

Strong typing has so many definitions that your statement is nearly
meaningless. See http://www.wordiq.com/definition/Strong_typing for a
few.

Now, if you have some prove that's not just anecdotal, I'd be
interested in hearing. Likewise if someone has prove of the contrary.

   Thanks,
   mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Some questions about Clojure Protocols

2010-11-04 Thread Meikel Brandmeyer
Hi,

On 4 Nov., 08:50, Paul Hobbs paul_ho...@hmc.edu wrote:

 Strong type systems make programming in the large easier.  It would be nice
 if I didn't have to walk on eggshells when using a library.  Written
 agreements are also known as gotchas.

I'm not sure what you mean with strong type systems. Clojure's type
system is dynamic. That means if I call seq on a thing I better make
sure that I have an actually seqable thing. Otherwise I get a
RuntimeException during runtime of my program. How is that different
to a protocol function implementation trying to compare two things? If
at least one doesn't implement Comparable you'll get a runtime
exception. I take it you expect static typing.

That said, I sense a lot of object-oriented thinking in how protocols
are seen in the moment. From my point of view, a honest definition of
a type or record is:

(defrecord Abc [a b c])

(extend-protocol Xyz
  Abc
  (x [this] ...)
  ...)

The record has nothing to do with the protocol. The record is a
collection of data with a special name representing a value of some
special sort. A protocol comprises functions which act on data in a
certain abstract way. How this works for different types of data is
defined by extending the protocol to the type (and not vice versa;
extend-type is a suboptimal way to carry this meaning). That you
specify these implementation inline with the type definition is a way
to improve performance. But I would even call it pre-mature
optimisation in a philosophical way. At the moment I see protocols
just as functions acting on data as any other normal function does
also.

But I'm not sure I understand the philosophy of protocols myself. Some
the above may be totally off track. YMMV.

Sincerely
Meikel

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: A bug? Unbound Unbound in 1.3-alpha2 when a symbol is not set

2010-11-04 Thread lprefontaine
Rich at the Conj explained that he wanted to remove a bunch of 
verifications each time a value was referenced to gain some speed.
The basis was of his reasoning was that an unbound
value is an exception more than a common thing and all these verifications at 
run time were really slowing things significantly for all applications.

I recalls that he mentioned he needed to create the unbound value to achieve
these optimizations.

Luc P.

Ken Wesson kwess...@gmail.com wrote ..
 On Thu, Nov 4, 2010 at 3:41 AM, Jacek Laskowski ja...@laskowski.net.pl 
 wrote:
  Hi,
 
  Is it intended in 1.3-alpha2? I think the error message in 1.2 is way
  better (although not as user friendly as I wish to). Shall I report
  it? Where? How?
 
  devmac:~ jacek$ clj -13
  CLOJURE_DIR:  /Users/jacek/apps/clojure
  CLOJURE_CONTRIB_JAR:  /Users/jacek/apps/clojure-contrib-1.3.0-alpha2.jar
  Clojure 1.3.0-alpha2
  user= (def c)
  #'user/c
  user= c
  #Unbound Unbound: #'user/c
 
  devmac:~ jacek$ clj
  CLOJURE_DIR:  /Users/jacek/apps/clojure-1.2.0
  CLOJURE_CONTRIB_JAR:
  /Users/jacek/apps/clojure-contrib/target/clojure-contrib-1.2.0.jar
  Clojure 1.2.0
  user= (def c)
  #'user/c
  user= c
  java.lang.IllegalStateException: Var user/c is unbound. (NO_SOURCE_FILE:0)
 
 Looks like an attempt to make commonplace compile error messages less
 verbose, to me.
 
 -- 
 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 new members are moderated - please be patient with your 
 first
 post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Resources on optimizing Clojure code

2010-11-04 Thread cej38
It is wonderful that people are so willing to help with a specific
problem, and I encourage you to continue doing so, but I don't think
anyone has answered the real question.  Is there material out there
that describes some of the mechanisms, tools, ideas, etc. that will
allow the average clojure user to optimize their code.  Yes, Yes, a
good implementation is key, but you need to know the best practices in
order to develop that implementation.

Not that I have done this myself (yet!) but there are some that argue
that reimplementing certain time critical components as macros will
greatly speed up the code.  See the link below:
http://www.bestinclass.dk/index.clj/2010/03/functional-fluid-dynamics-in-clojure.html

Optimization is a topic that I would like to see more on.






On Nov 2, 1:32 pm, Dan Kefford dan_keff...@hotmail.com wrote:
 Hello fellow clojurians...

 I've been using Clojure now fairly regularly for the past two months
 solving problems on Project Euler. I've been fairly successful solving
 them but there are times where the performance of my code either
 stinks (the answer may come back in 5-10 minutes) or not at all even
 though I have effectively solved the problem (the code is correct and
 will return the answer for n  1000 but for n  10^8... forget about
 it.)

 My question is: are there any materials out there on how to optimize
 performance of Clojure code? There doesn't seem to be a lot out there.

 Thanks in advance,

 dan kefford

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Is this bug in Google AppEngine, appengine-clj or Clojure itself?

2010-11-04 Thread Miki
FYI: 0.4.1-SNAPSHOT has this fix

On Nov 3, 11:07 am, Miki miki.teb...@gmail.com wrote:
 Does anybody know if this fix made it to the released jar?

 On Oct 17, 12:18 am, Mike Hinchey hinche...@gmail.com wrote:

  I think it is caused by those 2 clojure bugs (which seem to be the same
  thing).  You may be able to work around that problem by patching
  appengine-clj to hint the method call to be on the public interface:
  DatastoreService.

  (defn current-transaction
    Returns the current datastore transaction, or nil if not within a
  transaction. [] (.getCurrentTransaction
  ^com.google.appengine.api.datastore.DatastoreService
  (datastore) nil))

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Documentation lacking for ns macro

2010-11-04 Thread Ken Wesson
The ns macro seems to be poorly documented as yet. The Namespaces page
at the main Clojure site does not go into detail about its syntax;
doc ns comes closer, with:

  (ns foo.bar
(:refer-clojure :exclude [ancestors printf])
(:require (clojure.contrib sql sql.tests))
(:use (my.lib this that))
(:import (java.util Date Timer Random)
 (java.sql Connection Statement)))

given as an example. But what exactly, for instance, is the use clause
really supposed to look like? Is that a list of libraries starting
with my.lib, for example, or is it a single lib and a list of symbols?
The accompanying text only suggests looking at the use function's
documentation. But using doc use gives:

clojure.core/use
([ args])
  Like 'require, but also refers to each lib's namespace using
  clojure.core/refer. Use :use in the ns macro in preference to calling
  this directly.

  'use accepts additional options in libspecs: :exclude, :only, :rename.
  The arguments and semantics for :exclude, :only, and :rename are the same
  as those documented for clojure.core/refer.

Yeah, that's a real help if you're trying to remember the syntax. 
args. How specific. :)

I think this is one area that could definitely use improvement,
including a couple of actual examples of usage on the Namespaces page
and a better description of the arglist for the use function (and
ditto require) as well as a better :use example in doc ns. The model
here should be the example :import clause above, which is perfect --
it's clear that it should be followed by lists that start with a
package and continue with classnames from that package. By contrast,
it's not clear from all of this exactly how to use :use and :require.
Studying (or copying and modifying) example code from elsewhere seems
to be the way to do it and I think it's suboptimal when that's the
ONLY way.

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: A bug? Unbound Unbound in 1.3-alpha2 when a symbol is not set

2010-11-04 Thread Laurent PETIT
Luc is right.

As to explain the behavior, see below:

2010/11/4 Jacek Laskowski ja...@laskowski.net.pl:
 Hi,

 Is it intended in 1.3-alpha2? I think the error message in 1.2 is way
 better (although not as user friendly as I wish to). Shall I report
 it? Where? How?

 devmac:~ jacek$ clj -13
 CLOJURE_DIR:  /Users/jacek/apps/clojure
 CLOJURE_CONTRIB_JAR:  /Users/jacek/apps/clojure-contrib-1.3.0-alpha2.jar
 Clojure 1.3.0-alpha2
 user= (def c)
 #'user/c
 user= c
 #Unbound Unbound: #'user/c

c has the value Unbound. The semantic has not changed, the way to
carry the semantic has.

Now if you try to really use c, for example use it in call position,
then since Unbound implements IFn, you'll have the appropriate
exception because it correctly overrides IFn's invoke(...) methods.


 devmac:~ jacek$ clj
 CLOJURE_DIR:  /Users/jacek/apps/clojure-1.2.0
 CLOJURE_CONTRIB_JAR:
 /Users/jacek/apps/clojure-contrib/target/clojure-contrib-1.2.0.jar
 Clojure 1.2.0
 user= (def c)
 #'user/c
 user= c
 java.lang.IllegalStateException: Var user/c is unbound. (NO_SOURCE_FILE:0)




 Jacek

 --
 Jacek Laskowski
 Notatnik Projektanta Java EE - http://jaceklaskowski.pl

 --
 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 new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Python is way faster than Clojure on this task

2010-11-04 Thread Pepijn de Vos
Hi all,

I have written a Python script to analyze Minecraft levels and render a graph. 
Then I did the same with Clojure. It takes Python 10 seconds to analyze a map, 
while it takes Clojure over a minute.

After having tried different options without any significant improvement, I am 
lost as to why there is such a huge difference. I wouldn't mind an extra pair 
of eyes/brains to look at this.

I blogged about it in more detail here: 
http://pepijndevos.nl/clojure-versus-python
Clojure version: https://github.com/pepijndevos/Clomian/
Python version: https://github.com/l0b0/mian

Clojure spends most of its time in the freqs function, here are a couple of 
variations: https://gist.github.com/663096

If you want to run the code yourself, you'll need a Minecraft level and JNBT, 
which is not on Maven.
JNBT: http://jnbt.sourceforge.net/
The level used in the blogpost: http://dl.dropbox.com/u/10094764/World2.zip

Groeten,
Pepijn de Vos
--
Sent from my iPod Shuffle
http://pepijndevos.nl

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Python is way faster than Clojure on this task

2010-11-04 Thread Mike Meyer
On Thu, 4 Nov 2010 22:28:12 +0100
Pepijn de Vos pepijnde...@gmail.com wrote:

 Hi all,
 
 I have written a Python script to analyze Minecraft levels and render a 
 graph. Then I did the same with Clojure. It takes Python 10 seconds to 
 analyze a map, while it takes Clojure over a minute.
 
 After having tried different options without any significant improvement, I 
 am lost as to why there is such a huge difference. I wouldn't mind an extra 
 pair of eyes/brains to look at this.
 
 I blogged about it in more detail here: 
 http://pepijndevos.nl/clojure-versus-python
 Clojure version: https://github.com/pepijndevos/Clomian/
 Python version: https://github.com/l0b0/mian
 
 Clojure spends most of its time in the freqs function, here are a couple of 
 variations: https://gist.github.com/663096
 
 If you want to run the code yourself, you'll need a Minecraft level and JNBT, 
 which is not on Maven.
 JNBT: http://jnbt.sourceforge.net/
 The level used in the blogpost: http://dl.dropbox.com/u/10094764/World2.zip

Can you check GC activity in the clojure version?

I once ran into an issue where Python was running rings around an
Eiffel version (compiled down to native code - no VM need apply). This
looks similar to what you have, in that I built a large data
structure, and then started groveling over it. Turned out that Eiffel
was doing a mark-and-sweep GC, which was spending all of it's time
marking and sweeping the large static data structure, whereas python
doing a reference count GC didn't. Given that I know nothing about
Java GCs, this is just a WAG.

Come to think of it, how about trying to run the program Jython? That
should have the same GC issues. If it's some similar environmental
problem, that would show up there as well.

 mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Tryclojure - A Call To Action

2010-11-04 Thread Rayne
http://blog.acidrayne.net/?p=25

I wrote this blog post in the hopes that I can motivate people to
contribute to tryclojure. http://try-clojure.org is a relatively
important website that is unfortunately subpar. I hope that with the
community's help, we can turn it into something spectacular.

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Python is way faster than Clojure on this task

2010-11-04 Thread Andrew Gwozdziewycz
On Thu, Nov 4, 2010 at 5:43 PM, Mike Meyer
mwm-keyword-googlegroups.620...@mired.org wrote:
 On Thu, 4 Nov 2010 22:28:12 +0100
 Pepijn de Vos pepijnde...@gmail.com wrote:

 Hi all,

 I have written a Python script to analyze Minecraft levels and render a 
 graph. Then I did the same with Clojure. It takes Python 10 seconds to 
 analyze a map, while it takes Clojure over a minute.

 After having tried different options without any significant improvement, I 
 am lost as to why there is such a huge difference. I wouldn't mind an extra 
 pair of eyes/brains to look at this.

 I blogged about it in more detail here: 
 http://pepijndevos.nl/clojure-versus-python
 Clojure version: https://github.com/pepijndevos/Clomian/
 Python version: https://github.com/l0b0/mian

 Clojure spends most of its time in the freqs function, here are a couple of 
 variations: https://gist.github.com/663096

 If you want to run the code yourself, you'll need a Minecraft level and 
 JNBT, which is not on Maven.
 JNBT: http://jnbt.sourceforge.net/
 The level used in the blogpost: http://dl.dropbox.com/u/10094764/World2.zip

 Can you check GC activity in the clojure version?

 I once ran into an issue where Python was running rings around an
 Eiffel version (compiled down to native code - no VM need apply). This
 looks similar to what you have, in that I built a large data
 structure, and then started groveling over it. Turned out that Eiffel
 was doing a mark-and-sweep GC, which was spending all of it's time
 marking and sweeping the large static data structure, whereas python
 doing a reference count GC didn't. Given that I know nothing about
 Java GCs, this is just a WAG.

 Come to think of it, how about trying to run the program Jython? That
 should have the same GC issues. If it's some similar environmental
 problem, that would show up there as well.

There are many different collectors for the JVMs, too numerous to list
here, all tunable.

http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html


-- 
http://www.apgwoz.com

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Resources on optimizing Clojure code

2010-11-04 Thread Gary Poster
On Nov 4, 2010, at 1:32 PM, cej38 wrote:

 It is wonderful that people are so willing to help with a specific
 problem, and I encourage you to continue doing so, but I don't think
 anyone has answered the real question.  Is there material out there
 that describes some of the mechanisms, tools, ideas, etc. that will
 allow the average clojure user to optimize their code.  

Chapter 12 of Joy of Clojure is about performance (type hints, transience, 
chunked sequences, memoization, coercion).

Arguably much of the book is also about what you describe broadly, since it is 
trying to teach and encourage efficient, idiomatic Clojure usage generally, 
AIUI.

Gary

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


using swig in clojure

2010-11-04 Thread Seth
Ive recently had troubles using swig in clojure getting a 'unsatisfied
link exception' even though using the swig generated library worked in
regular java code. I believe there was a post on this somewhere in
these google groups.

Anyways, I have figured out that if I place the following code in a
clojure file (test.clj)
(System/loadLibrary Seth)

and go (compile 'test) on the REPL, i get


No such file or directory
  [Thrown class java.io.IOException]

Restarts:
 0: [QUIT] Quit to the SLIME top level

Backtrace:
  0: java.io.UnixFileSystem.createFileExclusively(Native Method)
  1: java.io.File.createNewFile(File.java:900)
  2: clojure.lang.Compiler.writeClassFile(Compiler.java:5885)
  3: clojure.lang.Compiler.compile(Compiler.java:6043)
  4: clojure.lang.RT.compile(RT.java:368)
  5: clojure.lang.RT.load(RT.java:407)
  6: clojure.lang.RT.load(RT.java:381)
  7: clojure.core$load$fn__4511.invoke(core.clj:4905)
  8: clojure.core$load.doInvoke(core.clj:4904)
  9: clojure.lang.RestFn.invoke(RestFn.java:409)
 --more--




However, afterwards i can succesfully do
(import Seth)
(Seth/add 2 3) = 5

I cant do the loadlibrary thing on the repl, or it wont work (i get
the 'unsatisfied link error' when calling (Seth/add)).  Notice that if
I do (compile 'test) again i get the same error above, which is
weird because if i do (System/loadLibrary Seth) on the repl i get
the 'expected' error

Native Library /home/seth/.random/java/libSeth.so already loaded in
another classloader
  [Thrown class java.lang.UnsatisfiedLinkError]

Restarts:
 0: [QUIT] Quit to the SLIME top level

Backtrace:
  0: java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1715)
  1: java.lang.ClassLoader.loadLibrary(ClassLoader.java:1675)
  2: java.lang.Runtime.loadLibrary0(Runtime.java:840)
  3: java.lang.System.loadLibrary(System.java:1047)
  4: user$eval1825.invoke(NO_SOURCE_FILE:1)
  5: clojure.lang.Compiler.eval(Compiler.java:5424)
  6: clojure.lang.Compiler.eval(Compiler.java:5391)
  7: clojure.core$eval.invoke(core.clj:2382)
 --more--




Anyone know whats going on and how this can be fixed?

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: A bug? Unbound Unbound in 1.3-alpha2 when a symbol is not set

2010-11-04 Thread Jacek Laskowski
On Thu, Nov 4, 2010 at 8:39 PM, Laurent PETIT laurent.pe...@gmail.com wrote:

 c has the value Unbound. The semantic has not changed, the way to
 carry the semantic has.

 Now if you try to really use c, for example use it in call position,
 then since Unbound implements IFn, you'll have the appropriate
 exception because it correctly overrides IFn's invoke(...) methods.

It begs a question then, why would I do that? Where would that be of use?

devmac:~ jacek$ clj -13
CLOJURE_DIR:  /Users/jacek/apps/clojure
CLOJURE_CONTRIB_JAR:  /Users/jacek/apps/clojure-contrib-1.3.0-alpha2.jar
Clojure 1.3.0-alpha2
user= (def c)
#'user/c
user= (c)
IllegalStateException Attempting to call unbound fn: #'user/c
clojure.lang.Var$Unbound.throwArity (Var.java:43)
user= (type c)
clojure.lang.Var$Unbound

Jacek

-- 
Jacek Laskowski
Notatnik Projektanta Java EE - http://jaceklaskowski.pl

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Tryclojure - A Call To Action

2010-11-04 Thread box
really like the site. i like the tutorial section. it would be nice if
the site would focus more on examples.

On Nov 4, 5:49 pm, Rayne disciplera...@gmail.com wrote:
 http://blog.acidrayne.net/?p=25

 I wrote this blog post in the hopes that I can motivate people to
 contribute to tryclojure.http://try-clojure.orgis a relatively
 important website that is unfortunately subpar. I hope that with the
 community's help, we can turn it into something spectacular.

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Tryclojure - A Call To Action

2010-11-04 Thread Rayne
Right. One of the most important aspects of a site like this is it's
tutorial. The tutorial should be interactive, much like tryhaskell's
tutorial. That's one of the biggest things that needs to be done.

Beyond that, tutorial authors would be great as well. If somebody
feels like writing a tutorial section or improving the existing ones,
have at it. It's a great way to examine your own Clojure knowledge and
very helpfully contribute to the project at the same time.

On Nov 4, 6:36 pm, box somethingital...@gmail.com wrote:
 really like the site. i like the tutorial section. it would be nice if
 the site would focus more on examples.

 On Nov 4, 5:49 pm, Rayne disciplera...@gmail.com wrote:



 http://blog.acidrayne.net/?p=25

  I wrote this blog post in the hopes that I can motivate people to
  contribute to tryclojure.http://try-clojure.orgisa relatively
  important website that is unfortunately subpar. I hope that with the
  community's help, we can turn it into something spectacular.

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Polymorphic protocols and containers....

2010-11-04 Thread Mike Meyer
It seems like the polymorphism of protocols breaks inside the
methods. This is a problem for having a function that's polymorphic
between an object and a container of the same objects.

For instance:

user= (defprotocol Tune (tweek [this]))
Tune
user= (deftype Knob [name] Tune (tweek [this] (println Tweeked name)))
user.Knob
user= (def base (Knob. base))
#'user/base
user= (tweek base)
Tweeked base
nil
user= (def treble (Knob. treble))
#'user/treble
user= (tweek treble)
Tweeked treble
nil
user= (deftype Box [ knobs] Tune (tweek [this] (for [knob knobs] (tweek 
knob
user.Box
user= (tweek (Box. base treble))
user= (tweek (Box. base treble))
java.lang.IllegalArgumentException: Don't know how to create ISeq from: 
user.Knob
(user= 

Where what I really want to happen is to tweek all the knobs in the
box. Unfortunately, tweek inside the method seems to be wired to the
method it's in, and no longer polymorphic. I've tried various ways to
get to the variable I want, and some hinting, but nothing seems to
change what I'm getting here.

Maybe I shouldn't be trying to use protocols and types for this? Can
someone let me know what I need to do to make this happen?

Thanks,
mike
-- 
Mike Meyer m...@mired.org http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Tryclojure - A Call To Action

2010-11-04 Thread Eric Lavigne
Last time I introduced someone to Clojure via try-clojure.org, he came
back later and said that the console ignored him after a while, and he
wasn't sure what he did wrong. We tried it together, and after a
couple minutes it stopped evaluating expressions. Does this bug sound
familiar? Unfortunately, I haven't been able to reproduce it since.

I'm guessing this is related to the bugfixes in jquery-console that
you mentioned, so upgrading to the latest version of jquery-console is
the piece that I would want to take on.

For my own reference, these are the customizations you made to
jquery-console that I will need to watch out for:

 
https://github.com/Raynes/tryclojure/commits/master/resources/public/javascript/jquery.console.js


On Thu, Nov 4, 2010 at 5:49 PM, Rayne disciplera...@gmail.com wrote:
 http://blog.acidrayne.net/?p=25

 I wrote this blog post in the hopes that I can motivate people to
 contribute to tryclojure. http://try-clojure.org is a relatively
 important website that is unfortunately subpar. I hope that with the
 community's help, we can turn it into something spectacular.


-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Tryclojure - A Call To Action

2010-11-04 Thread Rayne
That would be great. Any sort of problems with the console are very
likely to be related to jquery-console, so updating it might fix them.

I actually hadn't heard of that bug. Probably not a good sign, since
it might mean that people spend very little time with tryclojure. ;)

On Nov 4, 7:40 pm, Eric Lavigne lavigne.e...@gmail.com wrote:
 Last time I introduced someone to Clojure via try-clojure.org, he came
 back later and said that the console ignored him after a while, and he
 wasn't sure what he did wrong. We tried it together, and after a
 couple minutes it stopped evaluating expressions. Does this bug sound
 familiar? Unfortunately, I haven't been able to reproduce it since.

 I'm guessing this is related to the bugfixes in jquery-console that
 you mentioned, so upgrading to the latest version of jquery-console is
 the piece that I would want to take on.

 For my own reference, these are the customizations you made to
 jquery-console that I will need to watch out for:

      https://github.com/Raynes/tryclojure/commits/master/resources/public/...



 On Thu, Nov 4, 2010 at 5:49 PM, Rayne disciplera...@gmail.com wrote:
 http://blog.acidrayne.net/?p=25

  I wrote this blog post in the hopes that I can motivate people to
  contribute to tryclojure.http://try-clojure.orgis a relatively
  important website that is unfortunately subpar. I hope that with the
  community's help, we can turn it into something spectacular.

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Polymorphic protocols and containers....

2010-11-04 Thread Ken Wesson
user= (defn tweek* [knob] (tweek knob))
#'user/tweek*
user= (tweek* base)
Tweeked base
nil
user= (deftype Box [ knobs] Tune (tweek [this] (for [knob knobs]
(tweek* knob
user.Box
user= (tweek (Box. base treble))
#IllegalArgumentException java.lang.IllegalArgumentException: Don't
know how to create ISeq from: user.Knob

Not lexical scope, then -- it's not the deftype macro redefining it
lexically or that wouldn't make tweek* stop working.


user= (defn tweek* [knobs] (pmap #(tweek %) knobs))
#'user/tweek*
user= (tweek (Box. base treble))
#CompilerException java.lang.RuntimeException:
java.lang.IllegalArgumentException: Don't know how to create ISeq
from: user.Knob (NO_SOURCE_FILE:28)

Even more interesting. It's not being thread-locally rebound, either.
It's being globally rebound.


user= (deftype Box [ knobs] Tune (tweek [this] (println this) (tweek* knobs)))
user.Box
user= (tweek (Box. base treble))
#Box user@fe7f80
#CompilerException java.lang.RuntimeException:
java.lang.IllegalArgumentException: Don't know how to create ISeq
from: user.Knob (NO_SOURCE_FILE:30)

Fascinating. It's not calling the Box tweek on the Box, then calling
the Box tweek again on the knobs, else we'd have seen

#Box user@fe7f80
#Knob user.k...@fa6824
#CompilerException java.lang.RuntimeException:
java.lang.IllegalArgumentException: Don't know how to create ISeq
from: user.Knob

as it called tweek on the Box, printed the box, called tweek* which
mapped over the knobs, tweek got called on the base knob, printed the
base knob, and then tried to pmap over the base knob which isn't an
ISeq.

It's doing something else but I don't know what and I've got to go,
sorry. Fringe is on.

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Tryclojure - A Call To Action

2010-11-04 Thread Ken Wesson
On Thu, Nov 4, 2010 at 8:58 PM, Rayne disciplera...@gmail.com wrote:
 That would be great. Any sort of problems with the console are very
 likely to be related to jquery-console, so updating it might fix them.

 I actually hadn't heard of that bug. Probably not a good sign, since
 it might mean that people spend very little time with tryclojure. ;)

Inability to paste into the repl at tryclojure is also a problem.

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Tryclojure - A Call To Action

2010-11-04 Thread pete mcquain
I would love to help out.  I'm new to closure, but I'm a web dev by day.
What can I do?
On Nov 4, 2010 5:49 PM, Rayne disciplera...@gmail.com wrote:
 http://blog.acidrayne.net/?p=25

 I wrote this blog post in the hopes that I can motivate people to
 contribute to tryclojure. http://try-clojure.org is a relatively
 important website that is unfortunately subpar. I hope that with the
 community's help, we can turn it into something spectacular.

 --
 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 new members are moderated - please be patient with
your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Tryclojure - A Call To Action

2010-11-04 Thread Eric Lavigne
Pete,

Would you feel comfortable working on the jquery-console upgrade?
That's entirely a Javascript issue, and I'd be happy to find another
piece to work on. I actually prefer working in Clojure, and only took
on the jquery-console upgrade task because it seemed important.

Let me know if you're going to do the jquery-console upgrade, in which
case I'll choose one of the other tasks.

Eric

On Thu, Nov 4, 2010 at 9:04 PM, pete mcquain pete.mcqu...@gmail.com wrote:
 I would love to help out.  I'm new to closure, but I'm a web dev by day.
 What can I do?

 On Nov 4, 2010 5:49 PM, Rayne disciplera...@gmail.com wrote:
 http://blog.acidrayne.net/?p=25

 I wrote this blog post in the hopes that I can motivate people to
 contribute to tryclojure. http://try-clojure.org is a relatively
 important website that is unfortunately subpar. I hope that with the
 community's help, we can turn it into something spectacular.

 --
 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 new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

 --
 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 new members are moderated - please be patient with your
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Tryclojure - A Call To Action

2010-11-04 Thread Rayne
I'm not sure, but I think I might have convinced Chris Done to allow
pasting into the REPL. In any case, all tutorial examples are
clickable (they are thrown into the REPL), which was my way of trying
to work around those issues. Anybody is welcome to patch tryclojure's
version of jquery-console (after the upgrade). However, if we start
making changes like this, it might be a good idea to fork the jquery-
console repository for our version.

On Nov 4, 8:03 pm, Ken Wesson kwess...@gmail.com wrote:
 On Thu, Nov 4, 2010 at 8:58 PM, Rayne disciplera...@gmail.com wrote:
  That would be great. Any sort of problems with the console are very
  likely to be related to jquery-console, so updating it might fix them.

  I actually hadn't heard of that bug. Probably not a good sign, since
  it might mean that people spend very little time with tryclojure. ;)

 Inability to paste into the repl at tryclojure is also a problem.

There is lots to do! If you're decent with web design, then check out
the current design and see if you can make it better. I'm sure the
HTML is a mess, and heaven knows the CSS is probably a disaster, so
maybe you can help out with that. Making tryclojure look good is
important as well.

Beyond that, we have JavaScript stuff to do as well. Like Eric said,
jquery-console needs to be upgraded, and we need an interactive
tutorial a la tryhaskell.org, so that is some stuff you could look
into as well.

On Nov 4, 8:04 pm, pete mcquain pete.mcqu...@gmail.com wrote:
 I would love to help out.  I'm new to closure, but I'm a web dev by day.
 What can I do?

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Tryclojure - A Call To Action

2010-11-04 Thread pete mcquain
Sounds good to me. I'll start looking into it.
On Nov 4, 2010 9:15 PM, Eric Lavigne lavigne.e...@gmail.com wrote:
 Pete,

 Would you feel comfortable working on the jquery-console upgrade?
 That's entirely a Javascript issue, and I'd be happy to find another
 piece to work on. I actually prefer working in Clojure, and only took
 on the jquery-console upgrade task because it seemed important.

 Let me know if you're going to do the jquery-console upgrade, in which
 case I'll choose one of the other tasks.

 Eric

 On Thu, Nov 4, 2010 at 9:04 PM, pete mcquain pete.mcqu...@gmail.com
wrote:
 I would love to help out.  I'm new to closure, but I'm a web dev by day.
 What can I do?

 On Nov 4, 2010 5:49 PM, Rayne disciplera...@gmail.com wrote:
 http://blog.acidrayne.net/?p=25

 I wrote this blog post in the hopes that I can motivate people to
 contribute to tryclojure. http://try-clojure.org is a relatively
 important website that is unfortunately subpar. I hope that with the
 community's help, we can turn it into something spectacular.

 --
 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 new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

 --
 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 new members are moderated - please be patient with
your
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

 --
 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 new members are moderated - please be patient with
your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Tryclojure - A Call To Action

2010-11-04 Thread Rayne
I'd like to remind you guys that if you plan to work on something,
please create an issue for it on Github and let me know, so that I can
assign your name to it with a tag and we can avoid duplicating work.

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Some questions about Clojure Protocols

2010-11-04 Thread ka
 May I ask a heretic question: Why don't you specify the contract in the 
 docstring of the protocol?

Yes Meikel that is exactly what I have right now. Just trying to learn
and stir up a discussion here :)

Most times you'll just do fine by passing 'something' to Coolness
functions and expect them to work - they'll just blow up on runtime
(no .compareTo) if that 'something' isn't cool. But imagine certain
scary situations where that 'something' is really 'HalfCool' and still
some 'Coolness' functions work (type dispatch) behind your back!.

(defprotocol Coolness
  Yadddayaddablablablubber.
  Cool things have to be Comparable and Serializable.
  (x .. Since 'this' is cool i assume it is Serializable and
Comparable and so logically I can safely do this cool x thing!)
  (y ...))

(deftype ReallyCool ... Coolness .. Comparable .. Serializable)
(deftype SneakyCool .. Coolness)

(x (ReallyCool.)) ;yay rocket launches and reaches moon!
(x (SneakyCool.)) ;rocket launches alright (no exception thrown), but
blows mid air

I know you might argue its a code bug and caller's problem etc. - but
you just allowed a rocket to blow up.

Other times it might be necessary to know if something is 'Cool':

static public ISeq seq(Object coll){
  if(coll instanceof ASeq)
return (ASeq) coll;
  else if(coll instanceof LazySeq)
return ((LazySeq) coll).seq();
  else
return seqFrom(coll);
}

@Laurent,
 * first, when I see calls to (instance?) (satisifies?), it rings a bell in my 
 head. design problem.
Do you see the above seq method as a design problem? - or if you don't
care about Java, consider clojure.walk.

If I understand you correctly (probability of which is less) you don't
really see protocols as defining abstractions - but just as a
convenient tool for polymorphism. Like:

(extend ReallyCool clojure.contrib.json/Write-JSON
  {:write-json ...})

But all of this discussion is kind of bypassing my original question,
Meikel you say:

 A protocol comprises functions which act on data in a certain abstract way.

I simply asked - is there anything fundamentally wrong with the notion
of those protocols being composable. Protocol P is a set of abstract
functions, can we have a convenient way of saying P = union(P1, P2) ?

On a related note how is this:

(defn dispatch-fn [this ..]
  (if (and (comparable? this) (serializable? this))
 :green-signal :red-signal)

(defmulti x dispatch-fn)
(defmulti y dispatch-fn)
(defmulti z dispatch-fn)

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Tryclojure - A Call To Action

2010-11-04 Thread pete mcquain
Ok, sounds good (branch).  What stack/host is it being hosted on now?I've
got a couple crazy AppEngine ideas that have been floating around for the
past week or so.  Could be a good dogfooding example in itself.
-Pete -
On Nov 4, 2010 9:39 PM, Rayne disciplera...@gmail.com wrote:
 I'd like to remind you guys that if you plan to work on something,
 please create an issue for it on Github and let me know, so that I can
 assign your name to it with a tag and we can avoid duplicating work.

 --
 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 new members are moderated - please be patient with
your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Bug with instance? inside deftypes

2010-11-04 Thread ka
Christophe, Is it reasonable to assume that atleast the documentation
should be modified to reflect the situation?

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: A bug? Unbound Unbound in 1.3-alpha2 when a symbol is not set

2010-11-04 Thread David Nolen
On Thu, Nov 4, 2010 at 7:09 PM, Jacek Laskowski ja...@laskowski.net.plwrote:


 It begs a question then, why would I do that? Where would that be of use?


The behavior has changed, for some context:

http://clojure-log.n01se.net/date/2010-10-18.html#12:12c

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Tryclojure - A Call To Action

2010-11-04 Thread Vilson Vieira
Rayne I loved try clojure! Congrats! I really want to help but running
out of time for now. I'll take my hands on that as soon as possible.

Cheers.

2010/11/4 Rayne disciplera...@gmail.com:
 Right. One of the most important aspects of a site like this is it's
 tutorial. The tutorial should be interactive, much like tryhaskell's
 tutorial. That's one of the biggest things that needs to be done.

 Beyond that, tutorial authors would be great as well. If somebody
 feels like writing a tutorial section or improving the existing ones,
 have at it. It's a great way to examine your own Clojure knowledge and
 very helpfully contribute to the project at the same time.

 On Nov 4, 6:36 pm, box somethingital...@gmail.com wrote:
 really like the site. i like the tutorial section. it would be nice if
 the site would focus more on examples.

 On Nov 4, 5:49 pm, Rayne disciplera...@gmail.com wrote:



 http://blog.acidrayne.net/?p=25

  I wrote this blog post in the hopes that I can motivate people to
  contribute to tryclojure.http://try-clojure.orgisa relatively
  important website that is unfortunately subpar. I hope that with the
  community's help, we can turn it into something spectacular.

 --
 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 new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en




-- 
Vilson Vieira

vil...@void.cc

((( http://automata.cc )))

((( http://musa.cc )))

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Meta-circular STM for teaching purposes

2010-11-04 Thread ka
Hi Tom,

I might not be even remotely qualified but since I'm interested and
find the idea cool, so here's my take:

 - has anyone already experimented with a toy STM in Clojure for didactic 
 purposes?

No idea :)

 - what would be a good resource to start such a design from? (my current plan 
 is to start from http://java.ociweb.com/mark/stm/article.html)

I would think a good place to start is to define the primitives and
goals:
Primitives: assume existence of monitors in Clojure
Goals: Implement dosync in Clojure (hefty goal :))

I would love to help out in any capacity since I myself want to get
started with understand the STM in more detail. If you need a
volunteer you may contact me personally.

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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Reloading java classes

2010-11-04 Thread Seth
All i need to do is a function to reload a class I specify, nothing
fancy. Surely there is some way?

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Reloading java classes

2010-11-04 Thread Dave Newton
JRebel is still the best answer. Loading a class at runtime is non- trivial.
I don't know how it deals with handling existing instances of the class,
though; I still think CLOS got that right.

Dave
 On Nov 4, 2010 10:03 PM, Seth wbu...@gmail.com wrote:
 All i need to do is a function to reload a class I specify, nothing
 fancy. Surely there is some way?

 --
 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 new members are moderated - please be patient with
your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Tryclojure - A Call To Action

2010-11-04 Thread Rayne
It's currently hosted on Heinz's (Licenser's) server, which runs
apache.

On Nov 4, 9:22 pm, pete mcquain pete.mcqu...@gmail.com wrote:
 Ok, sounds good (branch).  What stack/host is it being hosted on now?I've
 got a couple crazy AppEngine ideas that have been floating around for the
 past week or so.  Could be a good dogfooding example in itself.
 -Pete -

I wouldn't be opposed to a try[ruby|haskell]ish design. The designs
are very pretty. If anybody wants to go that route, I'd love to see
the results. :

On Nov 4, 9:43 pm, Vilson Vieira vil...@void.cc wrote:
 2010/11/4 Rayne disciplera...@gmail.com:

  There is lots to do! If you're decent with web design, then check out
  the current design and see if you can make it better. I'm sure the
  HTML is a mess, and heaven knows the CSS is probably a disaster, so
  maybe you can help out with that. Making tryclojure look good is
  important as well.

 tryhaskell is a clone of why_'s tryruby [1]. We can do the same...

 [1]https://github.com/Sophrinix/TryRuby

 --
 Vilson Vieira

 vil...@void.cc

 (((http://automata.cc)))

 (((http://musa.cc)))

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Some questions about Clojure Protocols

2010-11-04 Thread David Nolen
On Thu, Nov 4, 2010 at 10:17 PM, ka sancha...@gmail.com wrote:

  May I ask a heretic question: Why don't you specify the contract in the
 docstring of the protocol?

 (defprotocol Coolness
  Yadddayaddablablablubber.
  Cool things have to be Comparable and Serializable.
   (x .. Since 'this' is cool i assume it is Serializable and
 Comparable and so logically I can safely do this cool x thing!)
  (y ...))


This would be a terrible protocol - protocols do not compose in this manner.


 static public ISeq seq(Object coll){
  if(coll instanceof ASeq)
return (ASeq) coll;
  else if(coll instanceof LazySeq)
return ((LazySeq) coll).seq();
  else
return seqFrom(coll);
 }



 Do you see the above seq method as a design problem? - or if you don't
 care about Java, consider clojure.walk.


You can't fix Java so I'm not sure that's a legitimate example. clojure.walk
suffers from the closed property.


 If I understand you correctly (probability of which is less) you don't
 really see protocols as defining abstractions - but just as a
 convenient tool for polymorphism. Like:


polymorphism *is* a form of abstraction.


 I simply asked - is there anything fundamentally wrong with the notion
 of those protocols being composable. Protocol P is a set of abstract
 functions, can we have a convenient way of saying P = union(P1, P2) ?


 This is desirable, but it's not clear whether this should be a feature of
protocols themselves.


 On a related note how is this:

 (defn dispatch-fn [this ..]
  (if (and (comparable? this) (serializable? this))
 :green-signal :red-signal)


Aha! Getting warmer.

This highlights a sore spot in the current multimethod implementation - the
dispatch fn is closed. Rich has expressed several times that he would like
to see a predicate dispatch implementation for clojure that removes this
wart.

David

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Tryclojure - A Call To Action

2010-11-04 Thread Rayne
Not to discourage discussion here, but in case anybody missed it in
the blog post, we have a google group now if anybody wants to discuss
what they're doing, considering doing, or any ideas.
http://groups.google.com/group/tryclojure

-- 
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 new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en