-XX:PermSize=512m prevents performance degradation over time

2010-02-04 Thread Albert Cardona
Hi all,

I wanted to share a JVM setting that is improving clojure performance
(for me) in long running processes: MaxPermSize and PermSize, which
define the size of the permanent generation in the garbage collector.

I am doing heavy image processing, with many long-lived objects.
Performance is great until, after 10 minutes or so from launching the
JVM, the garbage collector seems to be running almost all the time. A
look at the heap with "Control+\" on the terminal that runs java shows
that the permanent generation is at 99% capacity, and the "eden",
"from" and "to" spaces are at 0% !

The default permanent size is apparently 32 megabytes in jdk1.6.0_17
in an 8-core intel 64-bit machine with 16 Gb of RAM. The permanent
size, according to JVM docs, stores objects that are seldom or never
in need of being collected, like literal String instances and Class
instances.

So this is how I run the JVM in a 64-bit machine with 8 cores and 16
Gb of RAM, for image processing:

java -Xms6g -Xmx6g --Xingc -XX:PermSize=512m -XX:MaxPermSize=512m
-XX:CMSTriggerRatio=50 -XX:ParallelGCThreads=3 -XX:NewRatio=5

The fixed heap size helps. The incremental garbage collector also
helps a lot--very few or no pauses. I reduced the number of parallel
GC threads to 3 (defaults to as many as cores, if I recall correctly).
And the NewRatio, which is the proportion of "eden" versus old or
cms-generation, is 1:8 by default--so I made eden a bit bigger to
prevent the GC from running too often. Finally, the lower
CMSTriggerRatio (default is I think 80%) helps in triggering
concurrent garbage collector before little heap remains free (which,
when dealing with large images, may result in long pauses if its
triggered too late).

Performance does not degrade anymore. (Of course, YMMV.)

