Re: Leiningen 2.0.0-preview1

2012-03-08 Thread Pepijn de Vos
Yay, cool!

I've run into a problem with "lein run" though. It didn't take any
input, so I ran "lein trampoline run" instead, which did this:
http://pastebin.com/GBkpC0BP

Pepijn

On Mar 7, 11:28 pm, Phil Hagelberg  wrote:
> Hello folks!
>
> I'm proud to announce the release of Leiningen 2.0.0-preview1. While
> this isn't a final stable release, it's fairly stable and should be
> usable for the majority of projects. This is a near-rewrite and contains
> a few backwards-compatibility breaks, but updating should be pretty
> painless in most cases thanks to the lein-precate plugin that can
> suggest a new 2.x-compatible project.clj file.
>
> Highlights for this release:
>
> * Support profiles for alternate project configurations.
> * Replace maven-ant-tasks with Pomegranate library. (Chas Emerick, Nelson 
> Morris)
> * Complete rewrite of repl task. (Colin Jones, Chas Emerick, Anthony Grimes)
> * Rewrite new task. (Anthony Grimes)
> * New check task for catching reflection and other issues. (David Santiago)
> * Allow partial application of aliases.
> * Split out leiningen-core into independent library.
>
> See the full list of user-visible changes:
>
>  https://github.com/technomancy/leiningen/blob/master/NEWS.md
>
> There's a guide covering the upgrade process:
>
>  https://github.com/technomancy/leiningen/wiki/Upgrading
>
> If you are a plugin author, see the newly updated plugin guide,
> particularly the section on "Upgrading Existing Plugins":
>
>  https://github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md
>
> And we're also launchinghttp://leiningen.orgas an introductory page at
> this time.
>
> Please give this preview release a try and let us know how it works for you.
>
> -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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Mark Engelberg
Sean,

I agree that breaking things into smaller functions can potentially help.
Often, though, I find that a function begins by unpacking and computing a
large number of values that are all important for subsequent computations.
Dispatching these computations to helper functions would mean passing an
unwieldy number of variables.  One option is to have the helper functions
inside the main function, inside the scope of these bound variables so that
they don't have to be passed explicitly.  But this potentially means
several levels of nesting to bind the variables to their appropriate values
(possibly testing for nil and other such conditions before computing
further values), and then yet another level of nesting to create the helper
functions (possibly with letfn, which is poorly indented by most of the
IDEs last I checked).  In such scenarios, decomposing into inner helper
functions might actually exacerbate the problem of deeply nested and
therefore highly indented code.

It would be interesting to run a scan of public Clojure code to get a sense
for the average nesting level, indenting level, and the average line
width.  I'd be curious as to how far off the norm my own code is, and how
Clojure compares to other languages.

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

[ANN] clojure-py 0.1.0 Clojure on Python

2012-03-08 Thread Konrad Hinsen
Timothy Baldridge writes:

 > The Clojure-Py team is happy to announce the release of Clojure-Py 0.1.0.
 > 
 > https://github.com/halgari/clojure-py

This looks really nice already. Keep up the good work!

For me, this could be the solution to the main problem I have with
Clojure: the JVM. Most of my legacy code is in Python and most of the
important libraries in my domain are in C or Fortran and have Python
interfaces.

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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Nicolas
I’m not sure that just adding counter responses to almost all Mark
points really help. Most counter arguments here resume to "you are
doing it wrong" and "all clojure 'warts' are here to force you to
better design".

Indeed some kind of code is more readable when written in an
imperative way than functional way. Like some kind of code is more
readable when written in a functional way. This depend what kind of
code you want/need to write and that a strong point for supporting
both style in same language.

Clojure try to avoid imperative code style... Honestly I’m not sure if
avoiding all imperative code is a good idea or not... I need more
experience in clojure and lisp like language to have a good opinion on
that point. But anyway I enjoy clojure as it is today.

Mark, I would say using a few well designed macros you can make
clojure feel a lot more like you want to. That would be interesting to
see and experiment on.

Have a nice day, all!

Nicolas.

On 8 mar, 08:37, Sean Corfield  wrote:
> On Wed, Mar 7, 2012 at 5:10 PM, Mark Engelberg  
> wrote:
> > * introducing variables creates new indenting level, making code "creep to
> > the right"
>
> Mitigated by breaking functions into sub-functions (which is good
> practice anyway).
>
> > * as code creeps to the right, you need to have a lot more newlines
>
> Then your code is too deeply nested and should be broken into
> sub-functions. That's standard best practice across all languages.
>
> > * The convention of using hyphens to separate words is hard to read
>
> I disagree. I find camelCase far harder to read than hyphenated-names.
>
> > * loop/recur is significantly less readable
>
> I don't think it's "significantly" less readable but I do agree that
> recur is a bit of a wart.
>
> > * cond branches are sometimes written with the test and the answer on the
> > same line, or when the test gets too long you have to write it with the test
> > and answer on subsequent lines; this inconsistent formatting can make it
> > hard to know in long blocks whether you are looking at the test or the
> > answer
>
> Don't write long blocks. Don't write complex conditions. Introduction
> more sub-functions.
>
> > * Interweavings of cond and let (a common pattern) end up ridiculously
> > indented and hard to read
>
> See above (and I don't agree it's a "common" pattern... perhaps an
> anti-pattern?).
>
> > * Decades worth of classic algorithms involving imperative manipulation of
> > arrays look significantly uglier in Clojure
>
> Yet many algorithms are significantly cleaner in a pure functional style...
>
> > * Expression-oriented syntax (along with the indenting cost of using let)
> > encourages people to pack far too much into one line rather than giving
> > names to intermediate results.
>
> Again, poor style. Break things into sub-functions.
>
> > * DSLs are supposed to bring customized readable notation to many tasks, but
> > by the time you include namespace prefixes and colons for all the keywords,
> > DSLs don't really look that good.
>
> Then those DSLs are not achieving their design goals. DSLs are a good
> use case for :use or :require/:refer.
>
> > * ... But when I read someone else's compact
> > higher-order stuff, it's usually a nightmare to try to interpret what it is
> > doing.
>
> Really? I find the compaction outweighs the effort involved - as long
> as the code is modular enough (see comments above).
>
> > * And the number 1 problem with all Lisps is that when you look at Lisp
> > code, it's a sea of sameness.  Function applications, Macros, Control
> > constructs, bindings, data lookups, etc. all look exactly the same.
>
> I actually find that to be a plus - there's no distracting variance
> that artificially makes things "different" that don't need to be.
>
> Syntax is very subjective. It's really good to here your pro-Python
> thoughts tho'...
> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View --http://corfield.org/
> World Singles, LLC. --http://worldsingles.com/
>
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Mark Engelberg
On Wed, Mar 7, 2012 at 11:37 PM, Sean Corfield wrote:

