Re: Extending IFn

2011-10-28 Thread Meikel Brandmeyer (kotarak)
Hi,

since IFn is a Java interface and not a protocol, I'm afraid there is no 
better way to define this. However I would write the macro slightly 
differently. I find this more approachable. YMMV.

(def max-arities 20)

(defmacro definvokable
  [type fields & deftype-tail]
  (let [f(fields 0)
args (repeatedly max-arities gensym)
arity(fn [n]
   (let [args (take n args)]
 `(invoke [this# ~@args] ((. this# ~f) ~@args
vararg   `(invoke [this# ~@args more#]
(apply (. this# ~f) ~@args more#))
apply-to `(applyTo [this# args#] (apply (. this# ~f) args#))]
`(deftype ~type
   ~fields
   clojure.lang.IFn
   ~@(map arity (range (inc max-arities)))
   ~vararg
   ~apply-to
   ~@deftype-tail)))

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: Literate programming

2011-10-28 Thread Stefan Kamphausen
Hi,

just to be sure: are you are aware of Marginalia?
https://github.com/fogus/marginalia

Regards,
Stefan

-- 
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: Literate programming

2011-10-28 Thread Michael Jaaka
Maybe COBOL already solves the problem which Literate Programming want to 
solve?

-- 
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: core.match 0.2.0-alpha6, breaking change for or patterns

2011-10-28 Thread Michael Jaaka
Can you give examples of usage for each position?

-- 
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: Literate programming

2011-10-28 Thread Larry Johnson
On Thu, Oct 27, 2011 at 11:52 PM, daly  wrote:

>
> Any means of publication can be the medium for literate programming.
> As I rule I prefer Latex but anything will do.
>
> All you need is a distinguished means of quoting and naming the
> chunks. In html this could be as simple as:
>   
>  your code
>   
> and you need a program, often called "tangle", to extract the chunk
>   tangle mywebpage.html somename >mysomename.file
>
>
Yep.  That's all my Rube Goldberg-ish system did.  The chunk of machine
recognizable code was named as an attribute in a modified  tag.
The "weave" just stripped it out so you were left with "typeset ready"
Docbook markup.  The "tangle" just yanked out the target source code and
wrote it to a file in the proper order.

>
> The hardest part of literate programming is the mindset.
>
> In order to do literate programming you need to change your focus
> from traditional programming to writing for humans and, as a side
> effect, writing for the machine.
>  
> 
>

For programmers who are resistant to even commenting code LP must seem
nightmarish (at least at first).  Not only are you required to provide
comments, but those comments have to be a complete, well formatted, human
readable, journal article.  Also, it takes some time getting one's head
wrapped around the fact that the order in which the target language source
code appears in the article is not necessarily the order in which the
machine needs it for compilation and execution purposes.

When LP is practiced consistently it prevents a number of bad habits, and I
can't see that those good effects change whether one is using a "top down"
or "bottom up" approach to programming.  Since you're writing a complete,
well formatted, human readable, article on how the code works, you can't
just cut-and-paste code into a project without really understanding what the
code is doing (well, I guess you can, but that would become obvious while
you or another reader were trying to follow the article).
-- 

*Off the Beaten Path in Technology
http://otbeatenpath.wordpress.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: Clojure Conj extracurricular activities spreadsheet

2011-10-28 Thread Arnoldo Muller
Fogus,

Please add me to the core.logic, Heroku drinkup and Jamming with
Overtone.

Arnoldo

On Oct 25, 6:11 pm, Fogus  wrote:
> All,
>
> We talked about the possibility of getting some ideas about
> extracurricular activities during the Conj days (and possibly training
> days).  I've created a spreadsheet at the link below to collect
> ideas.  It is not my intention to be the organizer of these
> activities.  Instead, if you have an idea then please be prepared to
> own it.  The matter of space for these activities would need to be
> worked out by Conj planners or activity organizers, but having a list
> would help that process.
>
> https://docs.google.com/spreadsheet/ccc?key=0Alim_jfrt24MdDFqZVZsNW0t...
>
> I've entered an example, feel free to add your own ideas. :-)
>
> This should be epic.

-- 
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: Literate programming

2011-10-28 Thread Tassilo Horn
Hi Tim,

while I agree that good documentation is important for maintaining and
developing further a given code base, I always wonder how literate
programming deals with refactoring and larger restructuring.  I mean, in
basically all software projects I'm involved in, developers have a hard
time in keeping at least the most integral documentation up-to-date,
e.g., docstrings, JavaDocs, etc.

Now I consider a some literate code base, i.e., a book that describes
the complete system in a very detailed manner including the reasons to
design it that way.  That's awesome for developers joining the project,
but doesn't it hinder any further development?

For example, I'm currently reworking some paper that includes code for
some model transformation.  If I had the right tools, I could extract
the source code from the latex files and have a running transformation.
But now, I had to do some minor modifications to the code which took me
about 5 minutes, but adapting the surrounding text takes me hours over
hours.  I think, that's an experience many people have made: changing
source code of a system that is well-designed and understood by the
developer is much easier to do than changing a cohesive text in natural
language.  In code, I have an automated, picky lector that always reads
the complete "book" after each change I make (also known as compiler).
In plain text, only a human can verify consistency and only in very
narrow borders.

Well, that's more text than I intended to write. ;-) So short story
long: how do you manage conistency of docs and code in literate code
bases?

Bye,
Tassilo

-- 
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: repl output for list seems inconsistent and a holdover from yesteryear

2011-10-28 Thread Mark Rathwell
One clarification that might help is that traditionally the list has
been the only structure in lisps, and other data representations were
faked with lists.  Clojure added other modern data structures to that
traditional model (those are what are generally used for "data"
purposes) and left the list as the core code/data structure.

On Fri, Oct 28, 2011 at 1:16 AM, e  wrote:
> I think I understand more now though, everyone.  Thanks.  clojure chose
> lists for the data structure for code so lists sort of have a special place
> in the language.
> Thanks again.
>
> On Fri, Oct 28, 2011 at 1:13 AM, e  wrote:
>>
>>
>> On Thu, Oct 27, 2011 at 8:26 PM, Mark Rathwell 
>> wrote:
>>>
>>> > Maybe it would be clearer if I proposed some other, lesser-used chars,
>>> > like
>>> > "%(1 2 3 4)" or even "<1 2 3 4>".  That is, I'm not so much saying,
>>> > "this
>>> > needs to be treated as data and not eval'd" as I am simply saying,
>>> > "this is
>>> > the 'list' data structure as opposed to some other".
>>>
>>> A list data structure and a list code structure are the same.
>>
>> why wasn't vector chosen for code?
>>
>>>
>>> The
>>> only difference is that the programmer decides when one should not be
>>> evaluated.  By creating separate syntax for a list data structure you
>>> are in essence creating a different structure for lists of data than
>>> lists of code, and you no longer have a straightforwardly homoiconic
>>> language.
>>
>> This seems like a hugely important thing for me to grock, but it is easier
>> to grock in languages that, say, ONLY have lists.  Otherwise it seems like
>> code is arbitrarily ONE of the data structures and, therefore is NOT
>> homoiconic with respect to any other data structure.
>>
>>>
>>> > Why is there an assumption that
>>> > code as data means code as lists? Or is there?
>>>
>>> This is the key to everything.  Code is data
>>
>> yes, fine. but "data" doesn't always mean list in *my* mind.  But I'm
>> starting to get that it was chosen to be the same thing in lisps.
>>
>>>
>>> , data is code, they are
>>> the same structure.  By treating a list of data (integers for example)
>>> differently than a list of code (function and args), you create a
>>> situation where code and data are no longer the same thing.
>>
>> no. code and lists are no longer the same thing.  I see "data" as a
>> generic concept . . .a superset, not a different set.  code could be "data"
>> that I haven't picked a data structure for, yet.
>>
>>>
>>>  That
>>> trait is a fundamental trait of lisps, and makes things like macros
>>> much simpler.
>>
>> I suspected this, too. ok.
>>
>>>
>>> You don't have to call the structure a list, you can
>>> call it something else if you prefer, but whatever it is called, it
>>> must be the same structure that defines code and defines data.
>>
>> But, again, there are plenty of structures that define "data" differently
>> then that which was chosen for code.  So why not just have a "code
>> structure".  Again, it already seems broken with respect to other
>> structures.  Here's some "data". It's a vector. Here's *more* data.  It's a
>> chunk of code.  Ah but it was arbitrarily decided (more from history and
>> evolution) that *that* data is a list.  Broken.
>>
>>
>>>
>>> On Thu, Oct 27, 2011 at 6:58 PM, e  wrote:
>>> >
>>> > On Oct 26, 2011 7:15 PM, "Stuart Halloway" 
>>> > wrote:
>>> >>>
>>> >>> checking out the "Try Clojure":
>>> >>>
>>> >>> if you type the following, you get output that matches what you typed
>>> >>> in every case except for lists.
>>> >>>
>>> >>> Vectors: --> [1 2 3 4]
>>> >>> [1 2 3 4]
>>> >>>
>>> >>> Maps: --> {:foo "bar" 3 4}
>>> >>> {:foo "bar" 3 4}
>>> >>>
>>> >>> Lists: --> '(1 2 3 4)
>>> >>> (1 2 3 4)  <- *INCONSISTENT* why not render this as '(1 2 3 4)
>>> >>> ...
>>> >>> this would make much more sense to newbies.
>>> >>>
>>> >>> Sets: --> #{1 2 3 4}
>>> >>> #{1 2 3 4}
>>> >>
>>> >>
>>> >> This is an interesting question. Consistency is important, but
>>> >> consistency
>>> >> with what? Your mental model for what happens at the REPL needs to
>>> >> keep the
>>> >> R, E, and P steps clearly separate.
>>> >>
>>> >> Working backward:  the P (Print) prints things in a way that they can
>>> >> be
>>> >> read back, where possible:
>>> >>
>>> >> (read-string "[1 2 3 4]")
>>> >> => [1 2 3 4]
>>> >>
>>> >> (read-string "(1 2 3 4)")
>>> >> => (1 2 3 4)
>>> >>
>>> >> (read-string "#{1 2 3 4}")
>>> >> => #{1 2 3 4}
>>> >>
>>> >> (read-string "{1 2 3 4}")
>>> >> =>  {1 2, 3 4}
>>> >>
>>> >> If the P part of the REPL put a tick in front of lists, they would not
>>> >> read back correctly:
>>> >>
>>> >> (read-string "'(1 2 3 4)")
>>> >> => (quote (1 2 3 4))            < INCONSISTENT
>>> >>
>>> >
>>> > I see the problem that token " ' " is already taken to be short hand
>>> > for
>>> > "quote" so to be truly consistent, I might be compelled to argue that
>>> > (read-string "'(1 2 3 4)") should, seeing some hypothetical "list
>>> > start"
>>> > multi-char token 

Re: Extending IFn

2011-10-28 Thread Sean Devlin
Eh, I was afraid the interface would be a problem.  So there isn't a
good way to reuse interface implementations for interacting w/ legacy
Java quite yet.

I do like your approach to the macro better.  As usual you deliver,
Meikel :)

Sean

On Oct 28, 3:11 am, "Meikel Brandmeyer (kotarak)" 
wrote:
> Hi,
>
> since IFn is a Java interface and not a protocol, I'm afraid there is no
> better way to define this. However I would write the macro slightly
> differently. I find this more approachable. YMMV.
>
> (def max-arities 20)
>
> (defmacro definvokable
>   [type fields & deftype-tail]
>   (let [f        (fields 0)
>         args     (repeatedly max-arities gensym)
>         arity    (fn [n]
>                    (let [args (take n args)]
>                      `(invoke [this# ~@args] ((. this# ~f) ~@args
>         vararg   `(invoke [this# ~@args more#]
>                     (apply (. this# ~f) ~@args more#))
>         apply-to `(applyTo [this# args#] (apply (. this# ~f) args#))]
>     `(deftype ~type
>        ~fields
>        clojure.lang.IFn
>        ~@(map arity (range (inc max-arities)))
>        ~vararg
>        ~apply-to
>        ~@deftype-tail)))
>
> 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: ClojureScript and Counterclockwise?

2011-10-28 Thread Base
Thanks Luc!

I will give that a shot.

On Oct 27, 7:55 pm, Luc Prefontaine 
wrote:
> I run cljs_watch in a terminal window at the top of the project
> and I defined .cljs files to use the CCW editor. cljs_watch spots the changed 
> .cljs files
> through Eclipse and recompiles on the fly. Then I refresh the browser.
>
> It does most of the job.
>
> Luc P.
>
> On Thu, 27 Oct 2011 10:27:29 -0700 (PDT)
>
> Base  wrote:
> > Hi All -
>
> > Do any of you happen to know if Counterclockwise supports the
> > development of apps using ClojureScript?
>
> > Thanks!
>
> > Base
>
> --
> Luc P.
>
> 
> The rabid Muppet

-- 
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: clojurescript: generating the JavaScript on the fly?

2011-10-28 Thread Base
Not really.  ClojureScript only supports AOT compiling.  So you would
have to compile the ClojureScript code into javascript on the server
and send that over the wire.


On Oct 27, 1:27 am, Guofeng Zhang  wrote:
> Hi,
>
> Suppose there is a ajax request comes to the server. The server code process 
> it and then send some JavaScript codes as the response.
>
> Could clojurescript be using in the case? For example, given a string 
> representing the Clojurescript code, then build it into Javascript codes in 
> the memeory, then the codes are send back to the client as the response.
>
> Thanks!
>
> Guofeng

-- 
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: ultra-noob read-line question

2011-10-28 Thread Andrew
I should be more specific. I see the exception only with trampoline.

Exception in thread "main" java.lang.IllegalArgumentException: No 
implementation of method: :make-writer of protocol: #'
clojure.java.io/IOFactory found for class: nil (NO_SOURCE_FILE:0)

-- 
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 there a String protocol?

2011-10-28 Thread Stuart Sierra
You can use `read-string` as a general-purpose String-to-Number conversion.

-S

-- 
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 there a String protocol?

2011-10-28 Thread Sean Devlin
Yes, read-string is awesome, but that doesn't work as a number
protocol.

Python's int works on numbers and strings, and returns an int.  A set
of Clojure protocols that do the same would be very, very handy.

Sean

On Oct 28, 10:22 am, Stuart Sierra 
wrote:
> You can use `read-string` as a general-purpose String-to-Number conversion.
>
> -S

-- 
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: core.match 0.2.0-alpha6, breaking change for or patterns

2011-10-28 Thread David Nolen
The documentation has been updated to account for the changes:

https://github.com/clojure/core.match

On Fri, Oct 28, 2011 at 5:40 AM, Michael Jaaka  wrote:

> Can you give examples of usage for each position?
>
> --
> 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: Clojure Conj extracurricular activities spreadsheet

2011-10-28 Thread Benny Tsai
Please add me for core.logic, Heroku Drinkup, and Jamming with Overtone.

-- 
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: appengine-magic, directory not found, strange file: hierarchy

2011-10-28 Thread Paul Koerbitz
Thank you for sharing the link, I will have to go through installing Oracle
Java once I upgrade to 11.10.

cheers
Paul

On Thu, Oct 27, 2011 at 18:56, Thorsten Wilms  wrote:

> On 10/27/2011 02:45 PM, Paul Koerbitz wrote:
>
>  are you sure you used OpenJDK before the upgrade? I remember having
>> problems with OpenJDK + AppengineMagic which were resolved by switching
>> to Sun's JDK (this was on Ubuntu 10.04).
>>
>
> Switching to Oracle's version fixed it.
>
> I must have had it installed long before getting into Clojure, to then
> forget about it, on Ubuntu 10.04. Since there's apparently no package for
> 11.10, I followed http://www.webupd8.org/2011/**
> 09/how-to-install-oracle-java-**7-jdk-in.html
>
> Thanks!
>
>
>
> --
> Thorsten Wilms
>
> thorwil's design for free software:
> http://thorwil.wordpress.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+unsubscribe@**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: Literate programming

2011-10-28 Thread daly
On Fri, 2011-10-28 at 11:59 +0200, Tassilo Horn wrote:
> Hi Tim,
> 
> while I agree that good documentation is important for maintaining and
> developing further a given code base, I always wonder how literate
> programming deals with refactoring and larger restructuring.  I mean, in
> basically all software projects I'm involved in, developers have a hard
> time in keeping at least the most integral documentation up-to-date,
> e.g., docstrings, JavaDocs, etc.
> 
> Now I consider a some literate code base, i.e., a book that describes
> the complete system in a very detailed manner including the reasons to
> design it that way.  That's awesome for developers joining the project,
> but doesn't it hinder any further development?
> 
> For example, I'm currently reworking some paper that includes code for
> some model transformation.  If I had the right tools, I could extract
> the source code from the latex files and have a running transformation.
> But now, I had to do some minor modifications to the code which took me
> about 5 minutes, but adapting the surrounding text takes me hours over
> hours.  I think, that's an experience many people have made: changing
> source code of a system that is well-designed and understood by the
> developer is much easier to do than changing a cohesive text in natural
> language.  In code, I have an automated, picky lector that always reads
> the complete "book" after each change I make (also known as compiler).
> In plain text, only a human can verify consistency and only in very
> narrow borders.
> 
> Well, that's more text than I intended to write. ;-) So short story
> long: how do you manage conistency of docs and code in literate code
> bases?

Hard work? Book authors face the same problem. Every new change to
Clojure makes more work for the authors.

One side-effect of Literate Programming is that you re-arrange your
code to fit the presentation. As a result you bring together chunks
that are all related (e.g. the code to support Red-Black tries).

I would claim that refactoring "in the large" is unlikely in a
literate program because you have to think through the code in order
to explain it clearly. But if you do a large refactor then it is 
just hard work. For small refactorings you might not have to change
the explanation at all.

Clojure is pretty well "firmed up" at this point. I don't know if
there is going to be a large rewrite of the fundamentals.

Tim Daly


-- 
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: ultra-noob read-line question

2011-10-28 Thread Phil Hagelberg
On Fri, Oct 28, 2011 at 6:54 AM, Andrew  wrote:
> I should be more specific. I see the exception only with trampoline.
>
> Exception in thread "main" java.lang.IllegalArgumentException: No
> implementation of method: :make-writer of protocol:
> #'clojure.java.io/IOFactory found for class: nil (NO_SOURCE_FILE:0)

It probably means something like *out* is nil. The trampoline task is
still pretty new; if you have a simple repro case could you open a bug
report for it?

-Phil

-- 
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: Literate programming

2011-10-28 Thread Mark Engelberg
On Thu, Oct 27, 2011 at 10:58 AM, daly  wrote:
>> Have there been any new developments on the literate programming /
>> Clojure front, in terms of tools that leverage existing build tools,
>> test suites, generating meaningful line numbers for stack traces and
>> debugging?
>>
>
> The question is ill-posed in sense that literate programming is not
> a tool or technology but a change in mindset. To quote Knuth:

I think my question is legitimate.

To take an extreme example, if you tell me literate programming is
great, but that I have to write out my programs by hand on paper and
scan them into a computer, I'd laugh at you.  Why would I want to give
up the convenience of typing in my programs via keyboard to do
literate programming?

So I'd like an honest appraisal of the state of the art in literate
programming of Clojure -- what tools and conveniences do I have to
give up to do LP.  Do I have to give up things like meaningful line
numbers when I get an error message?

-- 
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


Final field optimizations

2011-10-28 Thread Gary Trakhman
It looks like this would be relevant to Clojure, seeing as we use final 
fields all over the place, anyone have any ideas about it?

http://www.azulsystems.com/blog/cliff/2011-10-27-final-fields-part-2

-- 
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

Dynamic test creation?

2011-10-28 Thread AndyK
I am setting up tests with clojure.test that are driven by a CSV where
each line represents one test case. Right now, there is a single
deftest function that runs all the assertions. That's ok but creates
reporting like 1 test was run with 1000s of assertions. Clojure being
so dynamic, is it possible to create tests on-the-fly and run them
where each dynamic test represents each row so that the reporting says
X tests (where X == number of CSV rows).

I'm fairly new to clojure and quite unfamiliar with the ins-and-outs
of clojure.test.
Any pointers here would be appreciated.

Thank you

-- 
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


Lazytest on the repl?

2011-10-28 Thread AndyK
How can lazytest describe blocks be run from the repl?

-- 
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


Pallet meetup during conj

2011-10-28 Thread Hugo Duncan

Hi all,

There will be an informal gathering of pallet users during the conj. Come
and talk with us, whether your just wondering what pallet can do, want to
hear how others are using pallet, if you have feedback and comments for
improving pallet, or you just want to say hello!

RSVP here: http://www.meetup.com/Pallet-Users-Group/events/38415062/

Apologies if this is seen as OT, but we started a meetup group [1] for
this before the extracurricular spreadsheet appeared, and want to reach
pallet users who are on this list.

Looking forward to meeting you at the conj!

--
Hugo Duncan

[1] http://www.meetup.com/Pallet-Users-Group

--
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


Trickiness with protocols and extends (1.3.0)

2011-10-28 Thread Howard Lewis Ship
I'm hitting a bit of frustration with (defprotocol) and friends and
I'm hoping someone can enlighten me:

Context: this is part of the Cascade layer I'm building on top of
Compojure. It's all about rendering markup, borrowing ideas from
Tapestry.

I have a protocol that represents Assets: any kind of static resource
that can be exposed to the client via a URL, such as a JavaScript
library or stylesheet:

(defprotocol Asset
  "Represent a server-side resource so that it can be exposed
efficiently to the client."
  (^InputStream content [asset] "Returns the content of the Asset as a
stream of bytes, or null if the Asset does not exist.")
  (^String client-url [asset] "Returns an absolute URL to the Asset."))

Cascade builds a DOM tree before streaming; one step of that is to
convert attribute values inside DOM nodes into strings.

(defprotocol ToAttributeValueString
  "Converts an attribute value to a string. It is not necessary to
apply quotes (those come at a later stage)."
  (to-attribute-value-string [value]
"Converts the value to a string that can be safely streamed as an
attribute value."))

(extend-protocol ToAttributeValueString
  String
  (to-attribute-value-string [string] (encode-string string))

  Number
  (to-attribute-value-string [num] (.toString num))

  Keyword
  (to-attribute-value-string [kw] (encode-string (name kw


Now, I want Assets to be used as attribute values, so:

(extend-type Asset
  ToAttributeValueString
  (to-attribute-value-string [asset] (:client-url asset)))

But this fails with:

Exception in thread "main" java.lang.IllegalArgumentException: Unable
to resolve classname: Asset, compiling:(cascade.clj:84)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6416)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6397)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyze(Compiler.java:6177)
at clojure.lang.Compiler$MapExpr.parse(Compiler.java:2782)
at clojure.lang.Compiler.analyze(Compiler.java:6224)
at clojure.lang.Compiler.analyze(Compiler.java:6177)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3503)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6411)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyze(Compiler.java:6177)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5572)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5008)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3629)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6407)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.eval(Compiler.java:6462)
at clojure.lang.Compiler.load(Compiler.java:6902)
at clojure.lang.RT.loadResourceScript(RT.java:357)
at clojure.lang.RT.loadResourceScript(RT.java:348)
at clojure.lang.RT.load(RT.java:427)
at clojure.lang.RT.load(RT.java:398)
at clojure.core$load$fn__4610.invoke(core.clj:5386)
at clojure.core$load.doInvoke(core.clj:5385)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5200)
at clojure.core$load_lib.doInvoke(core.clj:5237)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:602)
at clojure.core$load_libs.doInvoke(core.clj:5271)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:604)
at clojure.core$use.doInvoke(core.clj:5363)
at clojure.lang.RestFn.invoke(RestFn.java:436)
at main$eval3$loading__4505__auto4.invoke(main.clj:1)
at main$eval3.invoke(main.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6465)
at clojure.lang.Compiler.eval(Compiler.java:6455)
at clojure.lang.Compiler.load(Compiler.java:6902)
at clojure.lang.Compiler.loadFile(Compiler.java:6863)
at clojure.main$load_script.invoke(main.clj:282)
at clojure.main$script_opt.invoke(main.clj:342)
at clojure.main$main.doInvoke(main.clj:426)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:401)
at clojure.lang.AFn.applyToHelper(AFn.java:161)
at clojure.lang.Var.applyTo(Var.java:518)
at clojure.main.main(main.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.IllegalArgumentException: Unable to resolve
classname: Asset
at 

Re: Lazytest on the repl?

2011-10-28 Thread Stuart Sierra
Each `describe` block creates a Var with a gensym'd name. By examining Var 
metadata, you could find them.

But they're not callable functions like clojure.test.

-S

-- 
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: Trickiness with protocols and extends (1.3.0)

2011-10-28 Thread David Powell
On Fri, Oct 28, 2011 at 6:46 PM, Howard Lewis Ship  wrote:

>From my perspective, defprotocol appears to create a name (in the
> current namespace) as well as a Java interface (the real type). It
> feels to me like I should be able to pass either the interface or the
> protocol into extend-type and have it Just Work. Is there some concern
> I'm missing here? Thoughts?#


I think the problem is that you are trying to extend one protocol to another
protocol.  I don't think you are supposed to do this.  For one, it would
only work against deftypes that had compile-time support for the protocol
(ie that physically implemented the interfaces), and would fail for deftypes
and other instances that implemented the protocol dynamically.

I think protocols are designed to be orthogonal, and you should just extend
both protocols to the class.

-- 
Dave

-- 
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 Conj extracurricular activities spreadsheet

2011-10-28 Thread blcooley


On Oct 27, 5:41 pm, Daniel Solano Gomez  wrote:
>
> I'd like to propose a new activity: Android.  It'd be more of a hack and
> chat about doing Android development in Clojure.  Some things to talk
> about could include creating Clojure-friendly tools for Android
> development and perhaps the possibility of an Android contrib module.
>
> Thanks,
>
> Daniel Solano Gómez
>


I would definitely attend an Android activity.

-- 
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 Conj extracurricular activities spreadsheet

2011-10-28 Thread Gary Trakhman
Please add me to:

clojurescript
core.logic
the web and clojure

-- 
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: Literate programming

2011-10-28 Thread daly
On Fri, 2011-10-28 at 09:54 -0700, Mark Engelberg wrote:
> On Thu, Oct 27, 2011 at 10:58 AM, daly  wrote:
> >> Have there been any new developments on the literate programming /
> >> Clojure front, in terms of tools that leverage existing build tools,
> >> test suites, generating meaningful line numbers for stack traces and
> >> debugging?
> >>
> >
> > The question is ill-posed in sense that literate programming is not
> > a tool or technology but a change in mindset. To quote Knuth:
> 
> I think my question is legitimate.
> 
> To take an extreme example, if you tell me literate programming is
> great, but that I have to write out my programs by hand on paper and
> scan them into a computer, I'd laugh at you.  Why would I want to give
> up the convenience of typing in my programs via keyboard to do
> literate programming?

I'm not sure what tools you use for development. Straight emacs is
sufficient for my development. Emacs doesn't care what style is used
for development.

> 
> So I'd like an honest appraisal of the state of the art in literate
> programming of Clojure -- what tools and conveniences do I have to
> give up to do LP.  Do I have to give up things like meaningful line
> numbers when I get an error message?
> 

State of the art in literate programming in Clojure?

Hmmm. The pamphlet link is my only example of literate programming
related to Clojure. In order to develop you edit the pamphlet, type
"make" at a command line, and the world is rebuilt. Since the code is
extracted into the same source tree as it originally had, the line
numbers will be related to the file and line as before.

My development style involves changing about 10 lines of code or less
followed by a complete system rebuild and test cycle. Overlapping
rebuild and test is time for writing the literate explanations. 
Almost always, when something fails it is perfectly clear what lines
caused the error. When that isn't the case then a little "navel
debugging" (contemplating what might be wrong) is used. 

I don't use IDEs but I suppose it would be possible to write a
literate plugin of some kind that ignored things that were not in
code chunks. Line numbers could then be interpreted with respect
to the start of the chunk. Most IDEs allow plugins.

To your point, though, it is true that we may have reached a local
optimum of tool development for tiny files. It might be necessary
to move away from this peak in order to climb a different hill.
This would imply making things "worse" for development until the
tools adapt. Clojure moved off the local optimum of common lisp
and broke all my code-walking software, violated quite a few of my
assumptions, and invalidated my manuals but that isn't an argument
for abandoning Clojure.

You might feel that the current toolset is optimal and that
literate programming is not worth the time and effort.
De gustibus non disputandum. (There is no disputing taste).

A literate Clojure would only be of benefit to those who come after.
All it offers now is a lot of time and effort to communicate ideas
to people we will never meet. However the thing that draws people
to Clojure is the ideas, not the code.

We can debate it at length over beers at the Conj.

Tim Daly

-- 
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: Trickiness with protocols and extends (1.3.0)

2011-10-28 Thread Alex Miller
Howard, I didn't read all of your post because frankly, I'm lazy, but
David is correct that you will run into difficulties with hot protocol
on protocol action.  However, I personally think there are excellent
reasons for wanting to extend protocols on protocols and fellow
Revelytix-ian David McNeil developed a technique to do so and
documented it here:

http://david-mcneil.com/post/3495351254/clojure-protocol-adapters
https://github.com/david-mcneil/clojure-adapt

There was a discussion about this on -dev at one point and David
offered the code if someone wanted to put it in contrib but there was
strong apathy for doing so.

Alex





On Oct 28, 2:38 pm, David Powell  wrote:
> On Fri, Oct 28, 2011 at 6:46 PM, Howard Lewis Ship  wrote:
>
> From my perspective, defprotocol appears to create a name (in the
>
> > current namespace) as well as a Java interface (the real type). It
> > feels to me like I should be able to pass either the interface or the
> > protocol into extend-type and have it Just Work. Is there some concern
> > I'm missing here? Thoughts?#
>
> I think the problem is that you are trying to extend one protocol to another
> protocol.  I don't think you are supposed to do this.  For one, it would
> only work against deftypes that had compile-time support for the protocol
> (ie that physically implemented the interfaces), and would fail for deftypes
> and other instances that implemented the protocol dynamically.
>
> I think protocols are designed to be orthogonal, and you should just extend
> both protocols to the class.
>
> --
> Dave

-- 
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 Conj extracurricular activities spreadsheet

2011-10-28 Thread Federico Brubacher
Pleas add me to

Clojurescript
Heroku drinkup

On Fri, Oct 28, 2011 at 6:06 PM, Gary Trakhman wrote:

> Please add me to:
>
> clojurescript
> core.logic
> the web and clojure
>
> --
> 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
>



-- 
Federico Brubacher
@fbru02

-- 
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: clojurescript: generating the JavaScript on the fly?

2011-10-28 Thread Gary Trakhman
This is how the browser repl works, though I don't know if it's something 
to be used in production.   Check out: 
https://github.com/clojure/clojurescript/tree/master/samples/repl

-- 
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

ClojureScript interop

2011-10-28 Thread David Powell
I'm struggling at getting started in ClojureScript.

One problem I have:

I don't have to look far in Closure before I find an API like this:

http://closure-library.googlecode.com/svn/docs/class_goog_dom_DomHelper.html#goog.dom.DomHelper.prototype.createDom

that takes a JavaScript name/value object/map.  Is there an easy way to
construct a JavaScript object like this, eg from a ClojureScript map?  I
couldn't see anything, but this seems like an important thing.  If there
isn't one yet, can we expect one, or are there some issues?


Also, how do people go about writing a Closure app.  Do people make their
own UI components?  Is that easy to do in ClojureScript?

-- 
Dave

-- 
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: ClojureScript interop

2011-10-28 Thread David Nolen
There's a ticket, http://dev.clojure.org/jira/browse/CLJS-37

However things get fixed faster if you submit a patch ;) If you're excited
about ClojureScript, then consider submitting a CA and helping out.

David

On Fri, Oct 28, 2011 at 6:58 PM, David Powell  wrote:

>
> I'm struggling at getting started in ClojureScript.
>
> One problem I have:
>
> I don't have to look far in Closure before I find an API like this:
>
>
> http://closure-library.googlecode.com/svn/docs/class_goog_dom_DomHelper.html#goog.dom.DomHelper.prototype.createDom
>
> that takes a JavaScript name/value object/map.  Is there an easy way to
> construct a JavaScript object like this, eg from a ClojureScript map?  I
> couldn't see anything, but this seems like an important thing.  If there
> isn't one yet, can we expect one, or are there some issues?
>
>
> Also, how do people go about writing a Closure app.  Do people make their
> own UI components?  Is that easy to do in ClojureScript?
>
> --
> Dave
>
>  --
> 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: Clojure Conj extracurricular activities spreadsheet

2011-10-28 Thread lance bradley
I will be at the tooling and heroku discussions, packing heat

On Oct 28, 3:07 pm, Federico Brubacher  wrote:
> Pleas add me to
>
> Clojurescript
> Heroku drinkup
>
> On Fri, Oct 28, 2011 at 6:06 PM, Gary Trakhman wrote:
>
>
>
>
>
>
>
>
>
> > Please add me to:
>
> > clojurescript
> > core.logic
> > the web and clojure
>
> > --
> > 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
>
> --
> Federico Brubacher
> @fbru02

-- 
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: ClojureScript interop

2011-10-28 Thread David Nolen
I added the compiler macros to make this work in a branch:
https://github.com/clojure/clojurescript/compare/37-support-for-js-literals

Feedback appreciated.

David

On Fri, Oct 28, 2011 at 7:04 PM, David Nolen  wrote:

> There's a ticket, http://dev.clojure.org/jira/browse/CLJS-37
>
> However things get fixed faster if you submit a patch ;) If you're excited
> about ClojureScript, then consider submitting a CA and helping out.
>
> David
>
> On Fri, Oct 28, 2011 at 6:58 PM, David Powell  wrote:
>
>>
>> I'm struggling at getting started in ClojureScript.
>>
>> One problem I have:
>>
>> I don't have to look far in Closure before I find an API like this:
>>
>>
>> http://closure-library.googlecode.com/svn/docs/class_goog_dom_DomHelper.html#goog.dom.DomHelper.prototype.createDom
>>
>> that takes a JavaScript name/value object/map.  Is there an easy way to
>> construct a JavaScript object like this, eg from a ClojureScript map?  I
>> couldn't see anything, but this seems like an important thing.  If there
>> isn't one yet, can we expect one, or are there some issues?
>>
>>
>> Also, how do people go about writing a Closure app.  Do people make their
>> own UI components?  Is that easy to do in ClojureScript?
>>
>> --
>> Dave
>>
>>  --
>> 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: Trickiness with protocols and extends (1.3.0)

2011-10-28 Thread Nicolas
Hi !

For clojure, a type or a record, represent data. A protocol represent
a set of linked polymorph functions. But protocol themselves are not
types. Just grouped functions. The types is what they apply on. Not
what they are themselves.

You can view each method of a protocol like a big swich function that
test the type of it first argument and choose the right implementation
of the function depending of the type of this first argument.

Type can be extended to support a protocol. By doing that you define
the call that will be called when you call the protocol function with
a first parameter of the extended type. Type is a record or a type.
For java interop support, it can be also any java class/interface.

Clojure intentionnaly avoid support for inheritence. A record/type
can't inherit from another record/type. And protocol can't be extended
to another protocol. Because in clojure this would made no sence. A
function can't inherit from another function.

This is by design. Clojure avoid to support inheritence for clojure
concepts. It only support for java interop because this might be
needed for interfacing with an existing java library (Like swing
listeners).

In your example, extending cascade.Asset work because it is considered
as a java interface, and is supported for interoperability. But this
is likely not what you really want to do as Asset is still not a
clojure type.

Hope this help,

Nicolas

On 28 oct, 19:46, Howard Lewis Ship  wrote:
> I'm hitting a bit of frustration with (defprotocol) and friends and
> I'm hoping someone can enlighten me:
>
> Context: this is part of the Cascade layer I'm building on top of
> Compojure. It's all about rendering markup, borrowing ideas from
> Tapestry.
>
> I have a protocol that represents Assets: any kind of static resource
> that can be exposed to the client via a URL, such as a JavaScript
> library or stylesheet:
>
> (defprotocol Asset
>   "Represent a server-side resource so that it can be exposed
> efficiently to the client."
>   (^InputStream content [asset] "Returns the content of the Asset as a
> stream of bytes, or null if the Asset does not exist.")
>   (^String client-url [asset] "Returns an absolute URL to the Asset."))
>
> Cascade builds a DOM tree before streaming; one step of that is to
> convert attribute values inside DOM nodes into strings.
>
> (defprotocol ToAttributeValueString
>   "Converts an attribute value to a string. It is not necessary to
> apply quotes (those come at a later stage)."
>   (to-attribute-value-string [value]
>     "Converts the value to a string that can be safely streamed as an
> attribute value."))
>
> (extend-protocol ToAttributeValueString
>   String
>   (to-attribute-value-string [string] (encode-string string))
>
>   Number
>   (to-attribute-value-string [num] (.toString num))
>
>   Keyword
>   (to-attribute-value-string [kw] (encode-string (name kw
>
> Now, I want Assets to be used as attribute values, so:
>
> (extend-type Asset
>   ToAttributeValueString
>   (to-attribute-value-string [asset] (:client-url asset)))
>
> But this fails with:
>
> Exception in thread "main" java.lang.IllegalArgumentException: Unable
> to resolve classname: Asset, compiling:(cascade.clj:84)
>         at clojure.lang.Compiler.analyzeSeq(Compiler.java:6416)
>         at clojure.lang.Compiler.analyze(Compiler.java:6216)
>         at clojure.lang.Compiler.analyzeSeq(Compiler.java:6397)
>         at clojure.lang.Compiler.analyze(Compiler.java:6216)
>         at clojure.lang.Compiler.analyze(Compiler.java:6177)
>         at clojure.lang.Compiler$MapExpr.parse(Compiler.java:2782)
>         at clojure.lang.Compiler.analyze(Compiler.java:6224)
>         at clojure.lang.Compiler.analyze(Compiler.java:6177)
>         at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3503)
>         at clojure.lang.Compiler.analyzeSeq(Compiler.java:6411)
>         at clojure.lang.Compiler.analyze(Compiler.java:6216)
>         at clojure.lang.Compiler.analyze(Compiler.java:6177)
>         at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5572)
>         at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5008)
>         at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3629)
>         at clojure.lang.Compiler.analyzeSeq(Compiler.java:6407)
>         at clojure.lang.Compiler.analyze(Compiler.java:6216)
>         at clojure.lang.Compiler.eval(Compiler.java:6462)
>         at clojure.lang.Compiler.load(Compiler.java:6902)
>         at clojure.lang.RT.loadResourceScript(RT.java:357)
>         at clojure.lang.RT.loadResourceScript(RT.java:348)
>         at clojure.lang.RT.load(RT.java:427)
>         at clojure.lang.RT.load(RT.java:398)
>         at clojure.core$load$fn__4610.invoke(core.clj:5386)
>         at clojure.core$load.doInvoke(core.clj:5385)
>         at clojure.lang.RestFn.invoke(RestFn.java:408)
>         at clojure.core$load_one.invoke(core.clj:5200)
>         at clojure.core$load_lib.doInvoke(core.clj:5237)
>         at clojure

Re: Literate programming

2011-10-28 Thread Stefan Kamphausen


Clojure moved off the local optimum of common lisp
>

I can't help, but I really like that quote.  Nice meme :-) 

Stefan

-- 
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: Trickiness with protocols and extends (1.3.0)

2011-10-28 Thread David McNeil


On Oct 28, 12:46 pm, Howard Lewis Ship  wrote:
> (extend-type Asset
>   ToAttributeValueString
>   (to-attribute-value-string [asset] (:client-url asset)))

As Alex mentioned we have an "adapt-protocol" macro [1] [2] that I
think will do what you want. It would be invoked as:

(adapt-protocol Asset
  ToAttributeValueString
  (to-attribute-value-string [asset] (client-url asset)))

>From your original code, I changed "extend-type" to "adapt-protocol"
and I fixed what I think is a type by changing ":client-url" to
"client-url".

There are different ways to think of what this does. One way is to
think of adapting one protocol to another. The adapt-protocol call
defines how to adapt an Asset object to an ToAttributeValueString
object.

Another way is to think of layering the protocols. The
ToAttributeValueString protocol is layered on top of the Asset
protocol by defining how to satisfy the ToAttributeValueString
protocol in terms of the Asset protocol.

At a lower level what this adapt-protocol call means is: for any type
that implements Asset but does not already implement
ToAttributeValueString, add an implementation of Asset to that type
using the provided functions. This implementation will be added the
first time that an attempt is made to access the type via the
ToAttributeValueString protocol. It is useful to be able to define
this in one place rather than tracking down all of the types that
implement the Asset protocol and extending them to support the
ToAttributeValueString protocol.

I don't think it is useful to try and think of this as interface
inheritance because it is not the same as interface inheritance in
Java.

We are using this code in production to do exactly what you described.
The only real issue to be aware of is that once an adapter is
“installed” for a class subsequent calls to adapt-protocol do not
affect the class. This can cause pain at dev time when you are
changing the adapter code and want to dynamically redefine an adapter.
I talk about this issue and a way to address it at dev time in the
blog post [1].

-David

[1] http://david-mcneil.com/post/3495351254/clojure-protocol-adapters
[2] https://github.com/david-mcneil/clojure-adapt

-- 
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 Conj extracurricular activities spreadsheet

2011-10-28 Thread ffailla
Put me down for:

ClojureScript
core.logic

Thanks!

Frank Failla

On Oct 25, 12:11 pm, Fogus  wrote:
> All,
>
> We talked about the possibility of getting some ideas about
> extracurricular activities during the Conj days (and possibly training
> days).  I've created a spreadsheet at the link below to collect
> ideas.  It is not my intention to be the organizer of these
> activities.  Instead, if you have an idea then please be prepared to
> own it.  The matter of space for these activities would need to be
> worked out by Conj planners or activity organizers, but having a list
> would help that process.
>
> https://docs.google.com/spreadsheet/ccc?key=0Alim_jfrt24MdDFqZVZsNW0t...
>
> I've entered an example, feel free to add your own ideas. :-)
>
> This should be epic.

-- 
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