[I have found by the way a list of nearly all JVM flags for 1.6.0 with
minimal explanations here: http://www.md.pp.ru/~eu/jdk6options.html ]

Hope that helps somebody.

Albert
--
Albert Cardona
http://albert.rierol.net

-- 
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: set/select vs. other set functions: argument order and ->

2010-02-04 Thread Tayssir John Gabbour
On Feb 4, 3:31 am, wlr  wrote:
> (-> #{{:a 1, :b 1, :c 1}
>{:a 2, :b 2, :c 2}
>{:a 3, :b 3, :c 3}}
>(->> (select #(= (:a %) 1)))
>(project [:b :c]))
>
> => #{{:c 1, :b 1}}

Ahhh.. what a tricky language. ;) This saves me from writing reverse-
args or select*, so this succinct workaround may be my default.


Thanks,
Tayssir

-- 
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: Naming Functions...

2010-02-04 Thread Laurent PETIT
I would do as you do, finding a name, hopefully good enough to prevent
an imperative need to jump to the function definition when re-reading
the code 6 months later.

Anyway, would you have written this particular function as a method of
a class, would the problem of giving it a "short but meaningful name"
rather than "long and meaningful name" have been easier ?

2010/2/4 Wardrop :
> I often myself creating functions which perform a rather clear and
> simple task, but which is hard to describe, either because I don't
> know the term for what I've just implemented, or because the function
> is difficult to summarise in a couple of words. As an example, I've
> just created a function which determines how many times the value n,
> can be divided by the base, until n becomes smaller than the base.
> Here's the implementation...
>
> (defn  [n base]
>  (loop [n n count 0]
>    (if (< n base)
>      {:val n :count count}
>      (recur (float (/ n base)) (inc count)
>
> This can be used among other things, to determine how to format bytes.
> Say I have a file that's 6,789,354 bytes, and I want to display that
> in a more readable manner, I could use my unnamed function like so
> ( 6789354 1024), and get a new appropriately rounded number,
> including the number of times it has been rounded, which I can use the
> pick the appropriate suffix from a list ("Bytes", "KB", "MB", "GB",
> "TB).
>
> I mean, what the hell would you name this function, or would you not
> create such an obscure and generalised function to start with?
>
> On Feb 4, 3:15 pm, Jonathan Smith  wrote:
>> A function would be named based on what it is that it does.
>>
>> Difficulty naming functions would imply to me that the functions
>> involved do not contain a clear functionality.
>>
>> The names of the functions should sort of be an 'emergent property' of
>> a larger process of reasoning through the programming problem.
>>
>> As I see it, there are two ways to do this...
>> The first (systematic):
>>
>> 1.) break the program into reasonable steps
>>     (a concise description of the step being the function name)
>> 2.) make a function for each step.
>> 3.) break each function into steps
>> 4.) goto 2 until you are able to describe different pieces of the
>> program in the base language.
>>
>> the second (haphazard):
>> 1.) start writing code into a function (name of overall functionality)
>> 2.) when the code gets to a certain size,  decide that you have too
>> much code in the function.
>> 3.) look for different pieces of the task that you could potentially
>> pull out and name, or patterns that repeat more than once.
>> 4.) pull them out and use them as functions.
>> 5.) loop through this process of expanding the code and rewriting it
>> until you are done.
>>
>> I could write these as functions
>>
>> (defn systematic [idea]
>>   (let [sub-ideas (partition-idea idea)]
>>          (map #(unless (atomic? %1) (systematic %1)) sub-ideas))
>>
>> (defn haphazard [functionality]
>>   (let [[refactored-functionality & new-functions] (extract-
>> functionality functionality)]
>>   (map #(unless (atomic? %1) (haphazard %1)) new-functions)))
>>
>> Ideally these functions lead to the same output.
>> In my use of map I am assuming a lazy programmer without a deadline.
>> In the case of a motivated programmer, we might use dolist.
>> In the case of a lazy programmer with a deadline, we might use doall
>> or dorun..
>>
>> >On Feb 3, 10:47 pm, Wardrop  wrote:
>> > I've always struggled when it comes to defining good names for
>> > functions and methods. Now that I'm learning Clojure, function naming
>> > becomes even more imperative, as you don't have classes and objects to
>> > help give meaning to a method. I'm finding at the moment that I'm
>> > spending half my time thinking of decent names for functions. I'm just
>> > wondering what process you all use when it comes to naming functions?
>
> --
> 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: Naming Functions...

2010-02-04 Thread Michał Marczyk
On 4 February 2010 08:04, Wardrop  wrote:
> (defn  [n base]
>  (loop [n n count 0]
>    (if (< n base)
>      {:val n :count count}
>      (recur (float (/ n base)) (inc count)
>
> [ ... ]
>
> I mean, what the hell would you name this function, or would you not
> create such an obscure and generalised function to start with?

How about significand-and-exponent-in-radix? :-)

(Or for a shorter name maybe sci-notation-map or something...)

In fact, I might generalise it further to accept an optional argument
-- defaulting to 0 -- to determine how the result is to be normalised:

user> (defn significand-and-exponent-in-radix
([n radix] (significand-and-exponent-in-radix n radix 1))
([n radix o]
   (let [threshold (Math/pow radix o)]
 (loop [n n count 0]
   (if (< n threshold)
 {:significand n :exponent count}
 (recur (double (/ n radix)) (inc count)))
#'user/significand-and-exponent-in-radix
user> (Math/pow 10 1)
10.0
user> (significand-and-exponent-in-radix 1000 10)
{:significand 1.0, :exponent 3}
user> (significand-and-exponent-in-radix 1000 10 0)
{:significand 0.1, :exponent 4}

Also, add docstrings. With the REPL at hand, the explanation of
anything unclear from your function's name is one (doc ...) call away
if you do.

All best,
Michał

-- 
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: Proposal: New fn assoc-in-with

2010-02-04 Thread Sean Devlin
Some "Thinking out loud" here...

My last concern with assoc-in & arrays has to do with how it is
currently used for maps.  The way it creates elegant nested structures
is nice, and it requires very little understanding of the current
structure of the map.

However, assoc-in has a few more constraints when dealing w/ arrays,
and the end user does have to keep track of array structure.  Granted
they have to do this anyway by the nature of arrays.  I personally
always use conj when creating a vector of vectors, so I don't se much
of a use case (Hmmm...  Sparse Matrix?  That's better as a map...).

I DO see a great use case for update-in-with working on vectors, so
maybe assoc-in-with working on vectors should be implemented simply
for symmetry.

I dunno.  That's all I've got right now.

On Feb 3, 11:03 am, Rich Hickey  wrote:
> On Fri, Jan 29, 2010 at 8:53 AM, Sean Devlin  wrote:
> > The following doesn't currently work:
>
> > user=> (assoc [] 1 :a)
> > #
>
> But this does:
>
> user=> (assoc [] 0 :a)
>
> [:a]
>
> > So I say this should be map only.
>
> I don't think so.
>
> > Also, what do you mean by your question "Where would the default go"?
> > I don't understand what you're getting at yet.
>
> Just a question of arg order.
>
> Rich

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


Pattern Matching

2010-02-04 Thread Sean Devlin
Do we have a concise way of doing this?  Is it actually useful?

http://www.artima.com/weblogs/viewpost.jsp?thread=281160

Sean

-- 
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: set/select vs. other set functions: argument order and ->

2010-02-04 Thread wlr
Well, I think you've exposed an inconsistency in the signature of
clojure.set/select vis-a-vis the "collection first, sequence last"
principles here:

http://groups.google.com/group/clojure/msg/a8866d34b601ff43

It seems that the collection function clojure.set/select is patterned
after
the sequence function clojure.core/filter instead.

-- 
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: Pattern Matching

2010-02-04 Thread Tayssir John Gabbour
Hi,

On Feb 4, 3:08 pm, Sean Devlin  wrote:
> Do we have a concise way of doing this?  Is it actually useful?
> http://www.artima.com/weblogs/viewpost.jsp?thread=281160

Yep, see clojure.contrib.types/match.

I recently used it in an almost frivolous way in this thread, because
I thought it was pretty and intensely readable:
http://groups.google.com/group/comp.lang.lisp/msg/80cfc28feaf4a1e9

I can't say I haven't used pattern matching as much as I probably
should, unless we count destructuring, regexes and an Eliza-like thing
I once wrote as part of an NLP project. Haskellers seem to use it a
lot, I get the impression.


All the best,
Tayssir

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


Closures and environments

2010-02-04 Thread Ludovic Kuty
Hello,

I was wondering if symbol resolution in local scope (in a let or
function body) works the same way as it is in Scheme. I would like to
know some internals of Clojure when it comes to that. I thought about
explaining how closures work to my students using that analogy (is it
just an analogy ?), which I find to be an particularly clear way to
proceed but I want to avoid talking specifically about Scheme when I
want to talk about Clojure. Unless both are the same with respect to
this matter.

In Scheme, when a function is defined, a closure is created and is
composed of code (the body of the function) and an environment which
captures needed lexical bindings. When the closure is called (applied
to arguments), a new lexical environment is created to contain the
bindings of the arguments and that new environment is linked to the
one used in the definition of the function (points to). So, if we use
a variable in the body of the function, we look first in the new
environment and then in the other environment.

There could be a chaining of lexical environments.

There is an elegant notation to describe that process called
"Weizenbaum notation" but I was not able to find any source on it on
the Web. I used that when I studied Scheme in school, back in 97. If
anynone has got information on it, I would be glad. I guess it is
related to Joseph Weizenbaum.
We had, a control environment, an access environment, a form to be
evaluated and bindings in the current environment (terms translated
from french as the course was given in french). All in a concise
Weizenbaum frame.

Does it work the same in Clojure ? Or maybe someone could point me to
the source file ou source files where I can find that information.

TIA,

Ludovic Kuty

-- 
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: Proposal: New fn assoc-in-with

2010-02-04 Thread ajuc
Maybe sth like that

(defn assoc-in-maybe-creating [coll keys creator-fns value] ...)

so it can be used:

(assoc-in-maybe-creating
  [ {:a (sorted-map :X 1, :Y 2, :Z 3)
 :c (sorted-map :X 1, :Z 3)}
{:b (sorted-map :X 1, :Y 2, :Z 3)}
{:f  (sorted-map :X 1, :Y 2)}]
  [0 :b :X]
  [vector hashmap sorted-map]
  1)

returning

  [ {:a (sorted-map :X 1, :Y 2, :Z 3)
 :b (sorted-map :X 1)
 :c (sorted-map :X 1, :Z 3)}
{:b (sorted-map :X 1, :Y 2, :Z 3)}
{:f  (sorted-map :X 1, :Y 2)}]

or like that

(assoc-in-maybe-creating
  []
  [0 :a :Y]
  [vector hashmap (fn []
   (struct-map CustomStruct
:required-field1 value1 :required-field2 value2))]
  2)

Name is temporary, I couldn't think of better one.

-- 
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: Closures and environments

2010-02-04 Thread Sean Devlin
You can take a look at the IFn, AFn & Fn files in the clojure.lang
package to get a better understanding of what is going on.

Sean

On Feb 4, 8:33 am, Ludovic Kuty  wrote:
> Hello,
>
> I was wondering if symbol resolution in local scope (in a let or
> function body) works the same way as it is in Scheme. I would like to
> know some internals of Clojure when it comes to that. I thought about
> explaining how closures work to my students using that analogy (is it
> just an analogy ?), which I find to be an particularly clear way to
> proceed but I want to avoid talking specifically about Scheme when I
> want to talk about Clojure. Unless both are the same with respect to
> this matter.
>
> In Scheme, when a function is defined, a closure is created and is
> composed of code (the body of the function) and an environment which
> captures needed lexical bindings. When the closure is called (applied
> to arguments), a new lexical environment is created to contain the
> bindings of the arguments and that new environment is linked to the
> one used in the definition of the function (points to). So, if we use
> a variable in the body of the function, we look first in the new
> environment and then in the other environment.
>
> There could be a chaining of lexical environments.
>
> There is an elegant notation to describe that process called
> "Weizenbaum notation" but I was not able to find any source on it on
> the Web. I used that when I studied Scheme in school, back in 97. If
> anynone has got information on it, I would be glad. I guess it is
> related to Joseph Weizenbaum.
> We had, a control environment, an access environment, a form to be
> evaluated and bindings in the current environment (terms translated
> from french as the course was given in french). All in a concise
> Weizenbaum frame.
>
> Does it work the same in Clojure ? Or maybe someone could point me to
> the source file ou source files where I can find that information.
>
> TIA,
>
> Ludovic Kuty

-- 
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: Pattern Matching

2010-02-04 Thread Jon Harrop
On Thursday 04 February 2010 14:08:44 Sean Devlin wrote:
> Do we have a concise way of doing this?  Is it actually useful?
>
> http://www.artima.com/weblogs/viewpost.jsp?thread=281160

Are you talking about the pattern matching or the "for" loop?

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e

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


lein - how to add Class-Path entries to uberjar MANIFEST.MF

2010-02-04 Thread Amitava
Much like :main option in defproject,  I would like to add Class-Path
entries to MANIFEST.MF

Here's my unsuccessful attempt


(defproject ashee/lein-test "1.0.0-SNAPSHOT"
:description "FIXME: write"
:dependencies [
[org.clojure/clojure "1.1.0"]
[org.clojure/clojure-contrib "1.1.0-new-SNAPSHOT"]]
:main ashee.lein_test
:class-path [lib/clojure-1.1.0 lib/clojure-
contrib-1.1.0-new-20100114.180211-20.jar])


-- 
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: Coljure-contrib maven build fail

2010-02-04 Thread Stuart Sierra
This has been reported before.  It's a bug that shows up on Windows.
Please make an Assembla ticket.

In the mean time, build with -Dmaven.test.skip=true to ignore the
failure.

-SS



On Feb 3, 5:49 pm, Base  wrote:
> Hi
>
> Pulling off of GIT I got the following 4 errors in the unit tests:
>
> FAIL in (test-relative-path-string) (run-test5258617284758852043.clj:
> 45)
> absolute path strings are forbidden
> expected: (thrown? IllegalArgumentException (relative-path-string "/
> baz"))
>   actual: nil
>
> FAIL in (test-relative-path-string) (run-test5258617284758852043.clj:
> 45)
> absolute File paths are forbidden
> expected: (thrown? IllegalArgumentException (relative-path-string
> (File. "/quux")))
>   actual: nil
>
> FAIL in (test-file) (run-test5258617284758852043.clj:45)
> no sneaking in absolute paths!
> expected: (thrown? IllegalArgumentException (file "foo" "bar" "/boom"
> "baz" "quux"))
>   actual: nil
>
> FAIL in (test-as-url) (run-test5258617284758852043.clj:45)
> expected: (= (URL. "file:/foo") (as-url (File. "/foo")))
>   actual: (not (= # #))
>
> Any thoughts on this?
>
> 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: Pattern Matching

2010-02-04 Thread Sean Devlin
Pattern matching

On Feb 4, 12:12 pm, Jon Harrop  wrote:
> On Thursday 04 February 2010 14:08:44 Sean Devlin wrote:
>
> > Do we have a concise way of doing this?  Is it actually useful?
>
> >http://www.artima.com/weblogs/viewpost.jsp?thread=281160
>
> Are you talking about the pattern matching or the "for" loop?
>
> --
> Dr Jon Harrop, Flying Frog Consultancy Ltd.http://www.ffconsultancy.com/?e

-- 
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 for system administration

2010-02-04 Thread Stuart Sierra
Clojure can certainly do these things; clojure-contrib contains many
file and io-related utilities.  But remember that Clojure, like any
Java program, takes more time to start up than "scripting" languages
like Perl/Bash/Ruby/Python, so it may be less suitable for programs
that you intend to run at the command-line.

-SS

On Feb 3, 4:50 pm, ajay gopalakrishnan  wrote:
> Hi,
>
> I was wondering if the time is right to replace Perl/Bash/Ruby/Python with
> Clojure for system administration / dev productivity scripts. I would not do
> things in Java (for obvious reasons), but clearly Clojure is more concise
> than Java in most cases.
> I would however want to know in detail if it is suitable for Sysadmin tasks
> like the following:
>
>    1. Count # words in a folder , Count # files of particular extension in a
>    folder or search regular expression
>    2. Search for a particular regexp in a search path
>    3. Copy files from one folder to another
>    4. Walk through a directory structure
>    5. Fork another program and read it's results
>
> I've gone through this tutorialhttp://java.ociweb.com/mark/clojure/, but
> please point me to clojure.contribs that will make these kind of tasks
> easier.
>
> Thanks
> Ajay

-- 
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: Pattern Matching

2010-02-04 Thread Tayssir John Gabbour
On Feb 4, 3:28 pm, Tayssir John Gabbour 
wrote:
> I can't say I haven't used pattern matching as much as I probably
> should,

Excuse me, I mean that I haven't used it much though I keep hearing
about it...

-- 
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: Closures and environments

2010-02-04 Thread Stuart Sierra
Hi,

The functionality of closures in Clojure is more or less the same as
Scheme.  But the implementation may be quite different.  I seem to
recall that some Schemes treat lexical environments as first-class
objects.  Clojure does not (at present).

Here's what happens in Clojure:  When you write (fn [] ... x ...), the
compiler generates a sub-class of clojure.lang.Fn with an instance
field x.  When the expression is evaluated, it creates a new instance
of that class, assigning the value 1 to that object's x field.

-SS


On Feb 4, 8:33 am, Ludovic Kuty  wrote:
> Hello,
>
> I was wondering if symbol resolution in local scope (in a let or
> function body) works the same way as it is in Scheme. I would like to
> know some internals of Clojure when it comes to that. I thought about
> explaining how closures work to my students using that analogy (is it
> just an analogy ?), which I find to be an particularly clear way to
> proceed but I want to avoid talking specifically about Scheme when I
> want to talk about Clojure. Unless both are the same with respect to
> this matter.
>
> In Scheme, when a function is defined, a closure is created and is
> composed of code (the body of the function) and an environment which
> captures needed lexical bindings. When the closure is called (applied
> to arguments), a new lexical environment is created to contain the
> bindings of the arguments and that new environment is linked to the
> one used in the definition of the function (points to). So, if we use
> a variable in the body of the function, we look first in the new
> environment and then in the other environment.
>
> There could be a chaining of lexical environments.
>
> There is an elegant notation to describe that process called
> "Weizenbaum notation" but I was not able to find any source on it on
> the Web. I used that when I studied Scheme in school, back in 97. If
> anynone has got information on it, I would be glad. I guess it is
> related to Joseph Weizenbaum.
> We had, a control environment, an access environment, a form to be
> evaluated and bindings in the current environment (terms translated
> from french as the course was given in french). All in a concise
> Weizenbaum frame.
>
> Does it work the same in Clojure ? Or maybe someone could point me to
> the source file ou source files where I can find that information.
>
> TIA,
>
> Ludovic Kuty

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


Run expression, with particular functions replaced

2010-02-04 Thread Bryce
I want to create a macro that takes an expression, and runs it against
a collection after replacing a bunch of function calls via the
"replace" function.  Something like this:

(def a {'+ '*})
(def b '(+ a b))

(defmacro substituteFuncs [replacelist expresn target]
(#((replace replacelist expresn) %) `target)
)

I've tweaked it a bunch of ways, and can't seem to get it to resolve
properly, so

(substituteFuncs a b '(3 4))
results in 12.

I'm sure I'm messing up something fairly basic; any idea what I'm
doing wrong?

-- 
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: Seattle Clojure meeting

2010-02-04 Thread Stan Dyck

I can do the 11th as well.

StanD.

Kevin Downey wrote:

the 11th at Zokas is good for me

On Wed, Feb 3, 2010 at 10:07 PM, ajay gopalakrishnan  wrote:

I'm in!
But on 11th. I cannot make it on 15th


On Wed, Feb 3, 2010 at 7:01 PM, Phil Hagelberg  wrote:

Hello, clojurists of Seattle.

Let's meet! I'm thinking of getting folks together from 7pm to 9pm at Zoka
in the University District: http://bit.ly/c9jinW Topics may include
Leiningen, deftype/protocols, getting set up with Emacs, or even getting
another pair of eyes on that pet project that you've been playing around
with recently. I suspect it'll be mostly talking and getting to know people,
but bring laptops.

I'm thinking of either the 11th or the 15th, depending on what works best
for the most people. Let me know if you think you can make it to one or both
of these times.

-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

--
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: Pattern Matching

2010-02-04 Thread Jon Harrop
On Thursday 04 February 2010 16:32:36 Sean Devlin wrote:
> Pattern matching

Ok. Pattern matching is a core construct from the ML family of languages and, 
consequently, is now ubiquitous in F#, OCaml, Standard ML and Haskell as well 
as Scala. In the MLs, pattern matching is the only way to destructure data.

For example, you can extract the two elements of a pair and bind their values 
to the variable names "a" and "b" as follows (OCaml/F# code):

  let a, b = a_pair

Pattern matching is a powerful technique that has been generalized in many 
ways, so you can also destructure a pair of pairs by nesting patterns:

  let (x0, y0), (x1, y1) = two_vectors

Pattern matching is also used for dispatch in those languages (although the 
object oriented ones including OCaml and F# also provide method dispatch). 
Moreover, patterns can match on more than just objects, e.g. numbers:

  let rec factorial = function
| 0 | 1 -> 1
| n -> n * factorial(n-1)

Note the "or-pattern" 0|1 to match either 0 or 1.

A more advanced example including nesting, or-patterns, guarded patterns 
(with "when") and named subpatterns is to merge two sorted lists (OCaml/F# 
code):

  let rec merge = function
| [], xs | xs, [] -> xs
| x::xs', (y::_ as ys) when x <= y -> x::merge(xs', ys)
| xs, y::ys' -> y::merge(xs, ys')

I've written about it here:

  http://www.ffconsultancy.com/ocaml/benefits/pattern_matching.html

You may also be interested in this symbolic simplifier challenge:

  http://www.lambdassociates.org/studies/study10.htm

Note that the Common Lisp solutions are 50-160% longer and 1.7-7.5x slower 
than the OCaml.

Pattern matching is uncommon is Lisps because its core benefits (static 
checking and performance) rely upon static type information. However, some 
dynamic languages (e.g. Mathematica) do provide and make heavy use of pattern 
matching. On the other hand, dynamic languages can do lots of funky things 
with pattern matching that static languages do not, most notably allowing 
patterns to be generated at run-time (even MetaOCaml does not allow this).

A major disadvantage of pattern matching can be that it requires libraries to 
expose their internals in order for a user to be able to pattern match over 
them. This problem was solved using view patterns which are bundled with F# 
(as "active patterns") and Scala (as "extractors").

I have found pattern matching to be extremely valuable not only because it 
permits very clear and concise solutions to many problems but also because 
the static checking it provides allows me to leverage a static type system to 
prove aspects of correctness that remove major classes of bugs from real 
applications.

HTH.

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e

-- 
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 for system administration

2010-02-04 Thread Phil Hagelberg
On Thu, Feb 4, 2010 at 8:33 AM, Stuart Sierra
 wrote:
> Clojure can certainly do these things; clojure-contrib contains many
> file and io-related utilities.  But remember that Clojure, like any
> Java program, takes more time to start up than "scripting" languages
> like Perl/Bash/Ruby/Python, so it may be less suitable for programs
> that you intend to run at the command-line.

Also relevant is the fact that launching Clojure from the command-line
is very inconvenient compared to scripting languages. If you want
something simple you can just put on your path, you'll need to wrap it
in a bash (or other language) script anyway to handle the classpath,
etc. The combination of startup time and the need to roll your own
bash script even for simple things has kept me from wanting to use
Clojure as a perlish-replacement.

-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 for system administration

2010-02-04 Thread Richard Newman

in a bash (or other language) script anyway to handle the classpath,


The classpath is a perpetual source of frustration. It drives me nuts  
every time I have to restart swank to work on a different project with  
a different classpath. It certainly means that something like a  
Clojure shell would be unnaturally limited.


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


Re: Is this possible in Clojure?

2010-02-04 Thread Greg
Thanks Meikel, if I may reply to your points and your function as it's slightly 
different from what I wanted:

> * It's a function, not macro.

I need it to be a macro because it's more usable for my purposes that way. The 
newLISP function is being used to generate templates php-style:


NameEmail
<% (for-query-with-db db "SELECT * FROM people" %>
<%=NAME%><%=EMAIL%>
<% ) %>


As you can see it's much more convenient as a macro.

> * You don't have to fiddle with magic names. The user can choose himself.

These aren't magic names, they're just like you keywords, except they're 
symbols, and they're not magic because they're defined by the columns of the 
table. Or, I may be misunderstanding your use of the term 'magic'.

> * The query can be also stored in some local and doesn't have to be a literal 
> string.


There's nothing forcing you to use it as a literal, the newLISP version can be 
used with a let statement just as your example did.

After discussing this problem with the folks on #clojure they helped me refine 
my attempt at writing a clojure version of it:

(def col-names ["name" "age"])
(def col-vals [["Sally" 5] ["Sue" 6]])
(defmacro foo [& body]
(let [col-syms (for [n col-names] (-> n .toUpperCase symbol))
  exprs(for [v col-vals] `(let [~@(interleave col-syms 
v)] ~...@body))]
`(do ~...@exprs)
)
)
(foo (prn NAME))

As I'm not yet experienced in Clojure enough to use an actual db, I used the 
vars 'col-names' and 'col-vals' as placeholders.

That seems to work great, what I'm fuzzy on is the whole macroexpansion thing 
and when it occurs. As in this example everything is known at compile-time, is 
this "macro-expanded" at compile time? Can this sort of macro work just fine 
when the column information is only known at runtime? Are there any performance 
considerations?

Thanks!

- Greg

On Feb 4, 2010, at 1:42 AM, Meikel Brandmeyer wrote:

> Hi,
> 
> On Feb 4, 4:42 am, Greg  wrote:
> 
>> The magic happens here:
>> 
>> (while (list? (setf values (sql:next-row)))
>> (eval (expand (cons 'begin $args) (unify keys 
>> values)))
>> )
>> 
>> $args is equivalent to the 'body' in [& body] in clojure, and the expand 
>> function will replace all of the symbols in 'keys' (in $args) with the 
>> 'values'.
>> 
>> So (println NAME) becomes (println "José Lopez"), and it gets eval'd each 
>> time in the loop to the different values in the table.
>> 
>> How would you implement this behavior in Clojure?
> 
> (defn do-query
>  [db query thunk]
>  (doseq [entry (-> db (.prepareStatement query) .executeQuery
> resultset-seq)]
>(thunk entry)))
> 
> (let [q "SELECT name FROM people"]
>  (do-query db q #(println (:name %
> 
> Several differences to the newLisp code:
> 
> * It's a function, not macro.
> * You don't have to fiddle with magic names. The user can choose
> himself.
> * The query can be also stored in some local and doesn't have to be a
> literal
>  string.
> 
> I am really happy that I'm a smug Clojure weenie, who doesn't have to
> write
> code which walks other code to replace things in place and to eval
> it...
> 
> 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

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


Re: Is this possible in Clojure?

2010-02-04 Thread Greg
Whoops, I need to correct this statement:

> There's nothing forcing you to use it as a literal, the newLISP version can 
> be used with a let statement just as your example did.

Indeed in the original newlisp version I gave you wouldn't be able to use it 
with the let form, but that's because I wrote it incorrectly, I left out the 
eval on the 'query', it should be this:

(letn (db (eval db) sql (db:prepare-sql (eval query)) keys '())

One other note I should make so as to avoid confusion: using 'eval' is frowned 
upon in clojure because it's ridiculously slow, however it's OK to use it in 
newLISP because newlisp's eval is very fast, there's little to no penalty for 
using it, which is why you'll find it frequently used in newlisp code.

Please don't take that to mean that I think one language is better than the 
other, I think both are great and it's why I'm asking these questions. :-)

- Greg

On Feb 4, 2010, at 12:55 PM, Greg wrote:

> Thanks Meikel, if I may reply to your points and your function as it's 
> slightly different from what I wanted:
> 
>> * It's a function, not macro.
> 
> I need it to be a macro because it's more usable for my purposes that way. 
> The newLISP function is being used to generate templates php-style:
> 
>   
>   NameEmail
>   <% (for-query-with-db db "SELECT * FROM people" %>
>   <%=NAME%><%=EMAIL%>
>   <% ) %>
>   
> 
> As you can see it's much more convenient as a macro.
> 
>> * You don't have to fiddle with magic names. The user can choose himself.
> 
> These aren't magic names, they're just like you keywords, except they're 
> symbols, and they're not magic because they're defined by the columns of the 
> table. Or, I may be misunderstanding your use of the term 'magic'.
> 
>> * The query can be also stored in some local and doesn't have to be a 
>> literal string.
> 
> 
> There's nothing forcing you to use it as a literal, the newLISP version can 
> be used with a let statement just as your example did.
> 
> After discussing this problem with the folks on #clojure they helped me 
> refine my attempt at writing a clojure version of it:
> 
>   (def col-names ["name" "age"])
>   (def col-vals [["Sally" 5] ["Sue" 6]])
>   (defmacro foo [& body]
>   (let [col-syms (for [n col-names] (-> n .toUpperCase symbol))
> exprs(for [v col-vals] `(let [~@(interleave col-syms 
> v)] ~...@body))]
>   `(do ~...@exprs)
>   )
>   )
>   (foo (prn NAME))
> 
> As I'm not yet experienced in Clojure enough to use an actual db, I used the 
> vars 'col-names' and 'col-vals' as placeholders.
> 
> That seems to work great, what I'm fuzzy on is the whole macroexpansion thing 
> and when it occurs. As in this example everything is known at compile-time, 
> is this "macro-expanded" at compile time? Can this sort of macro work just 
> fine when the column information is only known at runtime? Are there any 
> performance considerations?
> 
> Thanks!
> 
> - Greg
> 
> On Feb 4, 2010, at 1:42 AM, Meikel Brandmeyer wrote:
> 
>> Hi,
>> 
>> On Feb 4, 4:42 am, Greg  wrote:
>> 
>>> The magic happens here:
>>> 
>>>(while (list? (setf values (sql:next-row)))
>>>(eval (expand (cons 'begin $args) (unify keys 
>>> values)))
>>>)
>>> 
>>> $args is equivalent to the 'body' in [& body] in clojure, and the expand 
>>> function will replace all of the symbols in 'keys' (in $args) with the 
>>> 'values'.
>>> 
>>> So (println NAME) becomes (println "José Lopez"), and it gets eval'd each 
>>> time in the loop to the different values in the table.
>>> 
>>> How would you implement this behavior in Clojure?
>> 
>> (defn do-query
>> [db query thunk]
>> (doseq [entry (-> db (.prepareStatement query) .executeQuery
>> resultset-seq)]
>>   (thunk entry)))
>> 
>> (let [q "SELECT name FROM people"]
>> (do-query db q #(println (:name %
>> 
>> Several differences to the newLisp code:
>> 
>> * It's a function, not macro.
>> * You don't have to fiddle with magic names. The user can choose
>> himself.
>> * The query can be also stored in some local and doesn't have to be a
>> literal
>> string.
>> 
>> I am really happy that I'm a smug Clojure weenie, who doesn't have to
>> write
>> code which walks other code to replace things in place and to eval
>> it...
>> 
>> 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
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> T

Re: Run expression, with particular functions replaced

2010-02-04 Thread Michał Marczyk
On 4 February 2010 17:24, Bryce  wrote:
> I'm sure I'm messing up something fairly basic; any idea what I'm
> doing wrong?

1. At the time the code inside your macro definition executes, the "a"
you pass in as the first argument in your example is just a symbol.
Ditto for "b". It makes no sense to use replace on that.

2. Even if the replace bit worked, you'd get something like (* a b)
from it -- that's a list containing three symbols, not a function, so
you can't use it as a function.

It seems that what you're trying to do is to use the expression, plus
the replacements, as the *body* of a function to be applied to the
arguments specified as the third argument to the macro, which brings
me to my third point:

3. Making your example work would necessitate discovering which of the
symbols in the (+ a b) form are to be treated as formal arguments. In
this case, the answer would be a (to be bound to 3) and b (to be bound
to 4). In general, that's very nearly impossible, as any symbol not in
your replacements map may equally well be a function which you don't
want to replace.

Example: Say your expression changes to (+ a (inc b)) -- you might
expect this to evaluate to (* 3 (inc 4)) => 15, but how's your code to
tell that it's meant to substitute stuff from target into the
expression while leaving the symbol inc alone? You could come up with
some heuristic, but that doesn't seem worthwhile.

I thought I'd come up with some alternate design to get you started on
reimagining this, but I'm finding it problematic without knowing your
purpose in wanting this kind of thing... I hope the above helps
somewhat.

Sincerely,
Michał

-- 
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 for system administration

2010-02-04 Thread Brenton
I have created a clj command on my system (using Ruby, 
http://gist.github.com/247899)
that will run a Clojure script or launch the REPL.

For example: "clj script.clj" or just "clj script" will run as script.
You may also pass args to the Clojure script like this "clj script
arg1 arg2". You may also pass arguments starting with "-X" through to
Java. I also have shorthands for other things like the arg -Xjmx is
converted to -Dcom.sun.management.jmxremote. Just typing clj at the
command line anywhere will start a REPL. I created this when I started
using Clojure to make it easier to work with and have been hacking on
it for a while. I add stuff all the time for my own convenience.

The basic idea is that you have a default classpath which is used when
you are not working within a project. If I execute clj within a
directory that contains a lib directory then it will put the jars in
lib on the classpath. If there is no lib directory then it will use
the default classpath. I explicitly set which jars are on the default
classpath but I think a better general purpose approach would be to
have a directory somewhere on your system that contains the default
jars. For example groovy has the .groovy/lib dir under ~ for this
purpose. This would allow you to easily add default jars without
modifying the clj script.

I also use a file named .cljrc.clj to configure the REPL. When the
script starts it will find the nearest parent dir that contains a file
named .cljrc.clj. When it finds this file it will run it and then
start the java process in that directory. I usually create a default
file in my root directory or ~ and one in each project. This file
usually contains an exit function to shutdown the REPL but you can
also configure the REPL here so that you don't have to do it each
time.

I created this before leiningen was available but I still use it and
the two work together very well. I also configure Emacs to use this as
my Clojure binary.

(setq swank-clojure-binary "clj")

What the others have said is still true. I only use Clojure for admin
stuff when the startup time is not a factor. But this clj script takes
away a lot of the pain of launching Clojure from the command line.

I hope this has more signal than noise.
Brenton

On Feb 4, 9:35 am, Phil Hagelberg  wrote:
> On Thu, Feb 4, 2010 at 8:33 AM, Stuart Sierra
>
>  wrote:
> > Clojure can certainly do these things; clojure-contrib contains many
> > file and io-related utilities.  But remember that Clojure, like any
> > Java program, takes more time to start up than "scripting" languages
> > like Perl/Bash/Ruby/Python, so it may be less suitable for programs
> > that you intend to run at the command-line.
>
> Also relevant is the fact that launching Clojure from the command-line
> is very inconvenient compared to scripting languages. If you want
> something simple you can just put on your path, you'll need to wrap it
> in a bash (or other language) script anyway to handle the classpath,
> etc. The combination of startup time and the need to roll your own
> bash script even for simple things has kept me from wanting to use
> Clojure as a perlish-replacement.
>
> -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: Is this possible in Clojure?

2010-02-04 Thread Richard Newman
* You don't have to fiddle with magic names. The user can choose  
himself.


These aren't magic names, they're just like you keywords, except  
they're symbols, and they're not magic because they're defined by  
the columns of the table. Or, I may be misunderstanding your use of  
the term 'magic'.


They're magic because they're not introduced via normal lexical  
scoping. Not magic:


(let [x 5]
  (do-something (foo x)))

Magic:

(with-implicit-wizard
  (do-something (foo gandalf)))


That seems to work great, what I'm fuzzy on is the whole  
macroexpansion thing and when it occurs. As in this example  
everything is known at compile-time, is this "macro-expanded" at  
compile time? Can this sort of macro work just fine when the column  
information is only known at runtime? Are there any performance  
considerations?


The macroexpansion occurs at compile time. If you have all the  
knowledge at compile time, you can do the work then. If you don't, the  
macro has to expand into code that does the work at runtime.


For example, to write a macro that prints upper-cased strings, you  
might do this:


  (defmacro all-upcase [& args]
`(println ~@(map (fn [x] (if (string? x) (.toUpperCase x)  
`(.toUpperCase ~x))) args)))


... it does the upcasing at compile-time for static strings, and at  
runtime for everything else. You can see what happens by using  
macroexpand:


user=> (macroexpand '(all-upcase "foo" "bar" x y))
(clojure.core/println "FOO" "BAR" (.toUpperCase x) (.toUpperCase y))

user=> (let [x "hi" y "there"] (all-upcase "foo" "bar" x y))
FOO BAR HI THERE

--
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: Naming Functions...

2010-02-04 Thread Erik Price
What kind of naming convention is appropriate for a function that
operates on a sequence, and, as one of its return values, returns a
new head for (or in other words a subsequence within) that sequence?
For example, a function that consumes some portion of a stream. Or is
it not conventional for a stream-consuming function to work that way?

e

-- 
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: Run expression, with particular functions replaced

2010-02-04 Thread Bryce

> 3. Making your example work would necessitate discovering which of the
> symbols in the (+ a b) form are to be treated as formal arguments. In
> this case, the answer would be a (to be bound to 3) and b (to be bound
> to 4). In general, that's very nearly impossible, as any symbol not in
> your replacements map may equally well be a function which you don't
> want to replace.

I take your point; I've given up trying to actually define a function
with the expression for the moment (I'd imagine it's still possible,
just much trickier than I thought).  My intention was to fake operator
overloading.  For my purposes it should be enough to evaluate the
expression with substituted functions, which is very easy:

(defmacro subFuncs [arg1 arg2]
  (eval `(replace ~arg1 ~arg2))
  )

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


Re: Is this possible in Clojure?

2010-02-04 Thread Meikel Brandmeyer
Hi,

Am 04.02.2010 um 18:55 schrieb Greg:

> I need it to be a macro because it's more usable for my purposes that way. 
> The newLISP function is being used to generate templates php-style:
> 
>   
>   NameEmail
>   <% (for-query-with-db db "SELECT * FROM people" %>
>   <%=NAME%><%=EMAIL%>
>   <% ) %>
>   
> 
> As you can see it's much more convenient as a macro.

I don't see why a macro should be of more use here. With a macro the db query 
is always done, when the page is compiled. I don't see how this would an 
advantage. With a function it could be compiled once at startup and when the 
page is accessed you just fire off a clojure function which does the work. 
enlive works like that, AFAIK. You would have to "recompile" the page only when 
its source is changed.

>> * You don't have to fiddle with magic names. The user can choose himself.
> 
> These aren't magic names, they're just like you keywords, except they're 
> symbols, and they're not magic because they're defined by the columns of the 
> table. Or, I may be misunderstanding your use of the term 'magic'.

Richard explained what I meant.

>> * The query can be also stored in some local and doesn't have to be a 
>> literal string.
> 
> 
> There's nothing forcing you to use it as a literal, the newLISP version can 
> be used with a let statement just as your example did.

eval is in general discouraged, not because it's slow, but because its bad 
style. For example clojure's eval wouldn't help you with let.

user=> (let [x 5] (eval 'x))
java.lang.Exception: Unable to resolve symbol: x in this context 
(NO_SOURCE_FILE:1)
user=> (let [x 5] (eval `x))
java.lang.Exception: No such var: user/x (NO_SOURCE_FILE:2)

What happens in newLisp if you have a macro which does some eval on an argument 
and the user passes it a function call which asks the user for input from a 
console?

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: Naming Functions...

2010-02-04 Thread Meikel Brandmeyer
Hi,

Am 04.02.2010 um 20:00 schrieb Erik Price:

> What kind of naming convention is appropriate for a function that
> operates on a sequence, and, as one of its return values, returns a
> new head for (or in other words a subsequence within) that sequence?
> For example, a function that consumes some portion of a stream. Or is
> it not conventional for a stream-consuming function to work that way?

There is no naming convention: filter, remove, take, take-nth, drop-while, ... 
are all examples of that.

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: Full Disclojure - I Need Topics!

2010-02-04 Thread Alex Stoddard

Suggestion:
"meta-data in clojure", what it is, how to work with it, idiomatic
uses.

Thanks for the great series,
Alex

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


Re: Clojure for system administration

2010-02-04 Thread Michael Wood
On 4 February 2010 20:47, Brenton  wrote:
> I have created a clj command on my system (using Ruby, 
> http://gist.github.com/247899)
> that will run a Clojure script or launch the REPL.
>
> For example: "clj script.clj" or just "clj script" will run as script.
[...]

Clojure also ignores lines starting with #!, so you can have a file
with the first line being:

#!/usr/bin/env clj

and with the rest being just normal Clojure s-expressions, and then
you can even run it directly instead of "clj script.clj". :)

-- 
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: clojure box 1.0 failed to connect to emacs server

2010-02-04 Thread Rollo
Hello,

Sorry for the late reply on this. Haven't got that much time lately to
experiment.

So actually I got it working in any of the versions (1.0, 1.1RC1,
1.1.0-1). The trick is simply to right-click and 'Run as admin'.
Somehow, on Windows 7, emacs won't start when using a non-privileged
account. Dunno why though - maybe someone can answer that?
In the meantime, as long as it works I'm a happy camper.

Thanks for your time Shawn

Rollo

On Jan 31, 11:49 pm, Shawn Hoover  wrote:
> On Sat, Jan 30, 2010 at 10:11 PM, Shawn Hoover wrote:
>
>
>
>
>
>
>
> > On Sat, Jan 30, 2010 at 5:48 PM, Rollo  wrote:
>
> >> Hi Shawn,
>
> >> Just tried with 1.1.RC1 - no luck. Emacs server won't start and system
> >> will start spawning thousands of cmdproxy processes again.
> >> Where does that bad condition comes from?
> >> Let me know if I can help diagnose or test further.
>
> >> Thanks,
> >> Rollo
>
> > Ok, I suggested RC1 because I thought the original poster said it worked. I
> > may have misread. Anyway, I develop and test Clojure Box on XP, where I
> > haven't had the problem, so I have no idea where it's coming from. I'll try
> > to test on 7 soon and see what's up.
>
> Sorry, folks, but I can't recreate this issue.
>
> What happens if you run c:\program files\clojure
> box\emacs\emacs\bin\emacs.exe, avoiding the client process run by the
> installed Clojure Box shortcut?

-- 
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 Jobs in White Plains, NY

2010-02-04 Thread Eric Thorsen
ThorTech Solutions is seeking exceptional developers to join our
team.  The work will be primarily on a new product, predominantly
written in Clojure.  If you are a passionate individual who is self
directed but thrives in a team environment and team results, has
experience with several of the following and would like to help move
us forward with the rest, we want to hear from you:
Web application development experience
SQL
Statistics background
Clojure, Java, Lisp, JavaScript, Python
Functional programming
XP, Scrum, Pair Programming
Mac OS X, Windows, Linux
Distributed application development on the Java or .Net platforms
Continuous Integration, Git
Amazon EC2, EBS
Hadoop, RDF, Sesame
We are a profitable company that is in its 9th year in business.
All developers work on Macbook Pro or Mac Pro machines
No crazy hours; good quality of life means a clearer thinking, happier
more productive team.
Great benefits package including medical
We are conveniently located in the central business district of White
Plains NY, walking distance from the train station, 35 minutes from
Grand Central Station.
Please send a resume with a one-page "why you think we're good fit for
you" to:
care...@thotech-solutions.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: Is this possible in Clojure?

2010-02-04 Thread Greg
On Feb 4, 2010, at 1:51 PM, Richard Newman wrote:

>>> * You don't have to fiddle with magic names. The user can choose himself.
>> 
>> These aren't magic names, they're just like you keywords, except they're 
>> symbols, and they're not magic because they're defined by the columns of the 
>> table. Or, I may be misunderstanding your use of the term 'magic'.
> 
> They're magic because they're not introduced via normal lexical scoping. Not 
> magic:
> 
> (let [x 5]
>  (do-something (foo x)))
> 
> Magic:
> 
> (with-implicit-wizard
>  (do-something (foo gandalf)))

OK, I hope you can see the difference though between that and what I showed. 
They are not the same; in your example:

- It's not clear what the magic symbols are
- The user does not specify the magic symbols (as they did in mine)

This sort of programming style is easy to abuse and can sometimes lead to 
confusion if handled incorrectly, but when applied in the appropriate manner it 
can be extremely useful.

The 'for-query-with-db' function is a good example of doing this correctly 
because it:

- Documents its behavior
- Creates symbols based on user input, not of its own accord as in your example
- Clearly distinguishes them through a special naming convention
- Has advantages over other forms of solving the same problem

>> That seems to work great, what I'm fuzzy on is the whole macroexpansion 
>> thing and when it occurs. As in this example everything is known at 
>> compile-time, is this "macro-expanded" at compile time? Can this sort of 
>> macro work just fine when the column information is only known at runtime? 
>> Are there any performance considerations?
> 
> The macroexpansion occurs at compile time. If you have all the knowledge at 
> compile time, you can do the work then. If you don't, the macro has to expand 
> into code that does the work at runtime.

Thanks for the example and explanation!

- Greg


> For example, to write a macro that prints upper-cased strings, you might do 
> this:
> 
>  (defmacro all-upcase [& args]
>`(println ~@(map (fn [x] (if (string? x) (.toUpperCase x) `(.toUpperCase 
> ~x))) args)))
> 
> ... it does the upcasing at compile-time for static strings, and at runtime 
> for everything else. You can see what happens by using macroexpand:
> 
> user=> (macroexpand '(all-upcase "foo" "bar" x y))
> (clojure.core/println "FOO" "BAR" (.toUpperCase x) (.toUpperCase y))
> 
> user=> (let [x "hi" y "there"] (all-upcase "foo" "bar" x y))
> FOO BAR HI THERE
> 
> -- 
> 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: Is this possible in Clojure?

2010-02-04 Thread Richard Newman
OK, I hope you can see the difference though between that and what I  
showed.


Of course I can; I'm just illustrating a point by exaggeration.


They are not the same; in your example:

- It's not clear what the magic symbols are
- The user does not specify the magic symbols (as they did in mine)


It's not clear in the case of multiple packages or namespaces. (In  
which package does "name" get interned? It depends on *when* the  
string is interned, because that decides the enclosing scope. Or does  
newLISP not have packages?)


Neither are the names specified in a query such as "SELECT * FROM  
people". Who knows what'll happen when you do "SELECT p1.name ...".


You're about half-way to complete anaphora when you're starting to  
pull symbol names out of syntax-laden strings (or databases). That's  
magic, at least when compared to ordinary lexical symbol reference.


Given that there's little to no advantage to doing this, I don't see  
the point.


This sort of programming style is easy to abuse and can sometimes  
lead to confusion if handled incorrectly, but when applied in the  
appropriate manner it can be extremely useful.


The 'for-query-with-db' function is a good example of doing this  
correctly because it:


- Documents its behavior
- Creates symbols based on user input, not of its own accord as in  
your example

- Clearly distinguishes them through a special naming convention
- Has advantages over other forms of solving the same problem


... and it's a bad example, because it:

- Quietly and maybe accidentally shadows variables from enclosing scopes
- Fails to nest queries which share names
- Silently interns new variable names in your packages
- Uses eval (which apparently is fine in newLISP, but as a Common  
Lisper and Clojurite strikes me as pointless)

- etc.

I see no point in doing this rather than going the conventional macro  
route. c.c.sql, for example, would do this:


(with-query-results res
  ["SELECT name FROM people"]
  (println (:name res)))

-- res is a map. You can pass it around, access its values, and your  
own function `name` doesn't get shadowed by your query.


c.c.sql also allows you to synthesize queries from Lisp forms, which I  
think is more useful than trying to extract symbol names from a SQL  
string.


The macroexpansion occurs at compile time. If you have all the  
knowledge at compile time, you can do the work then. If you don't,  
the macro has to expand into code that does the work at runtime.


Thanks for the example and explanation!


Sure thing!

--
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: Full Disclojure - I Need Topics!

2010-02-04 Thread Glen Stampoultzis
On 25 January 2010 16:34, Sean Devlin  wrote:

> Hello everyone,
> I'm having a blast making the Full Disclojure series.  It's one the
> best projects I've had a chance to work on.
>
> However, there's going to be a problem soon.  I only have a few more
> topics left before I run out.  No more topics, no more videos.
>
> This is where you come in.  I'm interested in what the community (i.e.
> you) would like to see talked about.  It could be the core language,
> contrib, a popular library, your-really-awesome-library-that-you-would-
> like-to-get-exposure, or some development tool.  Bring up anything and
> everything.  If it's interesting enough, I'll try to do an episode on
> it.  There are no bad suggestions.
>
>
Here's a challenge for you - Monads.  If you can clearly explain monads
you'll be my hero. :-)

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

Re: Is this possible in Clojure?

2010-02-04 Thread Greg
> It's not clear in the case of multiple packages or namespaces. (In which 
> package does "name" get interned? It depends on *when* the string is 
> interned, because that decides the enclosing scope. Or does newLISP not have 
> packages?)


NAME (not name) may be "interned" in the sense that it will exist somewhere in 
the symbol tree, but that doesn't matter—at all. At least in newLISP. In 
Clojure it may have some consequences and if so, that would be a valid argument 
to make, I'd be interested to know what they are if that is the case.

> Neither are the names specified in a query such as "SELECT * FROM people". 
> Who knows what'll happen when you do "SELECT p1.name ...".


This is incorrect. A query like "SELECT *" will not have any issues getting the 
correct, expected names from the table definition. You can check the code 
again, there's no string parsing going on with the query.

> - Quietly and maybe accidentally shadows variables from enclosing scopes


If any shadowing happens, it's OK because you know it's going to happen. It's 
also exceedingly unlikely it will happen due to naming convention and even if 
it happens, it's *still OK* because nothing breaks because things are only 
shadowed within the scope of the macro call and you're explicitly expecting to 
use the NAME symbol, etc. There's zero confusion and zero ambiguity.

> - Uses eval (which apparently is fine in newLISP, but as a Common Lisper and 
> Clojurite strikes me as pointless)

So, as I showed, the Clojure version seems to not require the use of eval.

> c.c.sql also allows you to synthesize queries from Lisp forms

This is a good point, and if I were to use Clojure I would use your version 
instead.

- Greg

On Feb 4, 2010, at 5:53 PM, Richard Newman wrote:

>> OK, I hope you can see the difference though between that and what I showed.
> 
> Of course I can; I'm just illustrating a point by exaggeration.
> 
>> They are not the same; in your example:
>> 
>> - It's not clear what the magic symbols are
>> - The user does not specify the magic symbols (as they did in mine)
> 
> It's not clear in the case of multiple packages or namespaces. (In which 
> package does "name" get interned? It depends on *when* the string is 
> interned, because that decides the enclosing scope. Or does newLISP not have 
> packages?)
> 
> Neither are the names specified in a query such as "SELECT * FROM people". 
> Who knows what'll happen when you do "SELECT p1.name ...".
> 
> You're about half-way to complete anaphora when you're starting to pull 
> symbol names out of syntax-laden strings (or databases). That's magic, at 
> least when compared to ordinary lexical symbol reference.
> 
> Given that there's little to no advantage to doing this, I don't see the 
> point.
> 
>> This sort of programming style is easy to abuse and can sometimes lead to 
>> confusion if handled incorrectly, but when applied in the appropriate manner 
>> it can be extremely useful.
>> 
>> The 'for-query-with-db' function is a good example of doing this correctly 
>> because it:
>> 
>> - Documents its behavior
>> - Creates symbols based on user input, not of its own accord as in your 
>> example
>> - Clearly distinguishes them through a special naming convention
>> - Has advantages over other forms of solving the same problem
> 
> ... and it's a bad example, because it:
> 
> - Quietly and maybe accidentally shadows variables from enclosing scopes
> - Fails to nest queries which share names
> - Silently interns new variable names in your packages
> - Uses eval (which apparently is fine in newLISP, but as a Common Lisper and 
> Clojurite strikes me as pointless)
> - etc.
> 
> I see no point in doing this rather than going the conventional macro route. 
> c.c.sql, for example, would do this:
> 
> (with-query-results res
>  ["SELECT name FROM people"]
>  (println (:name res)))
> 
> -- res is a map. You can pass it around, access its values, and your own 
> function `name` doesn't get shadowed by your query.
> 
> c.c.sql also allows you to synthesize queries from Lisp forms, which I think 
> is more useful than trying to extract symbol names from a SQL string.
> 
>>> The macroexpansion occurs at compile time. If you have all the knowledge at 
>>> compile time, you can do the work then. If you don't, the macro has to 
>>> expand into code that does the work at runtime.
>> 
>> Thanks for the example and explanation!
> 
> Sure thing!
> 
> -- 
> 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, se

Re: Is this possible in Clojure?

2010-02-04 Thread Greg
> I don't see why a macro should be of more use here. With a macro the db query 
> is always done, when the page is compiled. I don't see how this would an 
> advantage. With a function it could be compiled once at startup and when the 
> page is accessed you just fire off a clojure function which does the work. 
> enlive works like that, AFAIK. You would have to "recompile" the page only 
> when its source is changed.


Perhaps this isn't the right approach to take in Clojure because of the slow 
eval. I'm not sure exactly if this can be done without it. If it can though it 
should be as fast as Enlive or faster. You "compile" the template once to 
Clojure source, and then re-run that source each time the page is called.

Enlive has to reconstruct HTML from its data structures. This, on the other 
hand, mostly just prints already "rendered" strings, and calls any clojure 
functions/macros along the way. Again, though, if that's not possible to do in 
Clojure without using eval (as I do in newLISP), then I would see why Enlive's 
approach is preferred.

> eval is in general discouraged, not because it's slow, but because its bad 
> style. For example clojure's eval wouldn't help you with let.
> 
> user=> (let [x 5] (eval 'x))
> java.lang.Exception: Unable to resolve symbol: x in this context 
> (NO_SOURCE_FILE:1)
> user=> (let [x 5] (eval `x))
> java.lang.Exception: No such var: user/x (NO_SOURCE_FILE:2)

In newLISP it's not discouraged because it's not bad style. This works no 
problem:

> (let (x 5) (eval 'x))
5

Even if Clojure could do this, I would still agree with you that eval's use 
should be discouraged, but only because of how slow it is:

user=> (dotimes [_ 4] (time (dotimes [_ 1000] (eval '(+ 1 1))
"Elapsed time: 1797.558 msecs"
"Elapsed time: 1590.405 msecs"
"Elapsed time: 1274.187 msecs"
"Elapsed time: 1808.667 msecs"

vs.

> (time (dotimes (_ 1000) (eval '(+ 1 1
0.3

Yes, that's in milliseconds.

> What happens in newLisp if you have a macro which does some eval on an 
> argument and the user passes it a function call which asks the user for input 
> from a console?

That's silly, what happens when you pass in a string to a function that's 
expecting a double? That's what documentation is for. And if you want the 
macro/fexpr to accept function as well as symbols, you can always rewrite it to 
check for both and act appropriately.

- Greg

On Feb 4, 2010, at 2:16 PM, Meikel Brandmeyer wrote:

> Hi,
> 
> Am 04.02.2010 um 18:55 schrieb Greg:
> 
>> I need it to be a macro because it's more usable for my purposes that way. 
>> The newLISP function is being used to generate templates php-style:
>> 
>>  
>>  NameEmail
>>  <% (for-query-with-db db "SELECT * FROM people" %>
>>  <%=NAME%><%=EMAIL%>
>>  <% ) %>
>>  
>> 
>> As you can see it's much more convenient as a macro.
> 
> I don't see why a macro should be of more use here. With a macro the db query 
> is always done, when the page is compiled. I don't see how this would an 
> advantage. With a function it could be compiled once at startup and when the 
> page is accessed you just fire off a clojure function which does the work. 
> enlive works like that, AFAIK. You would have to "recompile" the page only 
> when its source is changed.
> 
>>> * You don't have to fiddle with magic names. The user can choose himself.
>> 
>> These aren't magic names, they're just like you keywords, except they're 
>> symbols, and they're not magic because they're defined by the columns of the 
>> table. Or, I may be misunderstanding your use of the term 'magic'.
> 
> Richard explained what I meant.
> 
>>> * The query can be also stored in some local and doesn't have to be a 
>>> literal string.
>> 
>> 
>> There's nothing forcing you to use it as a literal, the newLISP version can 
>> be used with a let statement just as your example did.
> 
> eval is in general discouraged, not because it's slow, but because its bad 
> style. For example clojure's eval wouldn't help you with let.
> 
> user=> (let [x 5] (eval 'x))
> java.lang.Exception: Unable to resolve symbol: x in this context 
> (NO_SOURCE_FILE:1)
> user=> (let [x 5] (eval `x))
> java.lang.Exception: No such var: user/x (NO_SOURCE_FILE:2)
> 
> What happens in newLisp if you have a macro which does some eval on an 
> argument and the user passes it a function call which asks the user for input 
> from a console?
> 
> 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

-- 
You received this message because you are subscribed to the Google
Groups "Clojure

Re: Is this possible in Clojure?

2010-02-04 Thread Greg
>> It's not clear in the case of multiple packages or namespaces. (In which 
>> package does "name" get interned? It depends on *when* the string is 
>> interned, because that decides the enclosing scope. Or does newLISP not have 
>> packages?)
> 
> 
> NAME (not name) may be "interned" in the sense that it will exist somewhere 
> in the symbol tree, but that doesn't matter—at all. At least in newLISP. In 
> Clojure it may have some consequences and if so, that would be a valid 
> argument to make, I'd be interested to know what they are if that is the case.

Oh, I think I understand what you're asking. Are you worrying if the symbol 
won't be visible because the code could be run in a different namespace? That's 
actually an issue I ran into and so I had to pass in an additional argument to 
specify the namespace. I complained about it on newLISP's forums and luckily in 
the next version this won't be an issue because there will be a function that 
will give you the namespace that a given symbol belongs to.

- Greg


On Feb 4, 2010, at 6:18 PM, Greg wrote:

>> It's not clear in the case of multiple packages or namespaces. (In which 
>> package does "name" get interned? It depends on *when* the string is 
>> interned, because that decides the enclosing scope. Or does newLISP not have 
>> packages?)
> 
> 
> NAME (not name) may be "interned" in the sense that it will exist somewhere 
> in the symbol tree, but that doesn't matter—at all. At least in newLISP. In 
> Clojure it may have some consequences and if so, that would be a valid 
> argument to make, I'd be interested to know what they are if that is the case.
> 
>> Neither are the names specified in a query such as "SELECT * FROM people". 
>> Who knows what'll happen when you do "SELECT p1.name ...".
> 
> 
> This is incorrect. A query like "SELECT *" will not have any issues getting 
> the correct, expected names from the table definition. You can check the code 
> again, there's no string parsing going on with the query.
> 
>> - Quietly and maybe accidentally shadows variables from enclosing scopes
> 
> 
> If any shadowing happens, it's OK because you know it's going to happen. It's 
> also exceedingly unlikely it will happen due to naming convention and even if 
> it happens, it's *still OK* because nothing breaks because things are only 
> shadowed within the scope of the macro call and you're explicitly expecting 
> to use the NAME symbol, etc. There's zero confusion and zero ambiguity.
> 
>> - Uses eval (which apparently is fine in newLISP, but as a Common Lisper and 
>> Clojurite strikes me as pointless)
> 
> So, as I showed, the Clojure version seems to not require the use of eval.
> 
>> c.c.sql also allows you to synthesize queries from Lisp forms
> 
> This is a good point, and if I were to use Clojure I would use your version 
> instead.
> 
> - Greg
> 
> On Feb 4, 2010, at 5:53 PM, Richard Newman wrote:
> 
>>> OK, I hope you can see the difference though between that and what I showed.
>> 
>> Of course I can; I'm just illustrating a point by exaggeration.
>> 
>>> They are not the same; in your example:
>>> 
>>> - It's not clear what the magic symbols are
>>> - The user does not specify the magic symbols (as they did in mine)
>> 
>> It's not clear in the case of multiple packages or namespaces. (In which 
>> package does "name" get interned? It depends on *when* the string is 
>> interned, because that decides the enclosing scope. Or does newLISP not have 
>> packages?)
>> 
>> Neither are the names specified in a query such as "SELECT * FROM people". 
>> Who knows what'll happen when you do "SELECT p1.name ...".
>> 
>> You're about half-way to complete anaphora when you're starting to pull 
>> symbol names out of syntax-laden strings (or databases). That's magic, at 
>> least when compared to ordinary lexical symbol reference.
>> 
>> Given that there's little to no advantage to doing this, I don't see the 
>> point.
>> 
>>> This sort of programming style is easy to abuse and can sometimes lead to 
>>> confusion if handled incorrectly, but when applied in the appropriate 
>>> manner it can be extremely useful.
>>> 
>>> The 'for-query-with-db' function is a good example of doing this correctly 
>>> because it:
>>> 
>>> - Documents its behavior
>>> - Creates symbols based on user input, not of its own accord as in your 
>>> example
>>> - Clearly distinguishes them through a special naming convention
>>> - Has advantages over other forms of solving the same problem
>> 
>> ... and it's a bad example, because it:
>> 
>> - Quietly and maybe accidentally shadows variables from enclosing scopes
>> - Fails to nest queries which share names
>> - Silently interns new variable names in your packages
>> - Uses eval (which apparently is fine in newLISP, but as a Common Lisper and 
>> Clojurite strikes me as pointless)
>> - etc.
>> 
>> I see no point in doing this rather than going the conventional macro route. 
>> c.c.sql, for example, would do this:
>> 
>> (wit

Re: Pattern Matching

2010-02-04 Thread Tom Faulhaber
Also, check out Tim Lopez's work here: 
http://www.brool.com/index.php/pattern-matching-in-clojure

He has a nice version that can be used for both Lisp-y and Haskell-y
stuff, though it's not quite as full featured as what you'd see in
traditional AI systems.

Tom

-- 
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: Pattern Matching

2010-02-04 Thread Base
Hi John -

Thanks for a very intersting response.

Do you have any real experience in F#?  I am really interested in
hearing your opinion/thoughts on it relative to other functional
languages (you appear to be quite well versed).  It looks very
interesting, but I am frankly having a hard enough time with Clojure
to spend my time on trying to add more to my plate.

Thanks

Bassel

On Feb 4, 12:43 pm, Jon Harrop  wrote:
> On Thursday 04 February 2010 16:32:36 Sean Devlin wrote:
>
> > Pattern matching
>
> Ok. Pattern matching is a core construct from the ML family of languages and,
> consequently, is now ubiquitous in F#, OCaml, Standard ML and Haskell as well
> as Scala. In the MLs, pattern matching is the only way to destructure data.
>
> For example, you can extract the two elements of a pair and bind their values
> to the variable names "a" and "b" as follows (OCaml/F# code):
>
>   let a, b = a_pair
>
> Pattern matching is a powerful technique that has been generalized in many
> ways, so you can also destructure a pair of pairs by nesting patterns:
>
>   let (x0, y0), (x1, y1) = two_vectors
>
> Pattern matching is also used for dispatch in those languages (although the
> object oriented ones including OCaml and F# also provide method dispatch).
> Moreover, patterns can match on more than just objects, e.g. numbers:
>
>   let rec factorial = function
>     | 0 | 1 -> 1
>     | n -> n * factorial(n-1)
>
> Note the "or-pattern" 0|1 to match either 0 or 1.
>
> A more advanced example including nesting, or-patterns, guarded patterns
> (with "when") and named subpatterns is to merge two sorted lists (OCaml/F#
> code):
>
>   let rec merge = function
>     | [], xs | xs, [] -> xs
>     | x::xs', (y::_ as ys) when x <= y -> x::merge(xs', ys)
>     | xs, y::ys' -> y::merge(xs, ys')
>
> I've written about it here:
>
>  http://www.ffconsultancy.com/ocaml/benefits/pattern_matching.html
>
> You may also be interested in this symbolic simplifier challenge:
>
>  http://www.lambdassociates.org/studies/study10.htm
>
> Note that the Common Lisp solutions are 50-160% longer and 1.7-7.5x slower
> than the OCaml.
>
> Pattern matching is uncommon is Lisps because its core benefits (static
> checking and performance) rely upon static type information. However, some
> dynamic languages (e.g. Mathematica) do provide and make heavy use of pattern
> matching. On the other hand, dynamic languages can do lots of funky things
> with pattern matching that static languages do not, most notably allowing
> patterns to be generated at run-time (even MetaOCaml does not allow this).
>
> A major disadvantage of pattern matching can be that it requires libraries to
> expose their internals in order for a user to be able to pattern match over
> them. This problem was solved using view patterns which are bundled with F#
> (as "active patterns") and Scala (as "extractors").
>
> I have found pattern matching to be extremely valuable not only because it
> permits very clear and concise solutions to many problems but also because
> the static checking it provides allows me to leverage a static type system to
> prove aspects of correctness that remove major classes of bugs from real
> applications.
>
> HTH.
>
> --
> Dr Jon Harrop, Flying Frog Consultancy Ltd.http://www.ffconsultancy.com/?e

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


Re: Is this possible in Clojure?

2010-02-04 Thread Richard Newman
NAME (not name) may be "interned" in the sense that it will exist  
somewhere in the symbol tree, but that doesn't matter—at all. At  
least in newLISP. In Clojure it may have some consequences and if  
so, that would be a valid argument to make, I'd be interested to  
know what they are if that is the case.


It matters in Clojure because symbols are interned in namespaces, or  
they have no namespace. Symbols from different namespaces denote  
different things: for example, this works just fine in Clojure, even  
though it's a Lisp-1, because the local `keys` has no namespace.


  (let [keys "Chubb"]
(println (clojure.core/keys {:foo :bar})))

Neither are the names specified in a query such as "SELECT * FROM  
people". Who knows what'll happen when you do "SELECT p1.name ...".


This is incorrect. A query like "SELECT *" will not have any issues  
getting the correct, expected names from the table definition. You  
can check the code again, there's no string parsing going on with  
the query.


My point with that example is that it really is magic: the symbol name  
comes out of the DB, and isn't even mentioned in the syntax of the  
query. Against a different DB you'll get different results -- your  
code might even throw an error about a symbol not existing.


What does newLISP do for a query like

  SELECT p1.name, p2.name from people p1 JOIN people p2;

?

It's also exceedingly unlikely it will happen due to naming  
convention and even if it happens, it's *still OK* because nothing  
breaks because things are only shadowed within the scope of the  
macro call and you're explicitly expecting to use the NAME symbol,  
etc. There's zero confusion and zero ambiguity.


The literature about hygienic macros disagrees with you.

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


Re: Is this possible in Clojure?

2010-02-04 Thread Richard Newman
Enlive has to reconstruct HTML from its data structures. This, on  
the other hand, mostly just prints already "rendered" strings, and  
calls any clojure functions/macros along the way.


Most CL/Clojure HTML output systems, like clj-html or CL-WHO, produce  
optimal output by processing the macro input. See


http://weitz.de/cl-who/

for a description. This is one of the reasons to use macros: you can  
do a huge amount of work once, at compile-time, leaving the runtime  
with less to do.


Templating does not require eval.

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


Re: Is this possible in Clojure?

2010-02-04 Thread Greg
>  (let [keys "Chubb"]
>(println (clojure.core/keys {:foo :bar})))

Yes, I really like this aspect of Clojure.

> What does newLISP do for a query like
> 
>  SELECT p1.name, p2.name from people p1 JOIN people p2;

newLISP doesn't do anything, but sqlite3 will tell you that there are 2 columns 
for the result set of that query, and each is named "name", and they both 
happen to have the same value.

Now, if they came from different tables, you'd have a problem I think, but in 
that case I wouldn't use my macro, which is just for convenience, it's not 
designed to handle all queries perfectly. I'm sorry if I gave you the wrong 
impression.

> The literature about hygienic macros disagrees with you.

I've read some of that literature and I don't think it does, but you're more 
than welcome to elaborate. There are no variable capture issues here at least, 
because the fexpr is inside of its own context (that's what define-smacro does, 
the 's' is for 'safe').

- Greg

On Feb 4, 2010, at 8:05 PM, Richard Newman wrote:

>> NAME (not name) may be "interned" in the sense that it will exist somewhere 
>> in the symbol tree, but that doesn't matter—at all. At least in newLISP. In 
>> Clojure it may have some consequences and if so, that would be a valid 
>> argument to make, I'd be interested to know what they are if that is the 
>> case.
> 
> It matters in Clojure because symbols are interned in namespaces, or they 
> have no namespace. Symbols from different namespaces denote different things: 
> for example, this works just fine in Clojure, even though it's a Lisp-1, 
> because the local `keys` has no namespace.
> 
>  (let [keys "Chubb"]
>(println (clojure.core/keys {:foo :bar})))
> 
>>> Neither are the names specified in a query such as "SELECT * FROM people". 
>>> Who knows what'll happen when you do "SELECT p1.name ...".
>> 
>> This is incorrect. A query like "SELECT *" will not have any issues getting 
>> the correct, expected names from the table definition. You can check the 
>> code again, there's no string parsing going on with the query.
> 
> My point with that example is that it really is magic: the symbol name comes 
> out of the DB, and isn't even mentioned in the syntax of the query. Against a 
> different DB you'll get different results -- your code might even throw an 
> error about a symbol not existing.
> 
> What does newLISP do for a query like
> 
>  SELECT p1.name, p2.name from people p1 JOIN people p2;
> 
> ?
> 
>> It's also exceedingly unlikely it will happen due to naming convention and 
>> even if it happens, it's *still OK* because nothing breaks because things 
>> are only shadowed within the scope of the macro call and you're explicitly 
>> expecting to use the NAME symbol, etc. There's zero confusion and zero 
>> ambiguity.
> 
> The literature about hygienic macros disagrees with you.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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


Re: Is this possible in Clojure?

2010-02-04 Thread Greg
> Templating does not require eval.

I don't recall saying it did.

I think you misunderstood what I said. I was musing about implementing 
PHP-style templating in Clojure, and I was wondering whether it was possible to 
avoid calling eval on each render.

Someone has implemented PHP-style templating in Clojure:

http://www.brool.com/index.php/a-modest-proposal

And he does have some eval's in there:

http://github.com/brool/gulliver/blob/master/template-servlet.clj

But my Clojure knowledge isn't yet good enough to tell me whether he's using 
eval only once or on every render?

- Greg

On Feb 4, 2010, at 8:09 PM, Richard Newman wrote:

>> Enlive has to reconstruct HTML from its data structures. This, on the other 
>> hand, mostly just prints already "rendered" strings, and calls any clojure 
>> functions/macros along the way.
> 
> Most CL/Clojure HTML output systems, like clj-html or CL-WHO, produce optimal 
> output by processing the macro input. See
> 
> http://weitz.de/cl-who/
> 
> for a description. This is one of the reasons to use macros: you can do a 
> huge amount of work once, at compile-time, leaving the runtime with less to 
> do.
> 
> Templating does not require eval.
> 
> -- 
> 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: Is this possible in Clojure?

2010-02-04 Thread Richard Newman

And he does have some eval's in there:

http://github.com/brool/gulliver/blob/master/template-servlet.clj

But my Clojure knowledge isn't yet good enough to tell me whether  
he's using eval only once or on every render?


It uses eval at runtime, but only once: that code slurps a template,  
turns it into s-expressions, then uses eval to define a function named  
`render` in the appropriate namespace. Pretty nice.


That function is just like one defined in Clojure source: it'll get  
JITed, for example.


One might avoid the (minor) runtime work by "precompiling" templates:  
translating them into the equivalent Clojure source on disk, which can  
then be treated like ordinary source files. That's what Cheetah does  
for Python.


--
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: Naming Functions...

2010-02-04 Thread Wardrop
Hi Michael,

Thanks for the implementation suggestion. I left school 2 years only
so missed out on some of the more advanced mathematics, hence I was
unaware of the function and purpose of log. Since reading your post,
I've done a little bit of research on log as to educate myself. I've
now re-implemented my function using your logn implementation. It now
has a name also...

(defn recursively-divide
  "Divides n by base until n is smaller than base. Returns a map
consisting of the structure {:result :times}, where :result is the
result of the recursive division, and :times is the number of times n
was divided by base."
  [n base]
  (let [times (int (logn base n))]
{:result (float (/ n (expt base times))) :times times}))

I've chosen "recursively-divide" as it seemed more clojuresque, as it
reads like it would in english "recursively divide n by base".

I guess if I've learnt anything from just this function alone, it's
that often names are difficult to think of when it's hard to define
exactly what it is a function is doing. If you can't easily define
what a functions purpose is, then I think that usually means it's been
poorly designed/implemented (suggesting there's a better way) or the
coder isn't exactly sure what they're trying to achieve.

On Feb 4, 5:28 pm, Michael Wood  wrote:
> On 4 February 2010 09:04, Wardrop  wrote:
>
>
>
> > I often myself creating functions which perform a rather clear and
> > simple task, but which is hard to describe, either because I don't
> > know the term for what I've just implemented, or because the function
> > is difficult to summarise in a couple of words. As an example, I've
> > just created a function which determines how many times the value n,
> > can be divided by the base, until n becomes smaller than the base.
> > Here's the implementation...
>
> > (defn  [n base]
> >  (loop [n n count 0]
> >    (if (< n base)
> >      {:val n :count count}
> >      (recur (float (/ n base)) (inc count)
>
> > This can be used among other things, to determine how to format bytes.
> > Say I have a file that's 6,789,354 bytes, and I want to display that
> > in a more readable manner, I could use my unnamed function like so
> > ( 6789354 1024), and get a new appropriately rounded number,
> > including the number of times it has been rounded, which I can use the
> > pick the appropriate suffix from a list ("Bytes", "KB", "MB", "GB",
> > "TB).
>
> I would probably split that up:
>
> The division can just use /, so no need for a separate function.
> The rest can be done like this:
>
> (defn logn [n x]
>   (/ (java.lang.Math/log x) (java.lang.Math/log n)))
>
> Then you could have a function that formats file sizes:
>
> (defn format-file-size [num-bytes]
>   (let [base 1024
>         val (float (/ num-bytes base))
>         times (int (logn base num-bytes))]
> ...)
>
> Not sure if that helps with your general question, though :)
>
> > I mean, what the hell would you name this function, or would you not
> > create such an obscure and generalised function to start with?
>
> --
> 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: Is this possible in Clojure?

2010-02-04 Thread Greg
> It uses eval at runtime, but only once: that code slurps a template, turns it 
> into s-expressions, then uses eval to define a function named `render` in the 
> appropriate namespace. Pretty nice.

Awesome, yes that'll do then. Good to know this is possible in Clojure. I much 
prefer this style of templating to Enlive, because it makes it far easier to 
work with (IMO), and I wouldn't be surprised if it is faster too.

Thanks,

- Greg

On Feb 4, 2010, at 8:46 PM, Richard Newman wrote:

>> And he does have some eval's in there:
>> 
>> http://github.com/brool/gulliver/blob/master/template-servlet.clj
>> 
>> But my Clojure knowledge isn't yet good enough to tell me whether he's using 
>> eval only once or on every render?
> 
> It uses eval at runtime, but only once: that code slurps a template, turns it 
> into s-expressions, then uses eval to define a function named `render` in the 
> appropriate namespace. Pretty nice.
> 
> That function is just like one defined in Clojure source: it'll get JITed, 
> for example.
> 
> One might avoid the (minor) runtime work by "precompiling" templates: 
> translating them into the equivalent Clojure source on disk, which can then 
> be treated like ordinary source files. That's what Cheetah does for Python.
> 
> -- 
> 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: Seattle Clojure meeting

2010-02-04 Thread Howard Lewis Ship
I might drive up on the 15th, or take the train.  I'm just getting
back from London on the 14th though, so maybe next meeting for me.

On Wed, Feb 3, 2010 at 7:01 PM, Phil Hagelberg  wrote:
> Hello, clojurists of Seattle.
>
> Let's meet! I'm thinking of getting folks together from 7pm to 9pm at Zoka
> in the University District: http://bit.ly/c9jinW Topics may include
> Leiningen, deftype/protocols, getting set up with Emacs, or even getting
> another pair of eyes on that pet project that you've been playing around
> with recently. I suspect it'll be mostly talking and getting to know people,
> but bring laptops.
>
> I'm thinking of either the 11th or the 15th, depending on what works best
> for the most people. Let me know if you think you can make it to one or both
> of these times.
>
> -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



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.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: Full Disclojure - I Need Topics!

2010-02-04 Thread Greg
> Here's a challenge for you - Monads.  If you can clearly explain monads 
> you'll be my hero. :-)

Seconded. Plus the existing Clojure docs I'm able to find on monads seem to be 
totally out of date, the example code fails to run as well.

- Greg

On Feb 4, 2010, at 5:55 PM, Glen Stampoultzis wrote:

> On 25 January 2010 16:34, Sean Devlin  wrote:
> Hello everyone,
> I'm having a blast making the Full Disclojure series.  It's one the
> best projects I've had a chance to work on.
> 
> However, there's going to be a problem soon.  I only have a few more
> topics left before I run out.  No more topics, no more videos.
> 
> This is where you come in.  I'm interested in what the community (i.e.
> you) would like to see talked about.  It could be the core language,
> contrib, a popular library, your-really-awesome-library-that-you-would-
> like-to-get-exposure, or some development tool.  Bring up anything and
> everything.  If it's interesting enough, I'll try to do an episode on
> it.  There are no bad suggestions.
> 
> 
> Here's a challenge for you - Monads.  If you can clearly explain monads 
> you'll be my hero. :-)
> 
> 
> -- 
> 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: Full Disclojure - I Need Topics!

2010-02-04 Thread Seth
Sean,

The new installation videos look great -- I have linked to them from
my company's intranet. Any plans for an installation video for
Counterclockwise for Eclipse?

It's neat of you to produce these videos in your spare time -- they
are much appreciated!

On Feb 4, 9:35 pm, Greg  wrote:
> > Here's a challenge for you - Monads.  If you can clearly explain monads 
> > you'll be my hero. :-)
>
> Seconded. Plus the existing Clojure docs I'm able to find on monads seem to 
> be totally out of date, the example code fails to run as well.
>
> - Greg
>
> On Feb 4, 2010, at 5:55 PM, Glen Stampoultzis wrote:
>
>
>
> > On 25 January 2010 16:34, Sean Devlin  wrote:
> > Hello everyone,
> > I'm having a blast making the Full Disclojure series.  It's one the
> > best projects I've had a chance to work on.
>
> > However, there's going to be a problem soon.  I only have a few more
> > topics left before I run out.  No more topics, no more videos.
>
> > This is where you come in.  I'm interested in what the community (i.e.
> > you) would like to see talked about.  It could be the core language,
> > contrib, a popular library, your-really-awesome-library-that-you-would-
> > like-to-get-exposure, or some development tool.  Bring up anything and
> > everything.  If it's interesting enough, I'll try to do an episode on
> > it.  There are no bad suggestions.
>
> > Here's a challenge for you - Monads.  If you can clearly explain monads 
> > you'll be my hero. :-)
>
> > --
> > 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: Full Disclojure - I Need Topics!

2010-02-04 Thread Sean Devlin
On Feb 4, 9:54 pm, Seth  wrote:
> Sean,
>
> The new installation videos look great -- I have linked to them from
> my company's intranet. Any plans for an installation video for
> Counterclockwise for Eclipse?
>

Eclipse is on the to-do list.  Keep your eyes open.

> It's neat of you to produce these videos in your spare time -- they
> are much appreciated!

What is the spare time you speak of, and where can I find some? :)

Glad to help.

>
> On Feb 4, 9:35 pm, Greg  wrote:
>
>
>
> > > Here's a challenge for you - Monads.  If you can clearly explain monads 
> > > you'll be my hero. :-)
>
> > Seconded. Plus the existing Clojure docs I'm able to find on monads seem to 
> > be totally out of date, the example code fails to run as well.
>
> > - Greg
>
> > On Feb 4, 2010, at 5:55 PM, Glen Stampoultzis wrote:
>
> > > On 25 January 2010 16:34, Sean Devlin  wrote:
> > > Hello everyone,
> > > I'm having a blast making the Full Disclojure series.  It's one the
> > > best projects I've had a chance to work on.
>
> > > However, there's going to be a problem soon.  I only have a few more
> > > topics left before I run out.  No more topics, no more videos.
>
> > > This is where you come in.  I'm interested in what the community (i.e.
> > > you) would like to see talked about.  It could be the core language,
> > > contrib, a popular library, your-really-awesome-library-that-you-would-
> > > like-to-get-exposure, or some development tool.  Bring up anything and
> > > everything.  If it's interesting enough, I'll try to do an episode on
> > > it.  There are no bad suggestions.
>
> > > Here's a challenge for you - Monads.  If you can clearly explain monads 
> > > you'll be my hero. :-)
>
> > > --
> > > 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: Full Disclojure - I Need Topics!

2010-02-04 Thread Laurent PETIT
2010/2/5 Seth :
> Sean,
>
> The new installation videos look great -- I have linked to them from
> my company's intranet. Any plans for an installation video for
> Counterclockwise for Eclipse?

Hello,

there's this one I've realized very quickly (as a proof of concept
since it was my first screencam on linux for youtube):

http://www.youtube.com/watch?v=1T0ZjBMIQS8

No sound, just visual. Demonstrates counterclockwise installed from
scratch plus creation of a helloworld project in 3 minutes.
(pre-requisites : a working eclipse installation)

But I agree it would be more thaninteresting, it would be awesome, to
see Sean register and publish a full featured video on his vimeo
channel !


Keep up the good work!

>
> It's neat of you to produce these videos in your spare time -- they
> are much appreciated!
>
> On Feb 4, 9:35 pm, Greg  wrote:
>> > Here's a challenge for you - Monads.  If you can clearly explain monads 
>> > you'll be my hero. :-)
>>
>> Seconded. Plus the existing Clojure docs I'm able to find on monads seem to 
>> be totally out of date, the example code fails to run as well.
>>
>> - Greg
>>
>> On Feb 4, 2010, at 5:55 PM, Glen Stampoultzis wrote:
>>
>>
>>
>> > On 25 January 2010 16:34, Sean Devlin  wrote:
>> > Hello everyone,
>> > I'm having a blast making the Full Disclojure series.  It's one the
>> > best projects I've had a chance to work on.
>>
>> > However, there's going to be a problem soon.  I only have a few more
>> > topics left before I run out.  No more topics, no more videos.
>>
>> > This is where you come in.  I'm interested in what the community (i.e.
>> > you) would like to see talked about.  It could be the core language,
>> > contrib, a popular library, your-really-awesome-library-that-you-would-
>> > like-to-get-exposure, or some development tool.  Bring up anything and
>> > everything.  If it's interesting enough, I'll try to do an episode on
>> > it.  There are no bad suggestions.
>>
>> > Here's a challenge for you - Monads.  If you can clearly explain monads 
>> > you'll be my hero. :-)
>>
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Clojure" group.
>> > To post to this group, send email to clojure@googlegroups.com
>> > Note that posts from new members are moderated - please be patient with 
>> > your first post.
>> > To unsubscribe from this group, send email to
>> > clojure+unsubscr...@googlegroups.com
>> > For more options, visit this group at
>> >http://groups.google.com/group/clojure?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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


Re: Seattle Clojure meeting

2010-02-04 Thread Tim Clemons
I'm interested as well.  Either the 11th or 15th works for me.

-- Tim.

On Feb 4, 5:57 pm, Howard Lewis Ship  wrote:
> I might drive up on the 15th, or take the train.  I'm just getting
> back from London on the 14th though, so maybe next meeting for me.
>
>
>
> On Wed, Feb 3, 2010 at 7:01 PM, Phil Hagelberg  wrote:
> > Hello, clojurists of Seattle.
>
> > Let's meet! I'm thinking of getting folks together from 7pm to 9pm at Zoka
> > in the University District:http://bit.ly/c9jinWTopics may include
> > Leiningen, deftype/protocols, getting set up with Emacs, or even getting
> > another pair of eyes on that pet project that you've been playing around
> > with recently. I suspect it'll be mostly talking and getting to know people,
> > but bring laptops.
>
> > I'm thinking of either the 11th or the 15th, depending on what works best
> > for the most people. Let me know if you think you can make it to one or both
> > of these times.
>
> > -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
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
>
> (971) 678-5210http://howardlewisship.com

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


Re: Clojure for system administration

2010-02-04 Thread Tim Clemons
Perhaps the solution is to have a *nix shell implemented in Clojure.
That would limit the start-up issue to a single initial instance.
Then the user can proceed to use regular command-line functionality
interspersed with Clojure scripts.  Think of it as a hybrid REPL.

On Feb 4, 9:35 am, Phil Hagelberg  wrote:
> On Thu, Feb 4, 2010 at 8:33 AM, Stuart Sierra
>
>  wrote:
> > Clojure can certainly do these things; clojure-contrib contains many
> > file and io-related utilities.  But remember that Clojure, like any
> > Java program, takes more time to start up than "scripting" languages
> > like Perl/Bash/Ruby/Python, so it may be less suitable for programs
> > that you intend to run at the command-line.
>
> Also relevant is the fact that launching Clojure from the command-line
> is very inconvenient compared to scripting languages. If you want
> something simple you can just put on your path, you'll need to wrap it
> in a bash (or other language) script anyway to handle the classpath,
> etc. The combination of startup time and the need to roll your own
> bash script even for simple things has kept me from wanting to use
> Clojure as a perlish-replacement.
>
> -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 for system administration

2010-02-04 Thread Greg
A much easier solution is to go with a lisp designed for exactly the task of 
scripting.

I whole-heartedly recommend newLISP for this:

http://www.newlisp.org/

Clojure is excellent when you need a powerhouse LISP capable of great feats, 
but newLISP is far better suited for scripting tasks, it was designed for that.

Or you can implement a *nix shell in Clojure. :-p

- Greg

On Feb 5, 2010, at 12:42 AM, Tim Clemons wrote:

> Perhaps the solution is to have a *nix shell implemented in Clojure.
> That would limit the start-up issue to a single initial instance.
> Then the user can proceed to use regular command-line functionality
> interspersed with Clojure scripts.  Think of it as a hybrid REPL.
> 
> On Feb 4, 9:35 am, Phil Hagelberg  wrote:
>> On Thu, Feb 4, 2010 at 8:33 AM, Stuart Sierra
>> 
>>  wrote:
>>> Clojure can certainly do these things; clojure-contrib contains many
>>> file and io-related utilities.  But remember that Clojure, like any
>>> Java program, takes more time to start up than "scripting" languages
>>> like Perl/Bash/Ruby/Python, so it may be less suitable for programs
>>> that you intend to run at the command-line.
>> 
>> Also relevant is the fact that launching Clojure from the command-line
>> is very inconvenient compared to scripting languages. If you want
>> something simple you can just put on your path, you'll need to wrap it
>> in a bash (or other language) script anyway to handle the classpath,
>> etc. The combination of startup time and the need to roll your own
>> bash script even for simple things has kept me from wanting to use
>> Clojure as a perlish-replacement.
>> 
>> -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

-- 
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 for system administration

2010-02-04 Thread ataggart


On Feb 4, 9:35 am, Phil Hagelberg  wrote:
> On Thu, Feb 4, 2010 at 8:33 AM, Stuart Sierra
>
>  wrote:
> > Clojure can certainly do these things; clojure-contrib contains many
> > file and io-related utilities.  But remember that Clojure, like any
> > Java program, takes more time to start up than "scripting" languages
> > like Perl/Bash/Ruby/Python, so it may be less suitable for programs
> > that you intend to run at the command-line.
>
> Also relevant is the fact that launching Clojure from the command-line
> is very inconvenient compared to scripting languages.

Does nailgun not solve that issue?

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