> I actually find that to be a plus - there's no distracting variance
> that artificially makes things "different" that don't need to be.
>
>
I just thought of an amusing analogy.  To me, reading Lisp takes more
mental effort in the same way that it takes more mental effort to follow
someone who is speaking in monotone (precisely because there is "no
distracting variance").

The main reason I spoke up was because of the comment in the thread
suggesting that readability is purely a function of what kind of syntax you
are most used to seeing.  Many people tend to assume that if you don't like
the way Lisp looks, you just haven't been using it long enough.  I wanted
to offer a counterexample, as someone who has spent over 20 years reading
Lispy code.  I prefer to *write* Clojure, but I prefer to *read* Python.

If I can find a language that I enjoy reading as much as I enjoy writing,
that would be nirvana.  That's why the original post for this thread caught
my eye, and struck me as worthy of discussion.  I know Rich has mentioned
that he admires Python's concision, so it seems reasonable to compare and
contrast their readability.

It is worth noting that Clojure does have several things that elevate it
over other Scheme/Lisps in terms of readability.  The use of [] for vectors
and {} for maps is a huge help.  The ability to add commas anywhere you
want is nice.  The removal of extra parens from let is nice (I'm less keen
on the removal of extra parens from cond because of the awkwardness that
results when the test and answer are too big to fit on the same line).
Short names for most of the built-in functions are also nice.

-- 
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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Mark Engelberg
On Thu, Mar 8, 2012 at 2:45 AM, Nicolas  wrote:

> I’m not sure that just adding counter responses to almost all Mark
> points really help. Most counter arguments here resume to "you are
> doing it wrong" and "all clojure 'warts' are here to force you to
> better design".
>

Looking back at my initial email, I can see that it probably came across as
a bit of a rant, and probably not as constructive a response as I had
intended it to be.  I understand where Sean is coming from with his
point-by-point.

-- 
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: [ANN] clojure-py 0.1.0 Clojure on Python

2012-03-08 Thread Timothy Baldridge
>Congrat's on the release! I am getting the following error on my
>Macbook (running 64-bit Lion, Python 2.7.1) when trying to run "sudo
>easy_install clojure-py":

I've seen this once before, in Linux, I'll open a bug for it and see
if we can get it ironed out.

Timothy

-- 
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: [ANN] clojure-py 0.1.0 Clojure on Python

2012-03-08 Thread Daniel Janus
I'm seeing it on Arch Linux as well, using both pip2 and easy_install-2.7.

Thanks,
Daniel

W dniu czwartek, 8 marca 2012, 12:00:24 UTC użytkownik tbc++ napisał:
>
> >Congrat's on the release! I am getting the following error on my
> >Macbook (running 64-bit Lion, Python 2.7.1) when trying to run "sudo
> >easy_install clojure-py":
>
> I've seen this once before, in Linux, I'll open a bug for it and see
> if we can get it ironed out.
>
> Timothy
>
>

-- 
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: named/numbered releases?

2012-03-08 Thread Stuart Campbell
Hello,

According to a past thread (
https://groups.google.com/forum/?fromgroups#!topic/clojure/L4e8DtzdThY):

ClojureScript has no "release" versions yet. Instead we have a
> revision number, calculated as the number of commits on the master
> branch since the beginning of the project. ClojureScript is currently
> at revision 927. In Maven/Leiningen, this is represented as version
> "0.0-927".


The latest release is 0.0-993.

Regards,
Stuart

On 8 March 2012 15:02, kovas boguta  wrote:

> It's great to see the steady activity on the clojurescript github page.
>
> However I'm not totally comfortable developing against the master branch.
>
> As it stands now, if I change development environments, or deploy on a
> new machine, the master branch may have moved.
>
> I could choose an arbitrary commit as my stable reference point,  and
> periodically make a judgement call about upgrading to a new arbitrary
> commit, but thats not easy for someone not involved in the internals.
>
> I gather this is still "pre-1.0" , but it would still be nice to have
> some incremental version numbers to rationalize things.
>
> thanks for listening.
>
> --
> 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: [ANN] clojure-py 0.1.0 Clojure on Python

2012-03-08 Thread Timothy Baldridge
It seems to be a packaging issue. As an aside note, if you do a github
checkout then run

python setup.py install

it seems to work just fine. But I'll look into this issue as well.

Timothy

2012/3/8 Daniel Janus :
> I'm seeing it on Arch Linux as well, using both pip2 and easy_install-2.7.
>
> Thanks,
> Daniel
>
> W dniu czwartek, 8 marca 2012, 12:00:24 UTC użytkownik tbc++ napisał:
>>
>> >Congrat's on the release! I am getting the following error on my
>> >Macbook (running 64-bit Lion, Python 2.7.1) when trying to run "sudo
>> >easy_install clojure-py":
>>
>> I've seen this once before, in Linux, I'll open a bug for it and see
>> if we can get it ironed out.
>>
>> Timothy
>
> --
> 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



-- 
"One of the main causes of the fall of the Roman Empire was
that-lacking zero-they had no way to indicate successful termination
of their C programs."
(Robert Firth)

-- 
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: [ANN] clojure-py 0.1.0 Clojure on Python

2012-03-08 Thread Laurent PETIT
Amazing!

What startup time performance improvements do you see for eg using
this platform for shell scripts-like stuff ?

Le 8 mars 2012 à 04:42, Timothy Baldridge  a écrit :

> The Clojure-Py team is happy to announce the release of Clojure-Py 0.1.0.
>
> https://github.com/halgari/clojure-py
>
> Clojure-Py is an implementation of Clojure running atop the Python VM.
> As it currently stands, we have translated over 235 functions from
> clojure.core. This is not a clojure interpreter in python; the
> Clojure-Py compiler compiles clojure code directly to python code.
> Clojure-py functions are python functions. Clojure-py types are python
> types, Clojure-py name spaces are python modules.
>
> Please feel free to browse the examples at
> https://github.com/halgari/clojure-py/tree/master/examples to get an
> idea of what Clojure-Py can currently accomplish.
>
> Version 0.1.0 should be considered "alpha" and "proof of concept".
> That being said, if you stick to the afore mentioned 235 functions,
> and python interop, the implementation is very usable and so far quite
> stable.
>
> The package is released via the Python Package index so you can simply type
>
> easy_install clojure-py
> clojurepy
>
> To install and startup the repl. Python 2.6, 2.7 and PyPy are all
> supported. Please check out this release and send us your feedback via
> Github.
> ---
>
> Upcoming in version 0.2.0:
>
> Support for bindings
> defprotocol and defmulti
> defrecord
> full support for pr-str
>
> ---
>
> Thank you for all the interest we've received from the Clojure and
> Python communities. We look forward to seeing this project grow.
>
> Timothy Baldridge (halgari)
>
> --
> 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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Stuart Halloway
> Looking back at my initial email, I can see that it probably came across as a 
> bit of a rant, and probably not as constructive a response as I had intended 
> it to be.  I understand where Sean is coming from with his point-by-point.

I did not find it so, and enjoyed reading it, albeit while disagreeing on many 
points. :-)

My Clojure/West talk will engage this issue.

Stu


Stuart Halloway
Clojure/core
http://clojure.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: [ANN] clojure-py 0.1.0 Clojure on Python

2012-03-08 Thread Timothy Baldridge
Okay, the Python package should be fixed now. It took a few tries, but
I was finally able to get it to include core.clj as part of the
distro.

> What startup time performance improvements do you see for eg using
> this platform for shell scripts-like stuff ?

Currently, it's about 3sec on my machine. This is because we're
parsing/compiling all 2600 lines of core.clj on every start-up. One of
my tasks this week is to compile the file to bytecode, then serialize
this bytecode as a .cljc file. This is the method the rest of python
uses, and at that point we should have almost instant start-up times.

Timothy


On Thu, Mar 8, 2012 at 6:36 AM, Laurent PETIT  wrote:
> Amazing!
>
> What startup time performance improvements do you see for eg using
> this platform for shell scripts-like stuff ?
>
> Le 8 mars 2012 à 04:42, Timothy Baldridge  a écrit :
>
>> The Clojure-Py team is happy to announce the release of Clojure-Py 0.1.0.
>>
>> https://github.com/halgari/clojure-py
>>
>> Clojure-Py is an implementation of Clojure running atop the Python VM.
>> As it currently stands, we have translated over 235 functions from
>> clojure.core. This is not a clojure interpreter in python; the
>> Clojure-Py compiler compiles clojure code directly to python code.
>> Clojure-py functions are python functions. Clojure-py types are python
>> types, Clojure-py name spaces are python modules.
>>
>> Please feel free to browse the examples at
>> https://github.com/halgari/clojure-py/tree/master/examples to get an
>> idea of what Clojure-Py can currently accomplish.
>>
>> Version 0.1.0 should be considered "alpha" and "proof of concept".
>> That being said, if you stick to the afore mentioned 235 functions,
>> and python interop, the implementation is very usable and so far quite
>> stable.
>>
>> The package is released via the Python Package index so you can simply type
>>
>> easy_install clojure-py
>> clojurepy
>>
>> To install and startup the repl. Python 2.6, 2.7 and PyPy are all
>> supported. Please check out this release and send us your feedback via
>> Github.
>> ---
>>
>> Upcoming in version 0.2.0:
>>
>> Support for bindings
>> defprotocol and defmulti
>> defrecord
>> full support for pr-str
>>
>> ---
>>
>> Thank you for all the interest we've received from the Clojure and
>> Python communities. We look forward to seeing this project grow.
>>
>> Timothy Baldridge (halgari)
>>
>> --
>> 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



-- 
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)

-- 
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: [ANN] clojure-py 0.1.0 Clojure on Python

2012-03-08 Thread Michael Wood
On 8 March 2012 05:42, Timothy Baldridge  wrote:
> The Clojure-Py team is happy to announce the release of Clojure-Py 0.1.0.
>
> https://github.com/halgari/clojure-py
>
> Clojure-Py is an implementation of Clojure running atop the Python VM.

Looks interesting :)

What's the plan for ratios and characters?  I assume they're still on
the TODO list?  (Maybe Issue 17 covers the ratios?)

e.g.:

$ python clojure.py
clojure-py 0.1.0
user=> \a
Compiling \a
Traceback (most recent call last):
[...]
CompilerException: Compiler Exception could not resolve '\a', '\a' not
found in user reference fn_787
user=> (/ 22 7)
3
user=> 22/7
Traceback (most recent call last):
[...]
clojure.lang.cljexceptions.ReaderException: Invalid number: 22/7
$

-- 
Michael Wood 

-- 
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: [ANN] clojure-py 0.1.0 Clojure on Python

2012-03-08 Thread Timothy Baldridge
> What's the plan for ratios and characters?  I assume they're still on
> the TODO list?  (Maybe Issue 17 covers the ratios?)

Yeah, I need to run a few more tests, but I'm thinking of somehow
layering libgmp ontop of Python in order to implement ratios.

