Re: Execute a string containing a form?

2010-04-22 Thread Mike Mazur
Hi,

On Thu, Apr 22, 2010 at 20:17, Base basselh...@gmail.com wrote:
 say i have a string that contains a form:

 (+ 1 1)

 I want to actually execute this.  How do you do this?  I thought that
 eval would be able to handle this but apparently am misunderstanding
 what eval does.

You need to read the string first:

user= (read-string (+ 1 1))
(+ 1 1)
user= (eval (read-string (+ 1 1)))
2

Mike

-- 
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: Execute a string containing a form?

2010-04-22 Thread Tassilo Horn
On Thursday 22 April 2010 14:17:15 Base wrote:

Hi!

 say i have a string that contains a form:
 
 (+ 1 1)
 
 I want to actually execute this.  How do you do this?  I thought that
 eval would be able to handle this but apparently am misunderstanding
 what eval does.

`eval' evals a form, so first you have to parse that string.  But that's
exactly what `read-string' does:

,
| user (read-string (+ 1 2))
| (+ 1 2)
| user (eval (read-string (+ 1 2)))
| 3
`

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: Execute a string containing a form?

2010-04-22 Thread Douglas Philips

On 2010 Apr 22, at 8:17 AM, Base wrote:

say i have a string that contains a form:

(+ 1 1)

I want to actually execute this.  How do you do this?  I thought that
eval would be able to handle this but apparently am misunderstanding
what eval does.


Well, eval is the second half of what you want.
eval evaluates a form.
user= (read-string (+ 1 1))
(+ 1 1)
user= (eval (read-string (+ 1 1)))
2

eval can be a dangerous thing to use, you have to be very careful  
about where the source has come from, in terms of trusting that the  
code your programs 'eval's will not be malicious or dangerous in some  
way. There are no absolute rules for this, it depends on your  
application.



read can also be a dangerous thing to use, as per the doc on *read- 
eval* quoted here:

clojure.core/*read-eval*
nil
  When set to logical false, the EvalReader (#=(...)) is disabled in  
the

  read/load in the thread-local binding.
  Example: (binding [*read-eval* false] (read-string #=(eval (def x  
3


  Defaults to true

(Note to doc folks, #= does not seem to be described on: http://clojure.org/reader 
 with the other # reader macros.)


-Doug

--
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: Execute a string containing a form?

2010-04-22 Thread Base
Thank you all!

I knew there was something simple that i was missing!

On Apr 22, 7:28 am, Douglas Philips d...@mac.com wrote:
 On 2010 Apr 22, at 8:17 AM, Base wrote:

  say i have a string that contains a form:

  (+ 1 1)

  I want to actually execute this.  How do you do this?  I thought that
  eval would be able to handle this but apparently am misunderstanding
  what eval does.

 Well, eval is the second half of what you want.
 eval evaluates a form.
 user= (read-string (+ 1 1))
 (+ 1 1)
 user= (eval (read-string (+ 1 1)))
 2

 eval can be a dangerous thing to use, you have to be very careful  
 about where the source has come from, in terms of trusting that the  
 code your programs 'eval's will not be malicious or dangerous in some  
 way. There are no absolute rules for this, it depends on your  
 application.

 read can also be a dangerous thing to use, as per the doc on *read-
 eval* quoted here:
 clojure.core/*read-eval*
 nil
    When set to logical false, the EvalReader (#=(...)) is disabled in  
 the
    read/load in the thread-local binding.
    Example: (binding [*read-eval* false] (read-string #=(eval (def x  
 3

    Defaults to true

 (Note to doc folks, #= does not seem to be described 
 on:http://clojure.org/reader
   with the other # reader macros.)

 -Doug

 --
 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 
 athttp://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: Slides for short (45 minutes) presentation of clojure for java devs

2010-04-22 Thread Laurent PETIT
Oh, really no answer ? :'(

2010/4/21 Laurent PETIT laurent.pe...@gmail.com:
 Hello,

 I've consulted a lot of already made presentations of clojure.
 They are great, but I guess they may not suit my needs because it
 seems to me that either:
  * they are more 1 1/2 to 2 hours talks than 45 minutes
  * they assume the public will not be relunctant to some terms like
 Lisp, Functional Programming and directly present these as
 advantages

 My goal is to raise interest into clojure in the mind of a public of
 people having used java for a long time. They may have Scala already
 in their radar, but not clojure, or may have seen it and immediately
 dismissed it for what seemed to them good reasons (mainly aversion for
 lisp syntax), though we all know this is not true after the normal
 adaptation period.

 Say this presentation could be the presentation that leads people, at
 its end, asking you for giving all those great other presentations
 already available that I mentioned before ...

 Any references I missed that already solve my problem ? :-)

 Thanks in advance,

 --
 Laurent


-- 
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: Slides for short (45 minutes) presentation of clojure for java devs

2010-04-22 Thread Joop Kiefte
I made one simple and short one for beginners, I think to your liking, but
in Dutch...

2010/4/22 Laurent PETIT laurent.pe...@gmail.com

 Oh, really no answer ? :'(

 2010/4/21 Laurent PETIT laurent.pe...@gmail.com:
  Hello,
 
  I've consulted a lot of already made presentations of clojure.
  They are great, but I guess they may not suit my needs because it
  seems to me that either:
   * they are more 1 1/2 to 2 hours talks than 45 minutes
   * they assume the public will not be relunctant to some terms like
  Lisp, Functional Programming and directly present these as
  advantages
 
  My goal is to raise interest into clojure in the mind of a public of
  people having used java for a long time. They may have Scala already
  in their radar, but not clojure, or may have seen it and immediately
  dismissed it for what seemed to them good reasons (mainly aversion for
  lisp syntax), though we all know this is not true after the normal
  adaptation period.
 
  Say this presentation could be the presentation that leads people, at
  its end, asking you for giving all those great other presentations
  already available that I mentioned before ...
 
  Any references I missed that already solve my problem ? :-)
 
  Thanks in advance,
 
  --
  Laurent
 

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




-- 
Communication is essential. So we need decent tools when communication is
lacking, when language capability is hard to acquire...

- http://esperanto.net  - http://esperanto-jongeren.nl

Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004

-- 
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: Slides for short (45 minutes) presentation of clojure for java devs

2010-04-22 Thread Laurent PETIT
2010/4/22 Joop Kiefte iko...@gmail.com:
 I made one simple and short one for beginners, I think to your liking, but
 in Dutch...

too bad I don't speak Dutch :-(


 2010/4/22 Laurent PETIT laurent.pe...@gmail.com

 Oh, really no answer ? :'(

 2010/4/21 Laurent PETIT laurent.pe...@gmail.com:
  Hello,
 
  I've consulted a lot of already made presentations of clojure.
  They are great, but I guess they may not suit my needs because it
  seems to me that either:
   * they are more 1 1/2 to 2 hours talks than 45 minutes
   * they assume the public will not be relunctant to some terms like
  Lisp, Functional Programming and directly present these as
  advantages
 
  My goal is to raise interest into clojure in the mind of a public of
  people having used java for a long time. They may have Scala already
  in their radar, but not clojure, or may have seen it and immediately
  dismissed it for what seemed to them good reasons (mainly aversion for
  lisp syntax), though we all know this is not true after the normal
  adaptation period.
 
  Say this presentation could be the presentation that leads people, at
  its end, asking you for giving all those great other presentations
  already available that I mentioned before ...
 
  Any references I missed that already solve my problem ? :-)
 
  Thanks in advance,
 
  --
  Laurent
 

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


 --
 Communication is essential. So we need decent tools when communication is
 lacking, when language capability is hard to acquire...

 - http://esperanto.net  - http://esperanto-jongeren.nl

 Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004

 --
 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: Slides for short (45 minutes) presentation of clojure for java devs

2010-04-22 Thread Laurent PETIT
Could I still take a look at it, to see the kind of examples you
provided (are the source code examples in english ?)

2010/4/22 Laurent PETIT laurent.pe...@gmail.com:
 2010/4/22 Joop Kiefte iko...@gmail.com:
 I made one simple and short one for beginners, I think to your liking, but
 in Dutch...

 too bad I don't speak Dutch :-(


 2010/4/22 Laurent PETIT laurent.pe...@gmail.com

 Oh, really no answer ? :'(

 2010/4/21 Laurent PETIT laurent.pe...@gmail.com:
  Hello,
 
  I've consulted a lot of already made presentations of clojure.
  They are great, but I guess they may not suit my needs because it
  seems to me that either:
   * they are more 1 1/2 to 2 hours talks than 45 minutes
   * they assume the public will not be relunctant to some terms like
  Lisp, Functional Programming and directly present these as
  advantages
 
  My goal is to raise interest into clojure in the mind of a public of
  people having used java for a long time. They may have Scala already
  in their radar, but not clojure, or may have seen it and immediately
  dismissed it for what seemed to them good reasons (mainly aversion for
  lisp syntax), though we all know this is not true after the normal
  adaptation period.
 
  Say this presentation could be the presentation that leads people, at
  its end, asking you for giving all those great other presentations
  already available that I mentioned before ...
 
  Any references I missed that already solve my problem ? :-)
 
  Thanks in advance,
 
  --
  Laurent
 

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


 --
 Communication is essential. So we need decent tools when communication is
 lacking, when language capability is hard to acquire...

 - http://esperanto.net  - http://esperanto-jongeren.nl

 Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004

 --
 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: Documentation (was: Re: duck-streams missing from clojure-contrib.jar file)

2010-04-22 Thread Alex Osborne
Douglas Philips d...@mac.com writes:

 Looking at the clojure.org front page, there is no roadmap link, or
 anything that seems to be like that, to know what is on the radar,

There's no formal roadmap as such, most open-source projects just don't
tend to work that way.

Working notes and ideas are often posted in the assembla wiki, which
should give you a reasonable idea of the larger things that are possibly
upcoming. 

http://www.assembla.com/spaces/clojure/wiki

There's also a todo list which is good for getting a feel of
Rich's long term intentions.  Be aware that these are Rich's ideas, not
a plan as such and some of them may have even already been scrapped
(like streams).

http://clojure.org/todo

 bouncing around, I eventually found:
 http://www.assembla.com/spaces/clojure/milestones/149827-release-1-2
 and it seems that there are only a handful of issues to be resolved
 before 1.2 is cut?

The assembla milestone is probably fairly indicative, but not
exhaustive.  The impression I have is also that there's not a huge
amount more going into 1.2, mainly finishing off the last little bits
and testing what's already been put in.

As you probably know the most high profile addition to 1.2 are datatypes
and protocols.  Rich yesterday posted some new documentation on them.
They've been revised quite a bit since the initial announcement, so the
new documents are worth a look:

http://clojure.org/datatypes
http://clojure.org/protocols

 Maybe I missed some other link(s) that would show a higher level view
 of what is planned?

A lot of discussion happens on the clojure-dev group and through IRC
(#clojure on freenode).  You'll need to have submitted a CA to join 
the dev group, but everyone can read it through the web interface:

http://groups.google.com/group/clojure-dev

For example, the discussion about some of the renaming happening in
contrib is in these threads:

http://groups.google.com/group/clojure-dev/browse_thread/thread/d7ada6ee885aa9d4
http://groups.google.com/group/clojure-dev/browse_thread/thread/49068754a8c2efb9
http://groups.google.com/group/clojure-dev/browse_thread/thread/b4acea9c95a9cfe9

-- 
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: Which version of Netbeans to use Compojure on OSX?

2010-04-22 Thread gary ng
I would choose the one with glassfish which includes the web app things that
even though you may not need immediately(if compojure comes with embedded
jetty) will be very likely in the future when you use other app
containers(be it GAE or tomcat etc.)

I picked the base Java SE version and needs to add the web application stuff
back later because I am working on project to push to GAE.

BTW, there is no web application support in enclojure.

On Wed, Apr 21, 2010 at 4:55 PM, Sophie itsme...@hotmail.com wrote:

 I see downloads named
  - Java SE (45MB)
  - Java FX (76MB)
  - Java (146MB) - apparently includes Sun Glassfish Server  what-not

 I'm using OSX 10.5.8, and just want to install the easiest Netbeans
 (with Enclojure) to for development with Compojure.

 Would I use Compojure with Jetty? Apache (built into OSX)?

 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.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: Execute a string containing a form?

2010-04-22 Thread Heinz N. Gies

On Apr 22, 2010, at 14:28 , Douglas Philips wrote:
 eval can be a dangerous thing to use, you have to be very careful about where 
 the source has come from, in terms of trusting that the code your programs 
 'eval's will not be malicious or dangerous in some way. There are no absolute 
 rules for this, it depends on your application.

To do a bit advertising here, for this case there is clj-sandbox I claim it 
does a pretty good job to give a basic hassle free safety for evaluated code. 
Also if it is a string you read from you can skip the read-string part and just 
pass it the string directly.

If you want to have a look: http://github.com/Licenser/clj-sandbox
or for lein: [clj-sandbox 0.3.1]

-- 
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: duck-streams missing from clojure-contrib.jar file

2010-04-22 Thread Neal
Stu,

Good book!

It was pretty clear to me that it was a snapshot.  It was really a
user error on my part.  Now that I have made that error, I won't make
it again.

Thanks,
Neal


On Apr 21, 9:31 am, Stuart Halloway stuart.hallo...@gmail.com wrote:
 The second level header tells you the branch (e.g. master). On the  
 left hand side is a list of branches (so you can click on e.g. 1.1.x).

 Some ways I see this might be better:

 (1) make clear what master currently equals (right now it is 1.2 alpha)
 (2) highlight the branch info more with css
 (3) push the branch info into the top-level header (and page title)
 (4) The overview section for c.c.io could tell about the lineage back  
 to 1.1.

 Which of these (or what else?) would have helped you the most?

 Stu





  On 2010 Apr 21, at 8:11 AM, Alex Osborne wrote:
  I suggest you use the stable 1.1 releases of both Clojure and contrib
  for your initial learning as it will better match the book.  When  
  1.2 is
  released stable I'm sure there will be a document written that  
  explains
  the differences.

  That isn't as helpful as you might think.

  (I'm using 1.1, as conveniently provided by macports.)

  Nothing that I can find on either clojure.org or the contrib 
  sitehttp://richhickey.github.com/clojure-contrib/
   says what version it is/applies-to.

  How would I know if I'm using the stable 1.1 release that I need to  
  replace clojure.contrib.seq with clojure.contrib.seq-utils, or  
  clojure.contrib.io with clojure.contrib.duck-stream?

 http://richhickey.github.com/clojure-contrib/io-api.htmldoesn't say:
    This document applies to 1.2 (pending), for 1.1 or older see: url
  nor:
    This document applies to 1.2 (pending), it was renamed from  
  clojure.contrib.duck-stream

  --Doug

  --
  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 
 athttp://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: duck-streams missing from clojure-contrib.jar file

2010-04-22 Thread Neal
Alex,

Yes.  I was using the snapshot.  My bad.

Neal


On Apr 21, 8:11 am, Alex Osborne a...@meshy.org wrote:
 Hi Neal,

 Neal neal_degrego...@yahoo.com writes:
  I'm trying to use duck-streams, but it is missing from the clojure-
  contrib JAR file (at least in build #81).  I have listed the contents
  of the JAR file and confirmed that it is not in there.

 It sounds like you're using a 1.2 pre-release snapshot build of
 clojure-contrib.  There's currently some refactoring going on to better
 organize contrib, now that it's a little more mature.  Most of
 clojure.contrib.duck-streams has now become clojure.contrib.io.

 I suggest you use the stable 1.1 releases of both Clojure and contrib
 for your initial learning as it will better match the book.  When 1.2 is
 released stable I'm sure there will be a document written that explains
 the differences.

 I really wish the 1.1.0 release builds were more prominently linked on
 the clojure.org website, but you can download them here:

 http://build.clojure.org/releases/org/clojure/clojure/1.1.0/clojure-1...http://build.clojure.org/releases/org/clojure/clojure-contrib/1.1.0/c...

 Hope that helps,

 Alex

 --
 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 
 athttp://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: duck-streams missing from clojure-contrib.jar file

2010-04-22 Thread Neal
OK.  Thanks everyone for your help.
Neal


On Apr 21, 8:11 am, Alex Osborne a...@meshy.org wrote:
 Hi Neal,

 Neal neal_degrego...@yahoo.com writes:
  I'm trying to use duck-streams, but it is missing from the clojure-
  contrib JAR file (at least in build #81).  I have listed the contents
  of the JAR file and confirmed that it is not in there.

 It sounds like you're using a 1.2 pre-release snapshot build of
 clojure-contrib.  There's currently some refactoring going on to better
 organize contrib, now that it's a little more mature.  Most of
 clojure.contrib.duck-streams has now become clojure.contrib.io.

 I suggest you use the stable 1.1 releases of both Clojure and contrib
 for your initial learning as it will better match the book.  When 1.2 is
 released stable I'm sure there will be a document written that explains
 the differences.

 I really wish the 1.1.0 release builds were more prominently linked on
 the clojure.org website, but you can download them here:

 http://build.clojure.org/releases/org/clojure/clojure/1.1.0/clojure-1...http://build.clojure.org/releases/org/clojure/clojure-contrib/1.1.0/c...

 Hope that helps,

 Alex

 --
 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 
 athttp://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: Arguments for and et al

2010-04-22 Thread Bill Allen
I thought there might be a performance reason in there. Thanks for the
pointer to clj-time. Looks like a huge improvement over java date/calendar.

BTW: love the book. Mine is already getting dog eared.

On Apr 21, 2010 8:24 AM, Stuart Halloway stuart.hallo...@gmail.com
wrote:

The built-in Java comparison operators don't honor Comparable either.  In
Clojure, it's about keeping (pure number) math fast.

If you are doing any nontrivial date work, I recommend you look at clj-time
(http://github.com/clj-sys/clj-time), a Clojure wrapper for Joda Time. Then,
if you really want  and  to work, you can define them in your own
namespace to wrap clj-time's after? and before?.

Stu

 I've been writing a program that requires the use of java.util.Calendar
 and its descendent java.ut...
 --
 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: Missing fns: rotate rotate-while

2010-04-22 Thread Harvey Hirst
 (defn rotate [n s]
  (let [[front back] (split-at (mod n (count s)) s)]
    (concat back front)))

Don't forget (mod n 0) is an ArithmeticException.

Harvey

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


Reading from file

2010-04-22 Thread I.K.
Hi!
I'm learning Clojure and trying some Google Code Jam exercises.
I am more or less satisfied with the style of algorithms I write, but
I would like to know how to do input/output. I want it to be Clojure
style (terse/functional/efficient) not just rewriting the usual
loops...
Take a look at simplest example from io standpoint:
http://code.google.com/codejam/contest/dashboard?c=188266#.
I want the file:

3
2 3
2 3 7
9 10

turn into vector: [ [2 3] [2 3 7] [9 10] ],

and in reverse direction (produce file given above from this vector).

Show your style.

Thanks,
I.K.

-- 
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: Missing fns: rotate rotate-while

2010-04-22 Thread Sean Devlin
Oh wow... totally would have :)

On Apr 21, 8:16 pm, Harvey Hirst hhi...@gmail.com wrote:
  (defn rotate [n s]
   (let [[front back] (split-at (mod n (count s)) s)]
     (concat back front)))

 Don't forget (mod n 0) is an ArithmeticException.

 Harvey

 --
 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 
 athttp://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: Reading from file

2010-04-22 Thread Per Vognsen
How about this?

(use 'clojure.contrib.str-utils 'clojure.contrib.duck-streams)

(defn parse [file]
  (let [r (reader file)]
(map (fn [line] (map #(Integer/parseInt %) (.split line  )))
(take (Integer/parseInt (.readLine r)) (repeatedly
#(.readLine r))

(defn unparse [xss file]
  (let [w (writer file)]
(.writeLine w (str (count xss))
(doseq [xs xss]
  (.writeLine w (str-join   (map str xs)))

-Per

On Thu, Apr 22, 2010 at 1:40 AM, I.K. ignacykrasicki...@gmail.com wrote:
 Hi!
 I'm learning Clojure and trying some Google Code Jam exercises.
 I am more or less satisfied with the style of algorithms I write, but
 I would like to know how to do input/output. I want it to be Clojure
 style (terse/functional/efficient) not just rewriting the usual
 loops...
 Take a look at simplest example from io standpoint:
 http://code.google.com/codejam/contest/dashboard?c=188266#.
 I want the file:

 3
 2 3
 2 3 7
 9 10

 turn into vector: [ [2 3] [2 3 7] [9 10] ],

 and in reverse direction (produce file given above from this vector).

 Show your style.

 Thanks,
 I.K.

 --
 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: Reading from file

2010-04-22 Thread Sean Devlin
You'll want to take a look at the docs for c.c.string[1], so have that
open in another tab.  Anyway, let's assume you have the data in a file
mytext.txt

First, load the raw data with the slurp fn

user=(def raw-string (slurp mytext.txt))

Next, you'll want to use the split-lines fn to create a sequence out
of the raw-string

user=(def raw-lines (split-lines raw-string))

Now, let's consider an individual line.  We'll need to do 3 things
1. Split on whitespace - for this we'll call split.  Here's the anon.
fn:

(fn [line] (split #\s+ line))

2. Parse each number - for this we need Java interop.

(fn [line] (map #(Integer/parseInt %) (split #\s+ line)))

3. Wrap the result in a vector -simply call vec

This looks like the following:

(fn [line] (vec (map #(Integer/parseInt %) (split #\s+ line

Now, we take this operation and map it over every line

(map (fn [line] (vec (map #(Integer/parseInt %) (split #\s+ line
raw-lines)

Almost there.  We need to wrap the final call with a vec as well [3].

(def parsed-vec (vec (map (fn [line] (vec (map #(Integer/parseInt %)
(split #\s+ line raw-lines)))

That's how I would do this forward.  To do the reverse is much
simpler.  We'll need to use c.c.io [2] (formerly duck-streams).

First, we turn the vec back into a string.  This can be done easily
enough with c.c.string/join

(join \n (map #(join   %) raw-vec))

And then we just spit this into a file:

(spit output.txt (join \n (map #(join   %) raw-vec)))

And that should do it :)

HTH,
Sean

1. http://richhickey.github.com/clojure-contrib/string-api.html
2. http://richhickey.github.com/clojure-contrib/io-api.html
3. For those that have been here a while, my requisite point free
version...
(def parsed-vec (vec (map ( vec (p map #(Integer/parseInt %)) (p
split #\s+)) raw-lines)))

On Apr 21, 2:40 pm, I.K. ignacykrasicki...@gmail.com wrote:
 Hi!
 I'm learning Clojure and trying some Google Code Jam exercises.
 I am more or less satisfied with the style of algorithms I write, but
 I would like to know how to do input/output. I want it to be Clojure
 style (terse/functional/efficient) not just rewriting the usual
 loops...
 Take a look at simplest example from io 
 standpoint:http://code.google.com/codejam/contest/dashboard?c=188266#.
 I want the file:

 3
 2 3
 2 3 7
 9 10

 turn into vector: [ [2 3] [2 3 7] [9 10] ],

 and in reverse direction (produce file given above from this vector).

 Show your style.

 Thanks,
 I.K.

 --
 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 
 athttp://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: Reading from file

2010-04-22 Thread Per Vognsen
I really hate how GMail line wraps without giving you a chance to
preview before sending.

Here's a version of parse that shouldn't line wrap. It also more
closely parallels unparse by using for instead of map:

(defn parse [file]
  (let [r (reader file)]
(for [line (take (Integer/parseInt (.readLine r))
 (repeatedly #(.readLine r)))]
  (map #(Integer/parseInt %) (.split line  )

-Per

On Thu, Apr 22, 2010 at 10:29 PM, Per Vognsen per.vogn...@gmail.com wrote:
 How about this?

 (use 'clojure.contrib.str-utils 'clojure.contrib.duck-streams)

 (defn parse [file]
  (let [r (reader file)]
    (map (fn [line] (map #(Integer/parseInt %) (.split line  )))
            (take (Integer/parseInt (.readLine r)) (repeatedly
 #(.readLine r))

 (defn unparse [xss file]
  (let [w (writer file)]
    (.writeLine w (str (count xss))
    (doseq [xs xss]
      (.writeLine w (str-join   (map str xs)))

 -Per

 On Thu, Apr 22, 2010 at 1:40 AM, I.K. ignacykrasicki...@gmail.com wrote:
 Hi!
 I'm learning Clojure and trying some Google Code Jam exercises.
 I am more or less satisfied with the style of algorithms I write, but
 I would like to know how to do input/output. I want it to be Clojure
 style (terse/functional/efficient) not just rewriting the usual
 loops...
 Take a look at simplest example from io standpoint:
 http://code.google.com/codejam/contest/dashboard?c=188266#.
 I want the file:

 3
 2 3
 2 3 7
 9 10

 turn into vector: [ [2 3] [2 3 7] [9 10] ],

 and in reverse direction (produce file given above from this vector).

 Show your style.

 Thanks,
 I.K.

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


Datatypes and Protocols update

2010-04-22 Thread Rich Hickey
I have been doing some work cleaning up the design and implementation
of datatypes and protocols in preparation for the 1.2 release. Some
notable changes for those who have been working with the earlier
versions:

deftype/reify now take an explicit 'this' argument in method sigs.
The :as option is gone.

There is a new datatype construct, defrecord. defrecord includes the
implementation of persistent map, and the IPersistentMap magic of
deftype is gone.

deftype and defrecord create named classes, even in non-AOT use. There
is no factory fn created, instead you can just call the constructor.

The types for defrecord, deftype and definterface are automatically
imported into the defining namespace.

Substantial performance improvements to extend, and to higher-order
use of protocol fns.

In addition, I have started documenting these on the clojure.org site,
and you should use this documentation instead of the wiki design docs,
which will not be maintained.

http://clojure.org/protocols
http://clojure.org/datatypes

Please note that these are just higher-level descriptions, and contain
links to the detailed function docs, which are a must-read prior to
use.


Feedback and errata welcome as always,

Rich

-- 
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: Datatypes and Protocols update

2010-04-22 Thread Mark Engelberg
I tried using deftype relatively recently, but realized it wouldn't
work for my needs because serialization via *print-dup* wasn't yet
implemented.  I'd recommend including this with the 1.2 release (or is
there a new recommended way to serialize Clojure data?)

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


reducing runtime errors due to mistyped keywords

2010-04-22 Thread Istvan Devai

Hi!

In general, what to give greater attention if I'm getting lots of 
runtime errors due to mistyped keywords? (eg. I'm referencing a map 
where the keyword is non-existent and this nil value goes deep down into 
my code where it is very hard to see that this was caused by a 
non-existing map entry).


Are there some constructs that allow catching some of these errors 
compile time or ease debugging runtime?


Cheers,
Istvan

--
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: reducing runtime errors due to mistyped keywords

2010-04-22 Thread Jason Wolfe
Hi Istvan,

I've run into this a fair bit too.  To catch such problems (at
runtime), I sprinkle my code with (safe-get m :key) in key places,
rather than (:key m) or (m :key) or (get m :key).  safe-get:


(defmacro lazy-get
  Like get but lazy about evaluating default
  [m k d]
  `(if-let [pair# (find ~m ~k)]
   (val pair#)
 ~d))

(defn safe-get
  Like get but throw an exception if key not found
  [m k]
  (lazy-get m k
(throw (IllegalArgumentException.
 (format Key %s not found in %s k m)

It's not ideal though, especially since I'd imagine you won't get fast
access for new defrecords.

I think it might be nice if one could optionally make closed maps or
records, which throw when you try to get a missing key rather than
returning nil.  I'm not sure what the implications of this would be,
though.  Maybe others have more elegant solutions...

-Jason


On Apr 22, 10:43 am, Istvan Devai ist...@istvandevai.com wrote:
 Hi!

 In general, what to give greater attention if I'm getting lots of
 runtime errors due to mistyped keywords? (eg. I'm referencing a map
 where the keyword is non-existent and this nil value goes deep down into
 my code where it is very hard to see that this was caused by a
 non-existing map entry).

 Are there some constructs that allow catching some of these errors
 compile time or ease debugging runtime?

 Cheers,
 Istvan

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.To post to this group, send email 
 tocloj...@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email 
 toclojure+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://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: Datatypes and Protocols update

2010-04-22 Thread Konrad Hinsen
On 22.04.2010, at 18:53, Rich Hickey wrote:

 Feedback and errata welcome as always,

One feature in the deftype/defrecord split that I regret is that defrecord no 
longer allows the redefinition of equals and hashCode. Any attempt to override 
those results in an error message about duplicate method definitions.

I have several former deftypes that are a perfect fit for the new defrecord, 
except that they need a specific comparison function. This is usually for 
excluding some fields from equality testing, or for requiring identity rather 
than equality for some fields.

As it is, I must convert all these to the new deftype, losing the convient 
field access through keywords.

Konrad.

-- 
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: Datatypes and Protocols update

2010-04-22 Thread ataggart
On protocols:
- doc string coming after the arg vecs seems odd. I'm used to putting
them after the name of whatever I'm working on.

On protocols doc:
- You can implement a protocol on nil ... Object: could you
elaborate on how these work and/or provide examples? I think this will
solve the one problem I was running into earlier.
- given a protocol my.ns/Protocol, an interface my.ns.MyProtocol:
the final segments don't match.




On Apr 22, 9:53 am, Rich Hickey richhic...@gmail.com wrote:
 I have been doing some work cleaning up the design and implementation
 of datatypes and protocols in preparation for the 1.2 release. Some
 notable changes for those who have been working with the earlier
 versions:

 deftype/reify now take an explicit 'this' argument in method sigs.
 The :as option is gone.

 There is a new datatype construct, defrecord. defrecord includes the
 implementation of persistent map, and the IPersistentMap magic of
 deftype is gone.

 deftype and defrecord create named classes, even in non-AOT use. There
 is no factory fn created, instead you can just call the constructor.

 The types for defrecord, deftype and definterface are automatically
 imported into the defining namespace.

 Substantial performance improvements to extend, and to higher-order
 use of protocol fns.

 In addition, I have started documenting these on the clojure.org site,
 and you should use this documentation instead of the wiki design docs,
 which will not be maintained.

 http://clojure.org/protocolshttp://clojure.org/datatypes

 Please note that these are just higher-level descriptions, and contain
 links to the detailed function docs, which are a must-read prior to
 use.

 Feedback and errata welcome as always,

 Rich

 --
 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 
 athttp://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: Datatypes and Protocols update

2010-04-22 Thread Stuart Halloway
A good place to look for examples is protocols.clj and gvec.clj in  
clojure itself. protocols.clj includes an example of implementing a  
protocol on nil.


Stu


On protocols:
- doc string coming after the arg vecs seems odd. I'm used to putting
them after the name of whatever I'm working on.

On protocols doc:
- You can implement a protocol on nil ... Object: could you
elaborate on how these work and/or provide examples? I think this will
solve the one problem I was running into earlier.
- given a protocol my.ns/Protocol, an interface my.ns.MyProtocol:
the final segments don't match.




On Apr 22, 9:53 am, Rich Hickey richhic...@gmail.com wrote:

I have been doing some work cleaning up the design and implementation
of datatypes and protocols in preparation for the 1.2 release. Some
notable changes for those who have been working with the earlier
versions:

deftype/reify now take an explicit 'this' argument in method sigs.
The :as option is gone.

There is a new datatype construct, defrecord. defrecord includes the
implementation of persistent map, and the IPersistentMap magic of
deftype is gone.

deftype and defrecord create named classes, even in non-AOT use.  
There

is no factory fn created, instead you can just call the constructor.

The types for defrecord, deftype and definterface are automatically
imported into the defining namespace.

Substantial performance improvements to extend, and to higher-order
use of protocol fns.

In addition, I have started documenting these on the clojure.org  
site,
and you should use this documentation instead of the wiki design  
docs,

which will not be maintained.

http://clojure.org/protocolshttp://clojure.org/datatypes

Please note that these are just higher-level descriptions, and  
contain

links to the detailed function docs, which are a must-read prior to
use.

Feedback and errata welcome as always,

Rich

--
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 
athttp://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: How to deal with clojure versions in libs

2010-04-22 Thread Heinz N. Gies

On Apr 19, 2010, at 7:52 , Heinz N. Gies wrote:

 Hi phil,
 thanks for the answer many good points there. So just to be sure, if I don't 
 add a :gen-class (which I don't need to in my case) I can use the lib with 
 both 1.1 and 1.2 w/o problems (save for the named ones) so the lein jar jar's 
 are not 'statically linked' (if you can call it that way) against the used 
 version of clojure?

Okay after some nice help from the people here and on #clojure I managed to get 
to my goal of a version compatible library. For anyone interested I wrote up a 
little guide of how it worked out in the end if anyone is interested: 
http://blog.licenser.net/2010/04/22/on-clojure-libs-and-versions

-- 
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: Datatypes and Protocols update

2010-04-22 Thread Jason Wolfe
+1, I am also using this feature of the old deftype.

On Apr 22, 12:15 pm, Konrad Hinsen konrad.hin...@fastmail.net wrote:
 On 22.04.2010, at 18:53, Rich Hickey wrote:

  Feedback and errata welcome as always,

 One feature in the deftype/defrecord split that I regret is that defrecord no 
 longer allows the redefinition of equals and hashCode. Any attempt to 
 override those results in an error message about duplicate method definitions.

 I have several former deftypes that are a perfect fit for the new defrecord, 
 except that they need a specific comparison function. This is usually for 
 excluding some fields from equality testing, or for requiring identity rather 
 than equality for some fields.

 As it is, I must convert all these to the new deftype, losing the convient 
 field access through keywords.

 Konrad.

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.To post to this group, send email 
 tocloj...@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email 
 toclojure+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://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: Slides for short (45 minutes) presentation of clojure for java devs

2010-04-22 Thread Luc Préfontaine
Is there a Dutch version of Clojure ?!?!?! I want one in French
then :
(Laurent you just said you like to be bashed  didn't you ? :)))

Luc

On Thu, 2010-04-22 at 15:09 +0200, Laurent PETIT wrote:

 Could I still take a look at it, to see the kind of examples you
 provided (are the source code examples in english ?)
 
 2010/4/22 Laurent PETIT laurent.pe...@gmail.com:
  2010/4/22 Joop Kiefte iko...@gmail.com:
  I made one simple and short one for beginners, I think to your liking, but
  in Dutch...
 
  too bad I don't speak Dutch :-(
 
 
  2010/4/22 Laurent PETIT laurent.pe...@gmail.com
 
  Oh, really no answer ? :'(
 
  2010/4/21 Laurent PETIT laurent.pe...@gmail.com:
   Hello,
  
   I've consulted a lot of already made presentations of clojure.
   They are great, but I guess they may not suit my needs because it
   seems to me that either:
* they are more 1 1/2 to 2 hours talks than 45 minutes
* they assume the public will not be relunctant to some terms like
   Lisp, Functional Programming and directly present these as
   advantages
  
   My goal is to raise interest into clojure in the mind of a public of
   people having used java for a long time. They may have Scala already
   in their radar, but not clojure, or may have seen it and immediately
   dismissed it for what seemed to them good reasons (mainly aversion for
   lisp syntax), though we all know this is not true after the normal
   adaptation period.
  
   Say this presentation could be the presentation that leads people, at
   its end, asking you for giving all those great other presentations
   already available that I mentioned before ...
  
   Any references I missed that already solve my problem ? :-)
  
   Thanks in advance,
  
   --
   Laurent
  
 
  --
  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
 
 
  --
  Communication is essential. So we need decent tools when communication is
  lacking, when language capability is hard to acquire...
 
  - http://esperanto.net  - http://esperanto-jongeren.nl
 
  Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004
 
  --
  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: Execute a string containing a form?

2010-04-22 Thread Luc Préfontaine
We store routing rules in a database as Clojure code and get these to be
loaded dynamically and run according to some variable configuration.
Of course we make sure the code forms are stringent in the database and
we wrap execution of these things with proper error handling code :)))

That's one of the features we needed to get that message bus thing to
lift up as a generic product and avoid specific code implementation.


Luc P.


On Thu, 2010-04-22 at 16:12 +0200, Heinz N. Gies wrote:

 On Apr 22, 2010, at 14:28 , Douglas Philips wrote:
  eval can be a dangerous thing to use, you have to be very careful about 
  where the source has come from, in terms of trusting that the code your 
  programs 'eval's will not be malicious or dangerous in some way. There are 
  no absolute rules for this, it depends on your application.
 
 To do a bit advertising here, for this case there is clj-sandbox I claim it 
 does a pretty good job to give a basic hassle free safety for evaluated code. 
 Also if it is a string you read from you can skip the read-string part and 
 just pass it the string directly.
 
 If you want to have a look: http://github.com/Licenser/clj-sandbox
 or for lein: [clj-sandbox 0.3.1]
 

-- 
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: Datatypes and Protocols update

2010-04-22 Thread ataggart
Ah, great!  And of course the piece I as missing is that nil and
Object get supported via extend.  Makes sense now given that that was
the section of the doc, but it didn't click the first time through.

On Apr 22, 2:54 pm, Stuart Halloway stuart.hallo...@gmail.com wrote:
 A good place to look for examples is protocols.clj and gvec.clj in  
 clojure itself. protocols.clj includes an example of implementing a  
 protocol on nil.

 Stu





  On protocols:
  - doc string coming after the arg vecs seems odd. I'm used to putting
  them after the name of whatever I'm working on.

  On protocols doc:
  - You can implement a protocol on nil ... Object: could you
  elaborate on how these work and/or provide examples? I think this will
  solve the one problem I was running into earlier.
  - given a protocol my.ns/Protocol, an interface my.ns.MyProtocol:
  the final segments don't match.

  On Apr 22, 9:53 am, Rich Hickey richhic...@gmail.com wrote:
  I have been doing some work cleaning up the design and implementation
  of datatypes and protocols in preparation for the 1.2 release. Some
  notable changes for those who have been working with the earlier
  versions:

  deftype/reify now take an explicit 'this' argument in method sigs.
  The :as option is gone.

  There is a new datatype construct, defrecord. defrecord includes the
  implementation of persistent map, and the IPersistentMap magic of
  deftype is gone.

  deftype and defrecord create named classes, even in non-AOT use.  
  There
  is no factory fn created, instead you can just call the constructor.

  The types for defrecord, deftype and definterface are automatically
  imported into the defining namespace.

  Substantial performance improvements to extend, and to higher-order
  use of protocol fns.

  In addition, I have started documenting these on the clojure.org  
  site,
  and you should use this documentation instead of the wiki design  
  docs,
  which will not be maintained.

 http://clojure.org/protocolshttp://clojure.org/datatypes

  Please note that these are just higher-level descriptions, and  
  contain
  links to the detailed function docs, which are a must-read prior to
  use.

  Feedback and errata welcome as always,

  Rich

  --
  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 
  athttp://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 
 athttp://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: Datatypes and Protocols update

2010-04-22 Thread MarkSwanson
Minor errata barely worth mentioning:on the page: http://clojure.org/datatypes

employeee.getName()

employeee needs just 2 'e' characters.

Cheers.

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


Naming factory functions

2010-04-22 Thread joshua-choi
When it comes to naming factory functions—functions that create things—
clojure.core gives four precedents:

1. Name it exactly what the new object is called. vector, hash-map,
set.
2. Name it a shortened version of #1. vec.
3. Prefix #1 with make-. make-hierarchy, make-array.
4. Prefix #1 with create-. create-ns, create-struct.

Are there any guidelines for naming a library's own factory functions?

(I find #1 and #2 pretty annoying, since they interfere with my
binding of symbols in let forms, but between #3 and #4 I'm not sure.)

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