The lispreader needs to be fixed to handle characters. I'll create a
bug report for that. Thanks!

Timothy

-- 
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: Why don't extends? and satisfies? require implementation of all protocol methods?

2012-03-08 Thread Armando Blancas
(Don't know why I can only respond to the first message.)

I come across partial implementation all the time, and with proxy, too. In 
Eclipse this is so common that this is typical:

"This adapter class provides default implementations for the methods 
described by the SelectionListener interface.
Classes that wish to deal with SelectionEvents can extend this class and 
override only the methods which they are interested in."

You may have seen the idea of optional operation in java.util.List and how 
it's handled in places like AbstractList with default implementations. 
Clojure itself has partial implementations of List in PersistentList and 
Collection in PersistentQueue. I suppose the alternative would be a 
proliferation of interfaces and protocols that would prevent reuse; 
something like ListWithoutModificationOrBulkOperations could have a full 
implementation but little use.

I can see the value of your view of protocol as spec, but maybe for 
domain-realted concepts and less for plumbing. 

-- 
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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Evan Gamble
Another way to flatten nested lets and conds is to use a macro that
lets you insert conditionals in your lets (vs. your suggestion of
inserting lets in conds).

I wrote a let? macro that does that: https://github.com/egamble/let-else

- Evan

On Mar 7, 10:51 pm, Mark Engelberg  wrote:

> In the meantime, I *strongly urge* everyone to check out Grand's flatter
> cond 
> macro:https://github.com/cgrand/parsley/blob/master/src/net/cgrand/parsley/...
>
> It lets you insert lets in the middle of cond expressions (like you can
> currently do with for) like:
> (cond
>    (pos? x) 2
>    :let [y (* x x)]
>     (> y 20) 4))
>
> This totally transformed my coding style and improved the readability of my
> code substantially.  Highly recommended.  Since it is backwards compatible,
> I very much wish it were part of the core, and see no reason that it
> couldn't be.
>
> --Mark

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


Which emacs packages?

2012-03-08 Thread AndyK
Curious about which emacs packages folks use for increased Clojure 
productivity (beyond the obvious, like slime/swank-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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Sean Corfield
On Thu, Mar 8, 2012 at 2:54 AM, Mark Engelberg  wrote:
> Looking back at my initial email, I can see that it probably came across as
> a bit of a rant, and probably not as constructive a response as I had
> intended it to be.

No, I thought it was an interesting set of observations but, like Stu,
I disagree on many points. As noted, syntax is definitely subjective.
Ruby makes my skin crawl but I can't really put my finger on why (it
feels like punctuation has been used for cryptic semantics - but I
don't react to some other languages against which I could level that
criticism). If I was doing heavy numeric computations, I'd probably
find the prefix syntax in Lisp annoying, so I suspect your problem
domain has a lot to do with your feelings about a language too.

> I understand where Sean is coming from with his
> point-by-point.

Most of my comments would be true of code in other languages (and
Scala came to mind, specifically, as I was suggesting breaking code
into smaller units to aid readability). I'm interested in hearing more
about the sort of functions that begin "by unpacking and computing a
large number of values that are all important for subsequent
computations". I'm not seeing this in my code so I assume we're
working on very different problem domains - could you elaborate?
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Laurent PETIT
You should probably both share gists of real code you're talking about,
shouldn't you ?

Your discussion made me think that editors may help further in this area,
without having to change the syntax.
Currently, the editors only try to give some "hints" by playing with
colors, but there are some other ideas that could be followed:
- playing with contrast by also using the ability to change the fonts
- playing with contrast by slowly decreasing the font's opacity as the code
gets deeper (but where the cursor is, this should probably go away to
ensure good visibility) => could help see the overall structure without
seeing to much of the details?
- playing with "proximity" by adjusting the line sizes. For example, there
could be extra space around the "true" and "false" clauses of an if, there
could be extra space around "condition/then" clauses of a cond, etc.
- playing with the background color of blocks, potentially minimizing (and
to some extend -in a modal structural editor- almost removing from sight)
the parens

- since it's not the same thing to "write/edit" and to "read" code, there
could be the possibility to have a "read" mode where the editor could
represent totally differently the source code (think it could even present
it in some sort of prefix-notation :-) )


2012/3/8 Sean Corfield 

> On Thu, Mar 8, 2012 at 2:54 AM, Mark Engelberg 
> wrote:
> > Looking back at my initial email, I can see that it probably came across
> as
> > a bit of a rant, and probably not as constructive a response as I had
> > intended it to be.
>
> No, I thought it was an interesting set of observations but, like Stu,
> I disagree on many points. As noted, syntax is definitely subjective.
> Ruby makes my skin crawl but I can't really put my finger on why (it
> feels like punctuation has been used for cryptic semantics - but I
> don't react to some other languages against which I could level that
> criticism). If I was doing heavy numeric computations, I'd probably
> find the prefix syntax in Lisp annoying, so I suspect your problem
> domain has a lot to do with your feelings about a language too.
>
> > I understand where Sean is coming from with his
> > point-by-point.
>
> Most of my comments would be true of code in other languages (and
> Scala came to mind, specifically, as I was suggesting breaking code
> into smaller units to aid readability). I'm interested in hearing more
> about the sort of functions that begin "by unpacking and computing a
> large number of values that are all important for subsequent
> computations". I'm not seeing this in my code so I assume we're
> working on very different problem domains - could you elaborate?
> --
> Sean A Corfield -- (904) 302-SEAN
> An Architect's View -- http://corfield.org/
> World Singles, LLC. -- http://worldsingles.com/
>
> "Perfection is the enemy of the good."
> -- Gustave Flaubert, French realist novelist (1821-1880)
>
> --
> 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: Leiningen 2.0.0-preview1

2012-03-08 Thread Phil Hagelberg
Pepijn de Vos  writes:

> I've run into a problem with "lein run" though. It didn't take any
> input, so I ran "lein trampoline run" instead, which did this:
> http://pastebin.com/GBkpC0BP

I'm having trouble reproducing this; could you open an issue with a
minimal test case?

-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: Which emacs packages?

2012-03-08 Thread Tassilo Horn
AndyK  writes:

> Curious about which emacs packages folks use for increased Clojure
> productivity (beyond the obvious, like slime/swank-clojure)...

For any lisp:

  - paredit
http://www.emacswiki.org/emacs/ParEdit
  - highlight-parentheses
http://www.emacswiki.org/emacs/HighlightParentheses

For any programming:

  - highlight-symbol
http://www.emacswiki.org/emacs/HighlightSymbol

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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Phil Hagelberg
Sean Corfield  writes:

> Most of my comments would be true of code in other languages (and
> Scala came to mind, specifically, as I was suggesting breaking code
> into smaller units to aid readability). I'm interested in hearing more
> about the sort of functions that begin "by unpacking and computing a
> large number of values that are all important for subsequent
> computations". I'm not seeing this in my code so I assume we're
> working on very different problem domains - could you elaborate?

I see this every so often, but it's usually easy to solve with partial.

(defn write-jar [project out-file filespecs]
  (let [manifest (make-manifest project)]
(with-open [jar-os (-> out-file
   (FileOutputStream.)
   (BufferedOutputStream.)
   (JarOutputStream. manifest))]
  (doseq [filespec filespecs]
[HUGE GLOB OF CODE THAT USES project AND out-file]

The doseq call needed to be converted to a reduce so it could accumulate
some state, but the big glob of code to be extracted needed access to
the `project` and `out-file` locals. Reducing with a partially-applied
function makes this work nicely:

(defn write-jar [project out-file filespecs]
  (let [manifest (make-manifest project)]
(with-open [jar-os (-> out-file
   (FileOutputStream.)
   (BufferedOutputStream.)
   (JarOutputStream. manifest))]
  (reduce (partial copy-to-jar project jar-os) #{} filespecs

Just a thought. I can see where Mark is coming from, but I don't think
the workaround is particularly difficult or onerous.

-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


[Clojurescript] Way to avoid function call indirection in deftypes?

2012-03-08 Thread Philip K
Right now, when I define a deftype function f the generated js code looks 
something like:

f = function(self, arg) {
  if (self.func) {
return self.func(self, arg);
  }
  else {
// check if self implements protocol
return f._(self, arg);
  }
}

This seems like an awful lot of indirection just for a function call. Is 
there a way to disable the protocol checks (maybe with advanced 
optimization?). Or do I have to define all functions outside the deftype in 
order to avoid the additional overhead of type checking?

I mean, yes, the error messages are helpful, but when I call a deftype 
function with the wrong argument I'm gonna get a runtime error in 99% of 
the cases anyway when I access some invalid field.

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

how to restart Clojurescript One repl the right way?

2012-03-08 Thread George Oliver
hi, I'm just starting with ClojureScript and ClojureScript One.
Sometimes working with One I kill the cljs-repl for whatever reason
(something hangs, I make some mistake and can't correct it, etcetera);
when I go to restart (by running lein repl again), I then can't
restart the cljs-repl. I get,

BindException Address already in use: JVM_Bind
java.net.PlainSocketImpl.socketBind

What's the right way to restart in this situation? Thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Clojurescript: named/numbered releases?

2012-03-08 Thread Evan Mezeske
I've been working off the releases under "tags":

https://github.com/clojure/clojurescript/tags

I think these are still pre-1.0 releases, but they seem to be released at 
more stable points than just tracking the master.

On Wednesday, March 7, 2012 9:02:48 PM UTC-7, kovasb wrote:
>
> It's great to see the steady activity on the clojurescript github page.
>
> However I'm not totally comfortable developing against the master branch.
>
> As it stands now, if I change development environments, or deploy on a
> new machine, the master branch may have moved.
>
> I could choose an arbitrary commit as my stable reference point,  and
> periodically make a judgement call about upgrading to a new arbitrary
> commit, but thats not easy for someone not involved in the internals.
>
> I gather this is still "pre-1.0" , but it would still be nice to have
> some incremental version numbers to rationalize things.
>
> thanks for listening.
>
>

-- 
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 on android over CLI

2012-03-08 Thread Jim - FooBar();
There is a clojure repl for android...it will make your life 
easier...the only problem is you cannot include external libs in your 
project...


Jim

On 08/03/12 01:43, Rostislav Svoboda wrote:

Hi. I'm trying to run:
 java -cp clojure-${VERSION}.jar clojure.main

on an Android phone from bash (using the 'terminal-ide' app) but I
can't make it past the error bellow. I did the jar-to-dex conversion
using:
 dx --verbose --dex --output=clojure-${VERSION}.dex.jar
clojure-${VERSION}.jar

for clojure-1.3.0.jar, clojure-1.3.0-slim.jar and even for the clojure
clone for Android Neko Toolkit from Daniel Solano Gómez:
https://github.com/sattvik/clojure.git

Does anyone know what I missed? Thx in advance

Bost


   Now searching: clojure-1.3.0.dex.jar
 found
java.lang.ExceptionInInitializerError
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:507)
 at com.spartacusrex.spartacuside.external.java.main(java.java:124)
 at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ExceptionInInitializerError
 at clojure.main.(main.java:20)
 ... 4 more
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException:
Could not locate clojure/core__init.class or clojure/core.clj on
classpath:
 at clojure.lang.Util.runtimeException(Util.java:165)
 at clojure.lang.RT.(RT.java:319)
 ... 5 more
Caused by: java.io.FileNotFoundException: Could not locate
clojure/core__init.class or clojure/core.clj on classpath:
 at clojure.lang.RT.load(RT.java:430)
 at clojure.lang.RT.load(RT.java:398)
 at clojure.lang.RT.doInit(RT.java:434)
 at clojure.lang.RT.(RT.java:316)
 ... 5 more


In case of the clojure clone for Daniel Solano Gómez:

   Now searching: clojure-1.4.0-master-SNAPSHOT.dex.jar
 found
java.lang.ExceptionInInitializerError
 at java.lang.reflect.Method.invokeNative(Native Method)
 at java.lang.reflect.Method.invoke(Method.java:507)
 at com.spartacusrex.spartacuside.external.java.main(java.java:124)
 at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ExceptionInInitializerError
 at clojure.main.(main.java:20)
 ... 4 more
Caused by: java.lang.ExceptionInInitializerError
 at java.lang.Class.classForName(Native Method)
 at java.lang.Class.forName(Class.java:234)
 at java.lang.Class.forName(Class.java:181)
 at clojure.lang.RT.(RT.java:235)
 ... 5 more
Caused by: java.lang.ExceptionInInitializerError
 at android.os.Build$VERSION.(Build.java:75)
 ... 9 more
Caused by: java.lang.UnsatisfiedLinkError: native_get
 at android.os.SystemProperties.native_get(Native Method)
 at android.os.SystemProperties.get(SystemProperties.java:59)
 at android.os.Build.getString(Build.java:216)
 at android.os.Build.(Build.java:27)
 ... 10 more



--
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 emacs packages?

2012-03-08 Thread Eduardo Bellani
IMHO, more or less in this order
* Paredit
* undo-tree
* ido-ubiquitous-mode or icicles
* winner-mode
* highlight-parentheses-mode

See you

On Thu, Mar 8, 2012 at 2:10 PM, AndyK  wrote:
> Curious about which emacs packages folks use for increased Clojure
> productivity (beyond the obvious, like slime/swank-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



-- 
Eduardo Bellani

www.cnxs.com.br

More is not better (or worse) than less, just different.
– The paradigm paradox.

-- 
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 use goog.dom.query

2012-03-08 Thread Evan Mezeske
Just a word of warning:  I've had several reports of people encountering 
difficulties (e.g. weird stack traces) when trying to use a recent 
ClojureScript compiler with the various "goog" jars that are flying around. 
 Presumably this is due to the fact that the compiler depends on the Google 
Closure Library, which conflicts with most of the goog jars (which also 
include the Closure Library, but typically a newer version of it).

It seems like it would be good if someone broke out the third-party Closure 
libraries into a separate jar that did not include the base Closure 
Library, to avoid these conflicts.

I myself am guilty of packaging the Closure Library together with the third 
party stuff (https://github.com/emezeske/closure-library).  It would be 
trivial to fork this repo and provide a third-party-only library, I think...

On Tuesday, January 24, 2012 4:47:38 PM UTC-7, Dave Sann wrote:
>
> The third party libs are not included in the std closurescript jar.
>
> pinot requires a modified jar that contains the extra libs. If you follow 
> the instructions for pinot - you can get this lib and install it - it's 
> fairly painless.
>
> I don't know of an easy way to include these without doing this.
>
> There is a version with a newer closure library here:
>
>- https://github.com/davesann/clojurescript-goog-jar
>
> (It is currently this version of the closure library : 
> closure-library-2010-r1376.zip)
>
> I made some notes on how I created this here: 
>
>- https://groups.google.com/d/topic/clj-noir/x5x9vcI-T4E/discussion
>
>
> Cheers
>
> 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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Leon Talbot
What I met by readable, is the capacity of reading someone's code.

On 7 mar, 18:12, Joachim De Beule  wrote:
> On Mar 7, 6:39 pm, Leon Talbot  wrote:
>
> > If so, how ?
>
> > Thanks !
>
> Please define "readable".
>
> Thanks!

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread djh
I think it's all down to pattern recognition. 

Once you've been developing in Clojure for a while you start to recognise 
patterns very easily, meaning reading other peoples code isn't really an 
issue.

The same applies to languages like Haskell, when you're just starting out 
it might seem a little alien, but after a while you start to recognise 
things and "read" the code a lot quicker

On Wednesday, March 7, 2012 5:39:08 PM UTC, Leon Talbot wrote:
>
> If so, how ? 
>
> Thanks !


On Wednesday, March 7, 2012 5:39:08 PM UTC, Leon Talbot wrote:
>
> If so, how ? 
>
> Thanks !

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojurescript: named/numbered releases?

2012-03-08 Thread Stuart Sierra
We have ClojureScript jars in Maven Central, built periodically when we 
think master is in a stable state.
http://search.maven.org/#search|gav|1|g%3A%22org.clojure%22%20AND%20a%3A%22clojurescript%22

These JARs correspond to the tags in Git.

-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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Moritz Ulrich
On Thu, Mar 8, 2012 at 08:37, Sean Corfield  wrote:
>> * The convention of using hyphens to separate words is hard to read
>
> I disagree. I find camelCase far harder to read than hyphenated-names.

I'm pretty sure there is an Emacs mode for displaying foo-bar-baz as
fooBarBaz and reversed.

-- 
Moritz Ulrich

-- 
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] Way to avoid function call indirection in deftypes?

2012-03-08 Thread David Nolen
The overhead is not as great as you think. In the newer crop of JS engines
it's surprisingly small and I imagine that it will get smaller.

I don't see this getting changed anytime soon as it allows for polymorphism
as well as handling the default case if provided. If you see a better way
to get the same behavior, we're all ears.

David

On Thu, Mar 8, 2012 at 1:02 PM, Philip K  wrote:

> Right now, when I define a deftype function f the generated js code looks
> something like:
>
> f = function(self, arg) {
>   if (self.func) {
> return self.func(self, arg);
>   }
>   else {
> // check if self implements protocol
> return f._(self, arg);
>   }
> }
>
> This seems like an awful lot of indirection just for a function call. Is
> there a way to disable the protocol checks (maybe with advanced
> optimization?). Or do I have to define all functions outside the deftype in
> order to avoid the additional overhead of type checking?
>
> I mean, yes, the error messages are helpful, but when I call a deftype
> function with the wrong argument I'm gonna get a runtime error in 99% of
> the cases anyway when I access some invalid field.
>
> --
> 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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Tassilo Horn
Moritz Ulrich  writes:

>>> * The convention of using hyphens to separate words is hard to read
>>
>> I disagree. I find camelCase far harder to read than
>> hyphenated-names.
>
> I'm pretty sure there is an Emacs mode for displaying foo-bar-baz as
> fooBarBaz and reversed.

There's glasses-mode for displaying CamelCase as Camel_Case, Camel-Case,
or whatever you like.  Not sure if there's a mode that does the reverse.

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: Pretty print defn

2012-03-08 Thread Jeff Weiss
I use serializable.fn pretty extensively, and it's been working great for 
me.  I think at this point, the only fix I put in that Phil didn't is that 
my serialized fn's print with an unqualified "fn" symbol, instead of 
"serializable.fn/fn".  I did that so it's more readable, the tradeoff is 
that if you want your fn's to be re-serializable (which I don't think you 
do), you have to spell out which fn you're using.

https://github.com/weissjeffm/serializable-fn

Another caveat is that it does not work with defn, just fn.  So you would 
have to do 
(def qw  
 (fn [] 
  (inc 2)) 

A serializable.fn/defn would be really nice to have, I am not sure how 
difficult it would be to write, without having tried it.

-jeff

On Friday, March 2, 2012 10:19:56 PM UTC-5, Phil Hagelberg wrote:
>
> Mark Rathwell  writes:
>
> > (clojure.repl/source-fn 'qw) will give you the source.
>
> You can also use serializable-fn to create a function that will carry
> its source around with it in metadata:
>
> https://github.com/technomancy/serializable-fn
>
> But it's not very well tested.
>
> -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: clojure-py 0.1.0 Clojure on Python

2012-03-08 Thread Shantanu Kumar


On Mar 8, 7:22 pm, Timothy Baldridge  wrote:
> Okay, the Python package should be fixed now. It took a few tries, but
> I was finally able to get it to include core.clj as part of the
> distro.

Thanks, the install works for me now. However, when I run "sudo
clojurepy" pressing Ctrl+D exits the REPL fine, but when I run
"clojurepy" without sudo I get the error below:

user=> ^DError in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
IOError: [Errno 13] Permission denied
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
IOError: [Errno 13] Permission denied

It exits the REPL nevertheless.

Shantanu

-- 
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-py 0.1.0 Clojure on Python

2012-03-08 Thread Timothy Baldridge
It looks to be a bug with where the script is saving the history file.
We have a bug report for it
https://github.com/halgari/clojure-py/issues/41 and we'll look into
it. Thanks!

Timothy

On Thu, Mar 8, 2012 at 1:11 PM, Shantanu Kumar  wrote:
>
>
> On Mar 8, 7:22 pm, Timothy Baldridge  wrote:
>> Okay, the Python package should be fixed now. It took a few tries, but
>> I was finally able to get it to include core.clj as part of the
>> distro.
>
> Thanks, the install works for me now. However, when I run "sudo
> clojurepy" pressing Ctrl+D exits the REPL fine, but when I run
> "clojurepy" without sudo I get the error below:
>
> user=> ^DError in atexit._run_exitfuncs:
> Traceback (most recent call last):
>  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
> python2.7/atexit.py", line 24, in _run_exitfuncs
>    func(*targs, **kargs)
> IOError: [Errno 13] Permission denied
> Error in sys.exitfunc:
> Traceback (most recent call last):
>  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/
> python2.7/atexit.py", line 24, in _run_exitfuncs
>    func(*targs, **kargs)
> IOError: [Errno 13] Permission denied
>
> It exits the REPL nevertheless.
>
> Shantanu
>
> --
> 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



-- 
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)

-- 
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 I can use InteractionEvent in clojure?

2012-03-08 Thread Antonio Recio
It works!!! Thanks Aaron Cohen and Mark Rathwell.

The code final that works 100% of the example cone6 of vtk in clojure is 
this:

(ns example
  (:import (javax.swing JFrame JPanel SwingUtilities)))

(clojure.lang.RT/loadLibrary "vtkCommonJava")
(clojure.lang.RT/loadLibrary "vtkWidgetsJava")

(def boxWidget  (vtk.vtkBoxWidget.))

(def myCallback
  (fn []
(println "Invoked!")
(let [t (vtk.vtkTransform.)]
  (doto boxWidget
(.GetTransform t)
(.. GetProp3D (SetUserTransform t))


(defn main []
  (let [cone   (vtk.vtkConeSource.)
coneMapper (vtk.vtkPolyDataMapper.)
coneActor  (vtk.vtkActor.)
ren(vtk.vtkRenderer.)
renWin (vtk.vtkRenderWindow.)
iren   (vtk.vtkRenderWindowInteractor.)
style  (vtk.vtkInteractorStyleTrackballCamera.)
t  (vtk.vtkTransform.)]

(doto cone
  (.SetHeight 3.0)
  (.SetRadius 1.0)
  (.SetResolution 10))
(doto coneMapper
  (.SetInput (.GetOutput cone)))
(doto coneActor
  (.SetMapper coneMapper))
(doto ren
  (.GradientBackgroundOn)
  (.SetBackground 0.5 0.6 0.8)
  (.AddActor coneActor)
  (.ResetCamera))
(doto renWin
  (.AddRenderer ren)
  (.SetSize 300 300))
(doto iren
  (.SetRenderWindow renWin)
  (.SetInteractorStyle style))
(doto boxWidget
  (.SetInteractor iren)
  (.SetPlaceFactor 1.25)
  (.SetProp3D coneActor)
  (.PlaceWidget)
  (.AddObserver "InteractionEvent" myCallback "run")
  (.On))
(doto iren
  (.Initialize)
  (.Start

(example/main)

-- 
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.test on ClojureScript?

2012-03-08 Thread Shantanu Kumar
Thanks Brenton and Stuart, that was very insightful.

Shantanu

On Feb 26, 11:58 pm, Brenton  wrote:
> Shantanu,
>
> I have been experimenting with this in ClojureScript One. The latest
> version is in the M003 branch.
>
> The example that Stuart links to is a complex integration test. Here
> is an example of some unit tests which test ClojureScript code.
>
> https://github.com/brentonashworth/one/blob/M003/test/one/test/dispat...
>
> The idea is to keep writing tests in Clojure using clojure.test but
> add the ability to easily evaluate some forms in a JavaScript
> environment. This allows you to have one test suite for a Clojure/
> ClojureScript project with integrated test results. The same technique
> could be used with other test frameworks.
>
> In the above example, you set up the test namespace in the same way
> you would with Clojure tests.
>
> You then have the `in-javascript` macro which sets up the
> ClojureScript namespace and allows you to define functions that you
> can call from ClojureScript in the tests below. All ClojureScript in
> the tests below will be evaluated in the namespace that you set up
> here.
>
> In your tests, when you want to evaluate something in the JavaScript
> environment, you wrap that form in the `js` macro.
>
> If you checkout this branch you can run tests in three ways:
>
> 1) `lein test` will run all the tests as it normally would. The
> current setup will launch a browser which can be used as the
> evaluation environment.
>
> 2) You can run tests from a Clojure REPL:
>
> (dev-server)
> (require 'one.test)
> (require 'clojure.test)
> (require 'one.test.dispatch)
>
> (def ee (one.test/browser-eval-env))
>
> ;; go to the development or fresh page
>
> (binding [one.test/*eval-env* ee]
>   (clojure.test/run-tests 'one.test.dispatch))
>
> 3) If you are in a ClojureScript REPL, you can run the tests with:
>
> (run-tests 'one.test.dispatch)
>
> In each case you need to have a JavaScript environment in which to
> evaluation things. In case 1 this is created for you. In case 2 you
> have to manually set it up. In case 3 it uses the active ClojureScript
> REPL's environment.
>
> This is all very experimental. I hope it gives you some good ideas for
> where to start.
>
> Thanks,
> Brenton
>
> On Feb 25, 11:34 pm, Shantanu Kumar  wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > Has anybody got clojure.test working with ClojureScript? Is it planned
> > for clojure.test to eventually work on ClojureScript?
>
> > Shantanu

-- 
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: named/numbered releases?

2012-03-08 Thread kovas boguta
Thanks.

I was just going on the information on the github wiki pages, and
poking around the tags and branches.

Part of the confusion is that the tags are large integers, with no
"0." prefixes. I concluded that they corresponded to a jira ticket
rather than to some kind of release number.


On Thu, Mar 8, 2012 at 7:28 AM, Stuart Campbell  wrote:
> Hello,
>
> According to a past thread
> (https://groups.google.com/forum/?fromgroups#!topic/clojure/L4e8DtzdThY):
>
>> ClojureScript has no "release" versions yet. Instead we have a
>> revision number, calculated as the number of commits on the master
>> branch since the beginning of the project. ClojureScript is currently
>> at revision 927. In Maven/Leiningen, this is represented as version
>> "0.0-927".
>
>
> The latest release is 0.0-993.
>
> Regards,
> Stuart
>
> On 8 March 2012 15:02, kovas boguta  wrote:
>>
>> It's great to see the steady activity on the clojurescript github page.
>>
>> However I'm not totally comfortable developing against the master branch.
>>
>> As it stands now, if I change development environments, or deploy on a
>> new machine, the master branch may have moved.
>>
>> I could choose an arbitrary commit as my stable reference point,  and
>> periodically make a judgement call about upgrading to a new arbitrary
>> commit, but thats not easy for someone not involved in the internals.
>>
>> I gather this is still "pre-1.0" , but it would still be nice to have
>> some incremental version numbers to rationalize things.
>>
>> thanks for listening.
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


idiomatic list-ify

2012-03-08 Thread Brandon Harvey
Hi,

I'm seeking a small & idiomatic function that will take input and ensure 
it's wrapped in a list.  If nil, I'd like the list to be empty.  If the 
input is already a list, I don't want to wrap it in another list layer.  So:

  "hi"   => ("hi")
  nil=> ()
  ("hi") => ("hi")

 (list '("hi")) => (("hi"))  ; bad
 (apply list "hi")  => (\h \i)   ; bad

So I've ended up writing the function with a conditional, like so.  Is 
there a tidier way?

(defn ls [x] (cond (list? x) (apply list x) 
   (nil? x)  '() 
   :else (list x)))

-- 
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] Way to avoid function call indirection in deftypes?

2012-03-08 Thread Philip K
I see the rationale now, thanks. One question though, isn't it possible to 
generate:

if (self && self.func) {
  return self.func(self);
}

instead of

if (truth(truth(self) ? self.func : self)) {
  return self.func(self);
}

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

clojure.io

2012-03-08 Thread cej38
This is a NOOB question.

Would it be possible to write a library that could do IO without
resorting to the underlying VM?

-- 
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] Way to avoid function call indirection in deftypes?

2012-03-08 Thread David Nolen
Nope, JavaScript has a terrible notion of truth. What if you want to add
functionality to numbers? Or strings? 0 and blank strings are false-y.

That said I have a branch where we inline the truth test which does a give
a perf boost on many JS engines. This needs to benchmarked more thoroughly
before we consider merging it in.

David

On Thu, Mar 8, 2012 at 3:13 PM, Philip K  wrote:

> I see the rationale now, thanks. One question though, isn't it possible to
> generate:
>
> if (self && self.func) {
>   return self.func(self);
> }
>
> instead of
>
> if (truth(truth(self) ? self.func : self)) {
>   return self.func(self);
> }
>
>  --
> 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.io

2012-03-08 Thread Jeremy Heiler
On Thu, Mar 8, 2012 at 4:12 PM, cej38  wrote:
> Would it be possible to write a library that could do IO without
> resorting to the underlying VM?

What do you mean by that? Do you want to restrict yourself to a
particular platform?

I think a more prudent question would be: Should there be a standard
Clojure IO API that each flavor of Clojure would implement?

-- 
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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread evandi
Why not avoid all the keywords and create let-cond?

(let-cond [a x b (* a 4)]
  (> b x) 1
  :else 2)

On Thursday, March 8, 2012 9:01:33 AM UTC-8, Evan Gamble wrote:
>
> Another way to flatten nested lets and conds is to use a macro that 
> lets you insert conditionals in your lets (vs. your suggestion of 
> inserting lets in conds). 
>
> I wrote a let? macro that does that: https://github.com/egamble/let-else 
>
> - Evan 
>
> On Mar 7, 10:51 pm, Mark Engelberg  wrote: 
>
> > In the meantime, I *strongly urge* everyone to check out Grand's flatter 
> > cond macro:
> https://github.com/cgrand/parsley/blob/master/src/net/cgrand/parsley/... 
> > 
> > It lets you insert lets in the middle of cond expressions (like you can 
> > currently do with for) like: 
> > (cond 
> >(pos? x) 2 
> >:let [y (* x x)] 
> > (> y 20) 4)) 
> > 
> > This totally transformed my coding style and improved the readability of 
> my 
> > code substantially.  Highly recommended.  Since it is backwards 
> compatible, 
> > I very much wish it were part of the core, and see no reason that it 
> > couldn't be. 
> > 
> > --Mark

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

2012-03-08 Thread cej38

>Should there be a standard Clojure IO API that each flavor of Clojure would 
>implement?


You are correct.  This is more of what my question should have been.
I do NOT want to restrict myself to a particular platform.

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


Functions knowing whether they're thread-bound or not?

2012-03-08 Thread Mark
Over in the clojure dev group, there's a discussion going on the overhead 
of sending thread-bound functions (by which, I think means a function that 
takes input from a thread-local) to an agent.  Functions that are 
thread-bound require the overhead of copying thread-local state to the 
agent's thread while functions that don't, don't so why incur it?  The 
question posed was whose responsibility is it to determine if the 
thread-local copying behavior is necessary:  the client or the agent?  It 
got me thinking...

Can functions carry metadata directly?  If so, would it be possible for a 
function to be compiled with the knowledge of its inputs, both parameter 
lists and thread-locals?  If this is feasible, then the send & send-off 
functions can easily optimize for the non-thread-bound case without making 
it the responsibility of the client.

-- 
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: idiomatic list-ify

2012-03-08 Thread Allen Johnson
> So I've ended up writing the function with a conditional, like so.  Is there
> a tidier way?
>
> (defn ls [x] (cond (list? x) (apply list x)
>                    (nil? x)  '()
>                    :else (list x)))

If `x` is a list then is the call to `(apply list x)` necessary?

(defn ls [x]
  (cond
(list? x) x
(nil? x) ()
:else (list x)))

Allen

-- 
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] Way to avoid function call indirection in deftypes?

2012-03-08 Thread Philip K

>
> Nope, JavaScript has a terrible notion of truth. What if you want to add 
> functionality to numbers? Or strings? 0 and blank strings are false-y.
>
> That said I have a branch where we inline the truth test which does a give 
> a perf boost on many JS engines. This needs to benchmarked more thoroughly 
> before we consider merging it in.
>

So is the inline truth test only done in special cases then? Or have 
I misunderstood something? 

-- 
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] Way to avoid function call indirection in deftypes?

2012-03-08 Thread David Nolen
In my branch the truth test is always inlined. Support for type-hints and
inference in the compiler could simplify the test when possible.

On Thursday, March 8, 2012, Philip K  wrote:
>> Nope, JavaScript has a terrible notion of truth. What if you want to add
functionality to numbers? Or strings? 0 and blank strings are false-y.
>> That said I have a branch where we inline the truth test which does a
give a perf boost on many JS engines. This needs to benchmarked more
thoroughly before we consider merging it in.
>
> So is the inline truth test only done in special cases then? Or have
I misunderstood something?
>
> --
> 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 on android over CLI

2012-03-08 Thread Daniel Solano Gomez
Hello,

On Thu Mar  8 02:43 2012, Rostislav Svoboda wrote:
> Hi. I'm trying to run:
> java -cp clojure-${VERSION}.jar clojure.main
> 
> on an Android phone from bash (using the 'terminal-ide' app) but I
> can't make it past the error bellow. I did the jar-to-dex conversion
> using:
> dx --verbose --dex --output=clojure-${VERSION}.dex.jar
> clojure-${VERSION}.jar
> 
> for clojure-1.3.0.jar, clojure-1.3.0-slim.jar and even for the clojure
> clone for Android Neko Toolkit from Daniel Solano Gómez:
>   https://github.com/sattvik/clojure.git
> 
> Does anyone know what I missed? Thx in advance
> 
> Bost

I don't use the terminal-ide app, so I have no idea of how its
implementation of the java command works.  So I am not sure I have any
specific ideas that can help you.

In general, Android differs from the standard JVM in how classes are
packed into a JAR.

You can have a source-only JAR that works with Java.  For example, given
the namespace 'my.app.core', it could be packaged as follows:

app-slim.jar:
  /my/app/core.clj

If you were to AOT-compile the class, the you would get something like
this:

app.jar:
  /my/app/core__init.class
  /my/app/core$foo.class
  /my/app/core$bar.class
  /my/app/core$baz.class

With Android, all of the classes are processed and written to a single
classes.dex, which is placed at the root of the package:

app.apk:
  /classes.dex


Now, some comments about your stack traces:

>   Now searching: clojure-1.3.0.dex.jar
> found
> java.lang.ExceptionInInitializerError
> at java.lang.reflect.Method.invokeNative(Native Method)
> at java.lang.reflect.Method.invoke(Method.java:507)
> at com.spartacusrex.spartacuside.external.java.main(java.java:124)
> at dalvik.system.NativeStart.main(Native Method)
> Caused by: java.lang.ExceptionInInitializerError
> at clojure.main.(main.java:20)
> ... 4 more
> Caused by: java.lang.RuntimeException: java.io.FileNotFoundException:
> Could not locate clojure/core__init.class or clojure/core.clj on
> classpath:
> at clojure.lang.Util.runtimeException(Util.java:165)
> at clojure.lang.RT.(RT.java:319)
> ... 5 more
> Caused by: java.io.FileNotFoundException: Could not locate
> clojure/core__init.class or clojure/core.clj on classpath:
> at clojure.lang.RT.load(RT.java:430)
> at clojure.lang.RT.load(RT.java:398)
> at clojure.lang.RT.doInit(RT.java:434)
> at clojure.lang.RT.(RT.java:316)
> ... 5 more

Just out of curiousity, which version Android are you testing this on?
Now that I think of it, this looks vaguely familiar to a problem I ran
into with Eclair.  At one level, you can see that some of the Clojure
code is running, but it fails when it tries to bootstrap 'clojure.core'.
This may be due the classpath not being quite right.  In an Android
application, there is usually a thread-context classloader where Clojure
finds its own classes.  Perhaps the java implementation here isn't
setting things up quite right?

> In case of the clojure clone for Daniel Solano Gómez:
> 
>   Now searching: clojure-1.4.0-master-SNAPSHOT.dex.jar
> found
> java.lang.ExceptionInInitializerError
> at java.lang.reflect.Method.invokeNative(Native Method)
> at java.lang.reflect.Method.invoke(Method.java:507)
> at com.spartacusrex.spartacuside.external.java.main(java.java:124)
> at dalvik.system.NativeStart.main(Native Method)
> Caused by: java.lang.ExceptionInInitializerError
> at clojure.main.(main.java:20)
> ... 4 more
> Caused by: java.lang.ExceptionInInitializerError
> at java.lang.Class.classForName(Native Method)
> at java.lang.Class.forName(Class.java:234)
> at java.lang.Class.forName(Class.java:181)
> at clojure.lang.RT.(RT.java:235)
> ... 5 more
> Caused by: java.lang.ExceptionInInitializerError
> at android.os.Build$VERSION.(Build.java:75)
> ... 9 more
> Caused by: java.lang.UnsatisfiedLinkError: native_get
> at android.os.SystemProperties.native_get(Native Method)
> at android.os.SystemProperties.get(SystemProperties.java:59)
> at android.os.Build.getString(Build.java:216)
> at android.os.Build.(Build.java:27)
> ... 10 more


This version does not get quite as far as the first.  This is seems to
fail during a reflective call to load android.os.Build.VERSION.
Apparently, there is some native library function that isn't being
found.  I am guessing this might be related to how the java command is
implemented in TermIDE.

Off-hand, after taking a brief glance at TermIDE's source, my guess that
the easiest way to fix it would be to modify the
com.spartacusrex.spartacuside.external.java class from TermIDE to set
current thread's context loader to the dexclassloader created there.  I
think that will work.

Sincerely,

Daniel

> 
> -- 
> You received this message because you are subscribed to the Google
> Group

Re: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Evan Gamble
That would work for replacing a single cond surrounded by a single
let, but I often find myself writing a series of nested lets, when-
lets, if-lets, etc. to handle the exceptional cases in lets. A
contrived example:

(when-let [a foo]
  (let [b bar]
(when (even? b)
  (let [c baz]
 (when (> b c)
(let [d qux]
   (f a b c d)))

becomes:

(let? [a foo :else nil
   b bar :is even?
   c baz :when (> b c)
   d qux]
 (f a b c d))

On Mar 8, 1:24 pm, evandi  wrote:
> Why not avoid all the keywords and create let-cond?
>
> (let-cond [a x b (* a 4)]
>   (> b x) 1
>   :else 2)
>
>
>
>
>
>
>
> On Thursday, March 8, 2012 9:01:33 AM UTC-8, Evan Gamble wrote:
>
> > Another way to flatten nested lets and conds is to use a macro that
> > lets you insert conditionals in your lets (vs. your suggestion of
> > inserting lets in conds).
>
> > I wrote a let? macro that does that:https://github.com/egamble/let-else
>
> > - Evan
>
> > On Mar 7, 10:51 pm, Mark Engelberg  wrote:
>
> > > In the meantime, I *strongly urge* everyone to check out Grand's flatter
> > > cond macro:
> >https://github.com/cgrand/parsley/blob/master/src/net/cgrand/parsley/...
>
> > > It lets you insert lets in the middle of cond expressions (like you can
> > > currently do with for) like:
> > > (cond
> > >    (pos? x) 2
> > >    :let [y (* x x)]
> > >     (> y 20) 4))
>
> > > This totally transformed my coding style and improved the readability of
> > my
> > > code substantially.  Highly recommended.  Since it is backwards
> > compatible,
> > > I very much wish it were part of the core, and see no reason that it
> > > couldn't be.
>
> > > --Mark

-- 
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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Mark Engelberg
On Thu, Mar 8, 2012 at 6:04 PM, Evan Gamble  wrote:

> That would work for replacing a single cond surrounded by a single
> let, but I often find myself writing a series of nested lets, when-
> lets, if-lets, etc. to handle the exceptional cases in lets. A
> contrived example:
>
> (when-let [a foo]
>  (let [b bar]
>(when (even? b)
>  (let [c baz]
> (when (> b c)
>(let [d qux]
>   (f a b c d)))
>
> becomes:
>
> (let? [a foo :else nil
>   b bar :is even?
>   c baz :when (> b c)
>   d qux]
>  (f a b c d))
>
>
Right, I do run across this sort of nesting on a regular basis, and that's
the kind of thing that that bothers me.  With the cond macro, it would look
like:

(cond
  :when-let [a foo]
  :let [b bar]
  :when (even? b)
  :let [c baz]
  :when (> b z)
  :let [d gux]
  (f a b c d))

The cond is more faithful to the original structure and possibly more
versatile, but yours is nicely compact for the common case that the
interleaved statements are basically assertions on a given variable you
want to ensure before moving on.  I'm definitely going to give your let? a
try and compare it.  Thanks!

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Mark Engelberg
On Thu, Mar 8, 2012 at 9:44 AM, Laurent PETIT wrote:

> You should probably both share gists of real code you're talking about,
> shouldn't you ?
>

Most of the stuff I'm working on is closed-source.  Offhand, I'm not sure
what examples I can share, but I'll keep an eye out for that.

In the meantime, just to get a feel for whether this is unique to my code
or universal, I decided that I was going to carefully scrutinize the
nesting level of the next public Clojure code I encountered.  Completely
randomly, the next Clojure code I encountered was this blog post:
http://blog.japila.pl/2012/03/block-scanner-from-let-over-lambda-in-clojure

Take a look at how indented the code is after merely 10 lines of code.  We
start to take this for granted in Clojure, but if you look at it with a
fresh eye, it really is ridiculous.


> Your discussion made me think that editors may help further in this area,
> without having to change the syntax.
> Currently, the editors only try to give some "hints" by playing with
> colors, but there are some other ideas that could be followed:
> - playing with contrast by also using the ability to change the fonts
> - playing with contrast by slowly decreasing the font's opacity as the
> code gets deeper (but where the cursor is, this should probably go away to
> ensure good visibility) => could help see the overall structure without
> seeing to much of the details?
> - playing with "proximity" by adjusting the line sizes. For example, there
> could be extra space around the "true" and "false" clauses of an if, there
> could be extra space around "condition/then" clauses of a cond, etc.
> - playing with the background color of blocks, potentially minimizing (and
> to some extend -in a modal structural editor- almost removing from sight)
> the parens
>
> - since it's not the same thing to "write/edit" and to "read" code, there
> could be the possibility to have a "read" mode where the editor could
> represent totally differently the source code (think it could even present
> it in some sort of prefix-notation :-) )
>
>
I love these ideas.  I think your final comment is especially insightful.
I have no problem writing Clojure code, I just find it unnecessarily taxing
to read it.  The idea of separating the two, and possibly having a
read-mode is an absolutely fascinating idea.  In some sense, Marginalia is
already a good positive step in this direction.  The first time I ran
Marginalia on my code I was astonished at how much more readable it was to
have the comments in a separate column alongside the code, rather than
interrupting the code itself.  It makes me wonder how many other things
could have such a positive, dramatic effect.

-- 
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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Mark Engelberg
On Thu, Mar 8, 2012 at 9:33 AM, Sean Corfield wrote:

> I'm interested in hearing more
> about the sort of functions that begin "by unpacking and computing a
> large number of values that are all important for subsequent
> computations". I'm not seeing this in my code so I assume we're
> working on very different problem domains - could you elaborate?
>
>
I can't show my closed-source code, but I'll try to elaborate to give you
an idea where I'm coming from.

I'm working with trees where the nodes can have a lot of attributes
associated with them.  I represent the nodes as maps like
{:tag 
 :data 
 :children 
 :attribute1 ___
 :attribute2 ___}

When working with a tree node, not only do I have to destructure/unpack a
lot of these attributes, but often, there are several "measurements" I
need, which are computationally intensive because computing those
measurements generally involves walking the tree.

Not all nodes have all the attributes, so there is a fair amount of testing
as I'm destructuring and computing these measurements to make sure I'm
doing the right thing.  I use multimethods, dispatching on :tag, to handle
certain types of context-sensitive behavior, but that alone doesn't handle
all the dynamic combinations of attributes that can occur.

If the helper function is external to the main function, that becomes a lot
of stuff that needs to be passed along and immediately destructured at the
other end.

-- 
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: [ANN] Leiningen 2.0.0-preview1

2012-03-08 Thread Phil Hagelberg
Phil Hagelberg  writes:

> Just found a bug that only manifests when you don't have any profiles
> and are running outside a project.

I released a 2.0.0-preview2 version with this fix. If you are running
the old preview, running "lein2 upgrade" should take care of it.

thanks,
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: How to use goog.dom.query

2012-03-08 Thread Brent Millare
>From what I understand, the third-party libraries are only packaged as part 
of the github, but not as a part of the goog.jar. You can use the :libs 
option to add the third party google compatible javascript files separately.

On Thursday, March 8, 2012 2:58:46 AM UTC-5, Evan Mezeske wrote:
>
> Just a word of warning:  I've had several reports of people encountering 
> difficulties (e.g. weird stack traces) when trying to use a recent 
> ClojureScript compiler with the various "goog" jars that are flying around. 
>  Presumably this is due to the fact that the compiler depends on the Google 
> Closure Library, which conflicts with most of the goog jars (which also 
> include the Closure Library, but typically a newer version of it).
>
> It seems like it would be good if someone broke out the third-party 
> Closure libraries into a separate jar that did not include the base Closure 
> Library, to avoid these conflicts.
>
> I myself am guilty of packaging the Closure Library together with the 
> third party stuff (https://github.com/emezeske/closure-library).  It 
> would be trivial to fork this repo and provide a third-party-only library, 
> I think...
>
> On Tuesday, January 24, 2012 4:47:38 PM UTC-7, Dave Sann wrote:
>>
>> The third party libs are not included in the std closurescript jar.
>>
>> pinot requires a modified jar that contains the extra libs. If you follow 
>> the instructions for pinot - you can get this lib and install it - it's 
>> fairly painless.
>>
>> I don't know of an easy way to include these without doing this.
>>
>> There is a version with a newer closure library here:
>>
>>- https://github.com/davesann/clojurescript-goog-jar
>>
>> (It is currently this version of the closure library : 
>> closure-library-2010-r1376.zip)
>>
>> I made some notes on how I created this here: 
>>
>>- https://groups.google.com/d/topic/clj-noir/x5x9vcI-T4E/discussion
>>
>>
>> Cheers
>>
>> 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: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Meikel Brandmeyer (kotarak)
Hi,

Am Freitag, 9. März 2012 03:12:52 UTC+1 schrieb puzzler:
>
>
> (cond
>   :when-let [a foo]
>   :let [b bar]
>   :when (even? b)
>   :let [c baz]
>   :when (> b z)
>   :let [d gux]
>   (f a b c d))
>
>
I wonder how long it will take until someone proposes monads.

(domonad
  [a foo]
  [b bar]
  :when (even? b)
  [c baz]
  :when (> b z)
  [d guz]
  (f a b c d))

Combined with maybe the Maybe monad?

Just a thought.

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: Why don't extends? and satisfies? require implementation of all protocol methods?

2012-03-08 Thread Garth Sheldon-Coulson
I think Tassilo's ideas about extenders deserve more discussion. But let me 
continue the discussion with Armando for now.

Thank you for offering the Eclipse API example, which is very helpful. I 
agree that Java's OO paradigm creates the need for abstract classes. 
However, I would like to look further at what is going on in the Eclipse 
example and consider if protocols in Clojure are the same or different.

To clarify the example: Eclipse allows the user to add the user's own 
methods for certain kinds of event-handling. Because the language is Java, 
these methods must be attached to a class. In order for Eclipse to specify 
which methods it expects, Eclipse provides an interface that the user's 
class must implement. For convenience, Eclipse also provides default 
implementations of the required methods; these are provided in an abstract 
class. When the user extends this abstract class, the user can elect to 
override none, some, or all of the default methods.

I have a few observations.

1) In the example, it is certainly true that the user may implement none or 
just some of the methods of the interface. However, when the user finally 
passes an object instance to Eclipse, *all* of the methods of the interface 
are in fact implemented by that instance. This is because the default 
implementations in the abstract class will fill any holes the user leaves. 
Therefore, I respectfully disagree that this is case of "partial 
implementation." It may appear so to the user, but not to the language.

2) It is true that a Java abstract class can partially implement an 
interface. However, an abstract class cannot be instantiated. It must be 
extended first. When extending an abstract class, the user must implement 
any methods that the abstract class has not implemented. No concrete class 
"partially implements" an interface.

To me, the analogy to Java therefore supports the idea that the extends? 
relationship ought to require a datatype/record to implement all of its 
protocols' methods. A datatype/record is a piece of data, not a collection 
of default methods; it is therefore like an object instance, not an 
abstract class. Object instances must implement all of their interfaces' 
methods.

As I said in my last post, it would seem strange for a language to provide 
protocols (rather than just fast, un-grouped multimethods) if a piece of 
data that "satisfies" a protocol does not necessarily implement even one of 
the protocol's methods.

3) Armando's worry is valid that requiring implementation of protocol 
methods would result in "proliferation of interfaces and protocols that 
would prevent reuse; something like 
ListWithoutModificationOrBulkOperations." 

However, to me the beauty of protocols is that they can be highly granular. 
They are not tied to a rigid inheritance paradigm. They support direct 
implementation composition. If, per Armando's example, a protocol designer 
felt the need to have a BasicList protocol, a ModifiableList protocol, and 
a BulkOperations protocol, to be combined as necessary, that would be just 
fine. 

4) In /The Joy of Clojure/, a few of the examples involve extending a type 
to implement just one of a protocol's multiple methods (pp. 193-195). The 
authors consider this a valid use case. To leave the /JoC/ examples roughly 
intact while giving protocols a bit more bite, let me throw out two ideas 
for discussion.

Idea 1
==

Types may be extended to a strict subset of a protocol's methods, but 
satisfies? and extends? will return FALSE, not true, in this case. That is:

=> (defprotocol Fixo
 (fixo-push [fixo value])
 (fixo-pop [fixo]))
Fixo
  
=> (extend-type clojure.lang.IPersistentVector
 Fixo
 (fixo-push [vector value]
   (conj vector value)))
[succeeds]

=> (extends? Fixo clojure.lang.IPersistentVector)
FALSE, not true


Idea 2
==

Types may be extended to new protocols only if *all* of the protocol's 
methods are implemented. However, types may be always extended tonew, 
ungrouped *methods*. That is:

=> (defprotocol Fixo
 (fixo-push [fixo value])
 (fixo-pop [fixo]))
Fixo
  
=> (extend-type clojure.lang.IPersistentVector
 Fixo
 (fixo-push [vector value]
   (conj vector value)))
[should FAIL - protocol name not allowed here unless all methods are 
implemented]  

=> (extend-type clojure.lang.IPersistentVector
 nil
 (fixo-push [vector value]
   (conj vector value)))
[should SUCCEED - fixo-push is like a fast multimethod, without a named 
protocol]

=> (extends? Fixo clojure.lang.IPersistentVector)
FALSE, not true


I invite discussion and criticism.

All the best, Garth


On Thursday, March 8, 2012 11:24:42 AM UTC-5, Armando Blancas wrote:
>
> (Don't know why I can only respond to the first message.)
>
> I come across partial implementation all the time, and with proxy, too. In 
> Eclipse this is so common that this is typical:
>
> "This adapter class provides default implementations for the methods 

Re: Can Clojure be as readable as Python or Ruby ?

2012-03-08 Thread Tassilo Horn
Mark Engelberg  writes:

Hi Mark,

> In the meantime, just to get a feel for whether this is unique to my code
> or universal, I decided that I was going to carefully scrutinize the
> nesting level of the next public Clojure code I encountered.  Completely
> randomly, the next Clojure code I encountered was this blog post:
> http://blog.japila.pl/2012/03/block-scanner-from-let-over-lambda-in-clojure
>
> Take a look at how indented the code is after merely 10 lines of code.  We
> start to take this for granted in Clojure, but if you look at it with a
> fresh eye, it really is ridiculous.

In some book (I think some Common Lisp book), I've read that code
leaning to the right is a pretty good indicator for code written in a
functional style.  If it's straight top-down, then it's probably more
imperative with one outer let and setf-ing of that let's variables.

That said, of course there's nothing wrong with macros like the cond
with :let or the let? in this thread.  They look really useful, and I
think I have some spots in my code where I could make use of them.

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