Re: Clojure & CEDET?

2011-03-07 Thread Konrad Hinsen

On 8 Mar 2011, at 02:44, Fred Concklin wrote:


Just wondering if anybody uses CEDET with clojure or anybody would be
interested in clojure language support for smart code completion.


I use Clojure, and I use CEDET (not just for Clojure), and I'd  
certainly like to have code completion for Clojure in CEDET.


Konrad.

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


Re: Are there sets that keep the insertion order?

2011-03-07 Thread Justin Kramer
https://github.com/ninjudd/ordered-set

Justin

On Mar 7, 1:14 pm, Tassilo Horn  wrote:
> Hello all,
>
> does clojure have sets that keep the insertion order, like Java's
> LinkedHashSet?
>
> Currently, I use lazy vectors in conjunction with `distinct', but that
> seems to perform not too well.
>
> Bye,
> Tassilo

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


Re: Clojure CLR ISeq IEnumerable

2011-03-07 Thread dmiller
I hesitate to modify the inheritance structure of Clojure's
interfaces.
ClojureCLR does follow ClojureJVM in providing support for these
interfaces in the abstract base classes underlying things such as
PersistentTreeMap.

In ClojureCLR 1.3-alpha:

public class PersistentTreeMap : APersistentMap, IObj,
   Reversible, Sorted, IEnumerable,
IDictionary

public abstract class APersistentMap: AFn, IPersistentMap,
   IDictionary, IEnumerable,
MapEquivalence,
   IDictionary

The only difference in 1.3-alpha versus 1.2 is that 1.3 adds the
generics IEnumerable and IDictionary for
interop with System.Linq and related libraries.  1.2 does have the
IEnumerable defined.  The entries iterated are IMapEntry.

So you should be able cast directly to IEnumerable in either version,
without casting to PersistentTreeMap.

-David


On Mar 7, 5:54 pm, Timothy Pratley  wrote:
> Feature request:
> It would be handy for ISeq to inherit IEnumerable.
> My use case is wanting to expose an IEnumerable "Values" from a
> Clojure IPersistentMap (vals ) call
> Currently I can do it easily enough by casting to PersistentTreeMap
> which has a .Values implementation, but I suspect there is probably a
> smarter solution... :)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 *compile-path* not set properly

2011-03-07 Thread Armando Blancas
Oops -- I got the class and compile paths mixed up. But I wonder why
that worked in the OP.

On Mar 7, 6:27 pm, Stuart Sierra  wrote:
> The Java system property "clojure.compile.path" is the directory where the
> Clojure compiler will write out .class files.  It should be one directory
> name, not a list.  
>
> When Clojure starts, it sets the Var *compile-path* to the value of the Java
> system property. The default is the directory named "classes".
>
> Whatever value you set for clojure.compile.path, that directory must also be
> on the Java classpath, set with the -cp command-line option to java.
>
> So, if you want to compile Clojure namespaces rooted at the current
> directory, you would run:
>
>     java -Dclojure.compile.path=. -cp .:clojure.jar clojure.main
>
> -Stuart Sierra
> clojure.com

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


Re: overriding keyword behavior?

2011-03-07 Thread Ken Wesson
On Mon, Mar 7, 2011 at 9:34 PM, Stuart Sierra
 wrote:
> Yes, something like tonyl's code will work.

OH RLY?

#

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: overriding keyword behavior?

2011-03-07 Thread Stuart Sierra
Yes, something like tonyl's code will work.

-S

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

Re: 1.3 (inc alpha4)?

2011-03-07 Thread Stuart Sierra
JIRA Release.Next means the final release of what is currently called 
1.3.0-alpha*.  More general information is available on the wiki: 
http://dev.clojure.org/display/design/Release.Next+Planning

Currently the Clojure/core team is trying to get this release ready for 
beta.  Some open bugs need fixing first.

-Stuart Sierra
clojure.com

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

Re: Clojure *compile-path* not set properly

2011-03-07 Thread Stuart Sierra
The Java system property "clojure.compile.path" is the directory where the 
Clojure compiler will write out .class files.  It should be one directory 
name, not a list.  

When Clojure starts, it sets the Var *compile-path* to the value of the Java 
system property. The default is the directory named "classes".

Whatever value you set for clojure.compile.path, that directory must also be 
on the Java classpath, set with the -cp command-line option to java.

So, if you want to compile Clojure namespaces rooted at the current 
directory, you would run:

java -Dclojure.compile.path=. -cp .:clojure.jar clojure.main

-Stuart Sierra
clojure.com

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

Re: overriding keyword behavior?

2011-03-07 Thread tonyl
I little redundant but looking now at the source code in Keyword.java

the Keyword class extends IFn, Comparable, Named, and Serializable;
they are all java that you could extend.
But I am not sure how the keyword lookup system works, haven't look
into it.
Just something that might help.

On Mar 6, 9:27 pm, kurtharriger  wrote:
> I was curious if it was possible to extend keyword lookup behavior to
> additional types, such as java.util.Properties.
>
> Currently I just convert java.util.properties into a keyword map with
> something such as the following.
> (defn as-keyword-map [prop]
>   (into {} (for [[k v] prop] [(keyword k) v])))
>
> This works well enough but I thought this might be possible to extend
> keywords or java.util.Properties via protocols or something to change
> the implementation of (:access-key prop) to (.get "access-key" prop).
> Its easy enough to redefine get using multimethods so that (get
> prop :access-key) would work on any type I wanted but I couldn't
> figure out how to do the same with keywords.  Looking at keyword.java
> it expects that object implements ILookup so I tried using (extend-
> type java.util.Properties Lookup ...) however ILookup isn't a protocol
> so this doesn't seem to work.
>
> I'm beginning to think that implementation of keywords being
> implemented in java doesn't support clojures more advanced
> extensibility features.  This makes me wonder if using the more
> idiomatic (:access-key obj) instead of (get obj :access-key) also
> limits my future extensibility options.  Is there a way to do this
> that I haven't thought of? and would it be possible to make ILookup
> into a protocol to enable this type of extensibility?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: overriding keyword behavior?

2011-03-07 Thread tonyl
I haven't tested it or anything, but you can use:
(extend-type java.util.Properties
ILookup
(valAt [this key] ...)
(valAt [this key not-found] ...))

AFAIK you can extend on Interfaces but not Abstracts or Classes.

On Mar 6, 9:27 pm, kurtharriger  wrote:
> I was curious if it was possible to extend keyword lookup behavior to
> additional types, such as java.util.Properties.
>
> Currently I just convert java.util.properties into a keyword map with
> something such as the following.
> (defn as-keyword-map [prop]
>   (into {} (for [[k v] prop] [(keyword k) v])))
>
> This works well enough but I thought this might be possible to extend
> keywords or java.util.Properties via protocols or something to change
> the implementation of (:access-key prop) to (.get "access-key" prop).
> Its easy enough to redefine get using multimethods so that (get
> prop :access-key) would work on any type I wanted but I couldn't
> figure out how to do the same with keywords.  Looking at keyword.java
> it expects that object implements ILookup so I tried using (extend-
> type java.util.Properties Lookup ...) however ILookup isn't a protocol
> so this doesn't seem to work.
>
> I'm beginning to think that implementation of keywords being
> implemented in java doesn't support clojures more advanced
> extensibility features.  This makes me wonder if using the more
> idiomatic (:access-key obj) instead of (get obj :access-key) also
> limits my future extensibility options.  Is there a way to do this
> that I haven't thought of? and would it be possible to make ILookup
> into a protocol to enable this type of extensibility?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 & CEDET?

2011-03-07 Thread Fred Concklin
Just wondering if anybody uses CEDET with clojure or anybody would be
interested in clojure language support for smart code completion. 

http://cedet.sourceforge.net/

fpc 

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 CLR ISeq IEnumerable

2011-03-07 Thread Timothy Pratley
Feature request:
It would be handy for ISeq to inherit IEnumerable.
My use case is wanting to expose an IEnumerable "Values" from a
Clojure IPersistentMap (vals ) call
Currently I can do it easily enough by casting to PersistentTreeMap
which has a .Values implementation, but I suspect there is probably a
smarter solution... :)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 *compile-path* not set properly

2011-03-07 Thread Armando Blancas
That's the default. You'd usually use the sys env clojure.compile.path
for the repl (on windows):

>java -Dclojure.compile.path=".;src;classes" -cp clojure.jar clojure.main
Clojure 1.2.0
user=> *compile-path*
".;src;classes"


On Mar 6, 5:32 pm, MC Andre  wrote:
> Clojure can't find and compile my scripts unless I augment the compile
> path.
>
> Specs:
>
> Clojure 1.2.0
> MacPorts 1.9.2
> Mac OS X 10.6.6
>
> $ cat hello.clj
> #!/usr/bin/env clj
>
> (ns hello)
> (println "Hello World!")
> $ clj hello.clj
> Hello World!
> $ clj
> Clojure 1.2.0
> user=> (compile 'hello)
> Hello World!
> java.io.IOException: No such file or directory (NO_SOURCE_FILE:0)
> user=> *compile-path*
> "classes"
> user=> (set! *compile-path* (str *compile-path* ":."))
> "classes:."
> user=> (compile 'hello)
> Hello World!
> hello

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Summer of Code 2011

2011-03-07 Thread Armando Blancas
You're not missing anything. In a lisp DSL, the L is a figure of
speech, for it's still lisp. Sure, lisp libraries can have great ease
and convenience as if they came with the language, but it won't be a
different language altogether --i.e., something that it ain't lisp.
Last year I wrote a little scripting module for the core postscript
and parsed it with antlr. As you point out, Clojure handles a bunch of
data with their respective parsers, and you'll need to provide your
own or a third party as needed.

On Mar 5, 11:35 am, Timothy Washington  wrote:
> Indeed :)
>
> I've actually been thinking about that. And from what I can tell, LISP DSLs
> are simply extensions to the LISP language. But maybe I still haven't gotten
> my head wrapped around '*defmacros*' and how they implements DSLs. It seems
> to me though, that someone could still want to parse *SQL* or *XQuery* or
> any *non-s-expression grammar*. And I don't see how to do that with '*
> defmacros*'. So, clojure does currently handle non s-expression grammars,
> but...
>
>    - XML - uses Java's xml parser facility
>    - Regex - is handled by Java's regex facility
>    - etc
>
> Am I missing something here? From what I can tell, you'd still need an
> outside library, or Parser Generator (BNF or otherwise), to handle something
> like SQL or XQuery.
>
> Thanks
>
> Tim Washington
> twash...@gmail.com
> 416.843.9060
>
>
>
> On Sat, Mar 5, 2011 at 12:35 AM, Ken Wesson  wrote:
> > On Fri, Mar 4, 2011 at 10:50 PM, Timothy Washington 
> > wrote:
> > > I can tell you the tools that I'm investigating:
> > > A) From what I can tell, there's no standard (E)BNF parser generator for
> > > clojure.
>
> > Who needs an (E)BNF parser generator when you've got defmacro? ;)
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en- Hide quoted text -
>
> - Show quoted text -

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


having trouble with http.async.client

2011-03-07 Thread Kevin Archie
I'm trying to use http.async.client to do a PUT request (where I don't
care about the response) and my code is hanging -- apparently after
succesfully completing the PUT, from the server's perspective.

This isn't quite what I'm doing, but exhibits the same behavior:

(require '[http.async.client :as c])
(c/with-client {} (c/PUT "http://any-site.com"; :body "test"))

When I try this against any URL (valid and accepting PUT, valid but
not accepting PUT, nonexistent), the call doesn't complete. Is there
something I'm doing wrong?

I've tried using a variety of permutations c/await and c/string on the
returned request object and get essentially the same behavior. I'm
getting the impression that there's some bit of laziness that doesn't
complete, and that the close won't return until it's done, but I may
be mistaken.

Thanks, and my apologies if this isn't the right forum for this
question.

  - Kevin

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Are there sets that keep the insertion order?

2011-03-07 Thread Tassilo Horn
Ken Wesson  writes:

Hi Ken,

>> does clojure have sets that keep the insertion order, like Java's
>> LinkedHashSet?
>
> Try something like:
>
> (deftype OrderPreservingSet [v m s]
> [...]

Great, I'll try that tomorrow.

> It should be substitutable for a normal set in Clojure code, but it
> seqs and prints itself in insertion order.  Performance caveat: if you
> keep conjing and disjing items from an open-ended set the internal
> vector may keep growing.

I'm doing a graph querying DSL with clojure.  I need the ordered sets
there, and I only need fast insertion and membership test, but I will
never disjoin elements.

Bye,
Tassilo

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


Re: Summer of Code 2011

2011-03-07 Thread Chas Emerick

On Mar 7, 2011, at 11:08 AM, Ken Wesson wrote:

>>> On Sun, Mar 6, 2011 at 11:00 AM, Chas Emerick  wrote:
 Rather than enumerate the places where sexprs are sub-optimal, it would 
 save a *lot* of time to simply point out that:
 
 (a) Every general-purpose programming language notation is a poor 
 substitute for the "native" notation of every domain
>>> 
>>> Ah, but what, pray tell, *is* "the native notation" of a domain?
>> 
>> Whatever the specialists in that domain say it is.
> 
> Bzzzt, sorry. Their choice seems as arbitrary as any other, much of
> the time. Ask yourself this: if aliens from another planet are at
> about the same level of development as us, are they likely to be using
> the same or a closely similar notation? (Modulo different glyphs and
> words -- is the syntax going to be close?)

The "What if...?" [1] question is silly, because notation is inherently bound 
up in culture, history, and biology; it's the semantics of things that might be 
similar, and only for the most foundational of disciplines.

As a thought experiment, how might a people with far better vision than us and 
nothing like written language program?  Maybe using something like Piet [2].

Signing off,

- Chas


[1] http://en.wikipedia.org/wiki/What_If_%28comics%29
[2] http://www.dangermouse.net/esoteric/piet/samples.html

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Summer of Code 2011

2011-03-07 Thread Ken Wesson
On Mon, Mar 7, 2011 at 1:56 PM, Timothy Baldridge  wrote:
>>...because they are easier to parse by the human brain.
>
> You keep saying that, and I don't think I agree. They may be easier to
> parse for western culture due to the hundreds of years of our brains
> being presented with data in that format. What's to say that
> s-expressions wouldn't be easier to understand given enough practice?
>
> Look at LISP in generalfor the beginner it looks like a mess of
> unreadable parentheses. But talk to any LISP programmer, and they will
> tell you that they don't even notice them any more. I know I don't.
> One could say "base 10 numbers are easier for the human mind to
> understand". But the truth is, if we were taught hexadecimal from
> birth, we probably wouldn't have any issue multiplying 0xFF and 0x03.

Oh, that's easy. 0x2FD.

> I think you underestimate how adaptable the human mind really is.

+0x01. ;)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Summer of Code 2011

2011-03-07 Thread Ken Wesson
On Mon, Mar 7, 2011 at 1:48 PM, Meikel Brandmeyer  wrote:
> Hi,
>
> Am 07.03.2011 um 17:08 schrieb Ken Wesson:
>
>> Bzzzt, sorry. Their choice seems as arbitrary as any other, much of
>> the time. Ask yourself this: if aliens from another planet are at
>> about the same level of development as us, are they likely to be using
>> the same or a closely similar notation? (Modulo different glyphs and
>> words -- is the syntax going to be close?)
>
> Probably not.

Oho!

> Because the choice is not arbitrary.

What? But you just indicated ...

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Are there sets that keep the insertion order?

2011-03-07 Thread Ken Wesson
On Mon, Mar 7, 2011 at 1:14 PM, Tassilo Horn  wrote:
> Hello all,
>
> does clojure have sets that keep the insertion order, like Java's
> LinkedHashSet?
>
> Currently, I use lazy vectors in conjunction with `distinct', but that
> seems to perform not too well.
>
> Bye,
> Tassilo

Try something like:

(deftype OrderPreservingSet [v m s]
  clojure.lang.IObj
(withMeta [this md] (OrderPreservingSet. v (with-meta m md) s))
(meta [this] (meta m))
  clojure.lang.IPersistentSet
(cons [this object]
  (if (contains? m object)
this
(OrderPreservingSet.
  (conj v object)
  (assoc m object (count v))
  s)))
(count [this] (count m))
(empty [this] (OrderPreservingSet. [] {} (Object.)))
(equiv [this other] (= (seq this) other))
(seq [this] (seq (remove #{s} v)))
(get [this object]
  (v (m object)))
(contains [this object]
  (contains? m object))
(disjoin [this object]
  (if-let [idx (m object)]
(OrderPreservingSet.
  (assoc v idx s)
  (dissoc m object)
  s)
   this))
  clojure.lang.IFn
(invoke [this object]
  (get this object))
(invoke [this object not-found]
  (get this object not-found)))

(defn order-preserving-set [& things]
  (reduce conj (OrderPreservingSet. [] {} (Object.)) things))

Cursory testing shows this working as expected (other than that
calling it as a function with the wrong arity will produce a different
exception from the usual IAE):

user=> (def foo (order-preserving-set 300 900 150 650 300))
#'user/foo
user=> foo
#{300 900 150 650}
user=> (def bar (Integer. 450))
#'user/bar
user=> (= bar (Integer. 450))
true
user=> (identical? bar (Integer. 450))
false
user=> (identical? ((conj foo bar) bar) bar)
true
user=> (disj foo 900)
#{300 150 650}
user=>

It should be substitutable for a normal set in Clojure code, but it
seqs and prints itself in insertion order. Performance caveat: if you
keep conjing and disjing items from an open-ended set the internal
vector may keep growing. The alternative isn't pretty though: actually
delete items from the internal vector, which would make disj O(n).

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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 *compile-path* not set properly

2011-03-07 Thread MC Andre
Clojure can't find and compile my scripts unless I augment the compile
path.

Specs:

Clojure 1.2.0
MacPorts 1.9.2
Mac OS X 10.6.6

$ cat hello.clj
#!/usr/bin/env clj

(ns hello)
(println "Hello World!")
$ clj hello.clj
Hello World!
$ clj
Clojure 1.2.0
user=> (compile 'hello)
Hello World!
java.io.IOException: No such file or directory (NO_SOURCE_FILE:0)
user=> *compile-path*
"classes"
user=> (set! *compile-path* (str *compile-path* ":."))
"classes:."
user=> (compile 'hello)
Hello World!
hello

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Web/Screenscraping Library?

2011-03-07 Thread Ambrose Bonnaire-Sergeant
If the website serves RDF, you can use Plaza
https://github.com/antoniogarrote/clj-plaza

Just from a casual browse of UM
Online LIbrary, some of their pages are in RDFa.

Ambrose

On Mon, Mar 7, 2011 at 12:48 AM, Jonathan Mitchem wrote:

> Are there any libraries that can extract structured web content as
> represented visually in the browser?
>
> I realize I could write regexes and extract using the HTML, but I was
> wondering if there was something that worked with the browser-rendered
> representation.  I.e., something a tad more human-readable: I'd like to have
> a simple syntax to represent the input pattern as presented in the browser
> and have it map into a structured list/map/array.
>
> For instance, (from the UMichigan Online Library)
>
> Poetry Here and Then
> A sampling of the papers of Michigan poets from various collections housed
> at the Bentley Historical Library, featuring handwritten and typed
> manuscripts, letters and essays as well as photographs, sketches,
> certificates and other personal items.
> Format: Image Collections
> Access: public
> Search within group: University of Michigan Collections
> Sponsor: Digital Library Production Service
> Statistics Detail: statistics detail
>
>
> [Next record, same format]
>
>
> That presentation is standardized, and repeated for a hundred+ items.
>
> I'd like to be able to easily turn it into something like:
>
> '(:title "Poetry Here and Then" :description "A sampling..." :format "Image
> Collections" :access "public" ... etc.)
>
>
> Again, I know I can do it with regex parsing of the HTML itself, but I was
> wondering if there were any libraries to make that process smoother.
>
>
> Thanks,
> Jonathan
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from 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: Web/Screenscraping Library?

2011-03-07 Thread Ambrose B
If the website serves RDF, you can use Plaza
https://github.com/antoniogarrote/clj-plaza

Just from a casual browse of UM
Online LIbrary, some of their pages are in RDFa.

Ambrose

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

overriding keyword behavior?

2011-03-07 Thread kurtharriger
I was curious if it was possible to extend keyword lookup behavior to
additional types, such as java.util.Properties.

Currently I just convert java.util.properties into a keyword map with
something such as the following.
(defn as-keyword-map [prop]
  (into {} (for [[k v] prop] [(keyword k) v])))

This works well enough but I thought this might be possible to extend
keywords or java.util.Properties via protocols or something to change
the implementation of (:access-key prop) to (.get "access-key" prop).
Its easy enough to redefine get using multimethods so that (get
prop :access-key) would work on any type I wanted but I couldn't
figure out how to do the same with keywords.  Looking at keyword.java
it expects that object implements ILookup so I tried using (extend-
type java.util.Properties Lookup ...) however ILookup isn't a protocol
so this doesn't seem to work.

I'm beginning to think that implementation of keywords being
implemented in java doesn't support clojures more advanced
extensibility features.  This makes me wonder if using the more
idiomatic (:access-key obj) instead of (get obj :access-key) also
limits my future extensibility options.  Is there a way to do this
that I haven't thought of? and would it be possible to make ILookup
into a protocol to enable this type of extensibility?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Summer of Code 2011

2011-03-07 Thread Timothy Baldridge
>...because they are easier to parse by the human brain.

You keep saying that, and I don't think I agree. They may be easier to
parse for western culture due to the hundreds of years of our brains
being presented with data in that format. What's to say that
s-expressions wouldn't be easier to understand given enough practice?

Look at LISP in generalfor the beginner it looks like a mess of
unreadable parentheses. But talk to any LISP programmer, and they will
tell you that they don't even notice them any more. I know I don't.
One could say "base 10 numbers are easier for the human mind to
understand". But the truth is, if we were taught hexadecimal from
birth, we probably wouldn't have any issue multiplying 0xFF and 0x03.
I think you underestimate how adaptable the human mind really is.

Timothy

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


await-for returning false, not nil

2011-03-07 Thread Ben Gladwell
I'm using clojure 1.2.0.  According to the await-for doc string, it
should return nil when returning because of a timeout.  But in all my
tests, it returns false (and true when returning because the agent is
done).

For example:

(defn sleep [_ n]
  (println (format "Sleeping for %d seconds" (* n 1000)))
  (Thread/sleep (* n 1000))
  (println (format "Done sleeping for %d seconds" (* n 1000

(def a1 (agent nil))

(send-off a1 sleep 6)

; prints false when agent is still running (not nil)
(println (await-for 2000 a1))

; prints true
(println (await-for 1 a1))

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Implementing "ClojureScript" - command-line/sys-admin scripting with Clojure

2011-03-07 Thread icylisper
I had been working on a tool that provides a persistent JVM for
command line applications. It is called jark.

It does not compete with any of the clojure build tools(lein, cljr),
but cleanly integrates with them.

You can find more about it here: http://icylisper.in/clojure/jark.html
I am yet to make a release. However, it is usable and source can be
found at https://github.com/icylisper/jark.

-
isaac
(icylisper)


On Mar 7, 4:41 am, rberger  wrote:
> Cake (http://clojure-cake.org/) has a nice mechanism to get around the
> slow startup issue of JVM/Clojure. I built a couple of command line
> tools using that. And it has some other nice features for Clojure
> development as well.
>
> Rob
>
> On Mar 4, 1:29 am, Shlomi Fish  wrote:
>
>
>
>
>
>
>
> > Hi all,
>
> > I've decided to offer a 200 USD bounty for implementing "ClojureScript" (a
> > tentative name), a Clojure API and a convenient command line utility for
> > performing quick system admin tasks, text manipulation tasks, command line
> > scripting, etc. similar to the use cases of bash/awk/sed or bash along with
> > /usr/bin/perl . If you're interested in doing this let me know.
>
> > Motivation:
> > ---
>
> > For a long time, I've desired a usable and popular dialect of Lisp, which 
> > was
> > the promise of Paul Graham's Arc (http://www.paulgraham.com/arc.html) and of
> > several other attempts, including some of my own attempts nicknamed "Park" 
> > and
> > "Spark". Now, it seems that the most trendy dialect of Lisp has become
> > Clojure, and while I challenge some of its design decisions, it seems pretty
> > nice.
>
> > One of the things that make a language popular and likable is its utility 
> > for
> > quick-and-dirty tasks. For further motivation please see:
>
> > *http://www.paulgraham.com/popular.html
>
> > *http://www.paulgraham.com/power.html
>
> > *http://www.shlomifish.org/philosophy/computers/perl/joy-of-perl/
>
> > *http://xoa.petdance.com/Stop_saying_%22script%22
>
> > *http://www.joelonsoftware.com/articles/FiveWorlds.html-see what he says
> > about "throwaway" code vs. inhouse code vs. "shrinkwrap" code.
>
> > *http://www.perl.com/pub/2007/12/06/soto-11.html-Larry Wall's "Programming
> > is Hard, Let's Go Scripting".
>
> > *http://perl.org.il/presentations/larry-wall-present-continuous-future-
> > perfect/transcript.html
>
> > (short URL -http://xrl.us/bhks6t).
>
> > *http://perl.plover.com/yak/12views/samples/notes.html#sl-39-titled "Why
> > Lisp Will Never Win" - comparing and contrasting Common Lisp to Awk and 
> > Perl.
>
> > ---
>
> > How to do it:
> > -
>
> > The one who will perform the task, will look at the scripting capabilities 
> > of
> > Perl 5, Ruby, Perl 6, Python, Bash and zsh (one can use Freenode for asking
> > questions about them) and will devise a specification for implementing
> > something similar in Clojure.
>
> > Afterwards, they will implement it as a user-land, high-level API above
> > Clojure with a simple command line front-end tentatively called "lurk", 
> > which
> > will be useful for it. Once completed, they will get the money, and credit.
>
> > The licence of the newly written code has to be the MIT/X11 licence 
> > (see:http://en.wikipedia.org/wiki/MIT_License) or a similar permissive 
> > licence
> > compatible with both the GPLv2 and the GPLv3.
>
> > Please let me know if you have further questions. You can contact me in
> > various ways here:
>
> >http://www.shlomifish.org/me/contact-me/
>
> > (I prefer either one of my Jabber accounts or MSN as IM, and I don't always
> > have IRC on.)
>
> > Regards,
>
> >         Shlomi Fish
>
> > --
> > -
> > Shlomi Fish      http://www.shlomifish.org/
> > Why I Love Perl -http://shlom.in/joy-of-perl
>
> > Modern Perl - the 3-D Movie. In theatres near you.
>
> > Please reply to list if it's a mailing list post -http://shlom.in/reply.

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


ANN: jark - tool to run clojure programs on a persistent JVM

2011-03-07 Thread icylisper
Startup time of the Java Virtual Machine(JVM) is too slow and thereby
command-line applications on the JVM are sluggish and very painful to
use. And there is no existing simple way for multiple clients to
access the same instance of the JVM.

Jark is an attempt to run the JVM as a daemon and support connections
from various clients like emacs, vim and even the command line.
Note that jark currently works only on GNU/Linux. I will port it to
windows/mac someday.
There are other systems such as cake which provides a persistent JVM.
However, I wanted something that is modular and easy to extend...
It uses nailgun under the hood.

Read more at: http://icylisper.in/clojure/jark.html

USAGE: jark MODULE COMMAND [ARGS]
Available modules:
cljr - reload add
cp  - list add run
doc- search examples comments
if- cli cli-json
ns  - find list load repl run
package - install uninstall versions describe deps search installed
latest
repo   - list add remove
self- install uninstall version about
swank- start stop
vm - start stop threads stat uptime


Happy hacking
-
isaac
http://icylisper.in

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Summer of Code 2011

2011-03-07 Thread Meikel Brandmeyer
Hi,

Am 07.03.2011 um 17:08 schrieb Ken Wesson:

> Bzzzt, sorry. Their choice seems as arbitrary as any other, much of
> the time. Ask yourself this: if aliens from another planet are at
> about the same level of development as us, are they likely to be using
> the same or a closely similar notation? (Modulo different glyphs and
> words -- is the syntax going to be close?)

Probably not. Because the choice is not arbitrary. Mathematicians use formulae 
and not s-expressions, because they are easier to parse by the human brain. 
They use TeX, because the current computers are not powerful enough to provide 
easy means to exchange such formulae through the wire. It is a compromise to 
tell the computer about things. The aliens will probably use a system which 
fits to their brain (if they have one) and their way of thinking.

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


Are there sets that keep the insertion order?

2011-03-07 Thread Tassilo Horn
Hello all,

does clojure have sets that keep the insertion order, like Java's
LinkedHashSet?

Currently, I use lazy vectors in conjunction with `distinct', but that
seems to perform not too well.

Bye,
Tassilo

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


Re: A multiple-inheritance prototype system

2011-03-07 Thread icemaze
> It looks like you're trying to group together different functionality
> in one place. Idiomatic Clojure tends to encourage separating
> functionality out into independent components.

Thanks for the tip. My system doesn't provide validation, it just
differentiates between "nil" and "undefined but mandatory". It also
checks to see if there's a conflict betweeb inherited values, but this
is something any system with multiple inheritance must do.

Finally, it keeps track of objects' ancestors, so that I can see that
a :smartphone is-a :phone and is-a :pc, and so on.

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


Re: Summer of Code 2011

2011-03-07 Thread Ken Wesson
On Mon, Mar 7, 2011 at 8:40 AM, Chas Emerick  wrote:
>
> On Mar 6, 2011, at 11:53 AM, Ken Wesson wrote:
>
>> On Sun, Mar 6, 2011 at 11:00 AM, Chas Emerick  wrote:
>>> Rather than enumerate the places where sexprs are sub-optimal, it would 
>>> save a *lot* of time to simply point out that:
>>>
>>> (a) Every general-purpose programming language notation is a poor 
>>> substitute for the "native" notation of every domain
>>
>> Ah, but what, pray tell, *is* "the native notation" of a domain?
>
> Whatever the specialists in that domain say it is.

Bzzzt, sorry. Their choice seems as arbitrary as any other, much of
the time. Ask yourself this: if aliens from another planet are at
about the same level of development as us, are they likely to be using
the same or a closely similar notation? (Modulo different glyphs and
words -- is the syntax going to be close?)

>> And
>> why are you so sure it's almost never sexps? Sexps are a natural fit
>> to at least one other domain I can think of: mathematics. And if only
>> mathematicians used sexps it would be easy to generate things like
>> automated proof-vetters and the like using lisp. :)
>
> The fact that mathematicians appear to disagree (viz. Mathematica, MatLab, 
> fortress, etc) should be taken into account.

And yet they also use TeX, sometimes conversationally.

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


Re: A multiple-inheritance prototype system

2011-03-07 Thread James Reeves
On 7 March 2011 14:05, icemaze  wrote:
> 1) Was this necessary at all? Can my requirements be fulfilled with
> off-the-shelf clojure libraries or components? Requirements include
> the ability to merge objects as shown below.

It looks like you're trying to group together different functionality
in one place. Idiomatic Clojure tends to encourage separating
functionality out into independent components.

Your example indicates your defobject system is providing validation
and default values. You may be able to split this up into individual
functions. For example:

  (defn default [m k v]
(if (nil? (m k))
  (assoc m k v)
  m))

  (defn mobile-defaults [mobile]
(-> mobile
(default :warranty 3)
(default :on-contract? true)))

But without knowing more about your system it's hard to offer any more
specific advice.

- James

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Serialising functions...

2011-03-07 Thread Michael Wood
On 5 March 2011 18:02, Christopher Brown  wrote:
> Sorry for not explaining L2 in my original response.
> The tuple of  is not guaranteed to be unique either, but 
> we're approaching crazy-town with the probabilities.
> This tuple fails in a way analogous to the L2 MAC addr problem.

Yes, that's why I said it would get you "closer". :)

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


A multiple-inheritance prototype system

2011-03-07 Thread icemaze
Hi clojure developers!

I recently wrote an alternative datatype system for a project of mine,
because requirements were a little odd and I couldn't find anything
appropriate.

My questions are:
1) Was this necessary at all? Can my requirements be fulfilled with
off-the-shelf clojure libraries or components? Requirements include
the ability to merge objects as shown below.
2) Do you think this system would be useful to the clojure community?
Should I clean it up and publish it?

The best way to show how it works is with an example:

; This create a product "class". The "mandatory" function
; returns a special value which throws an
; exception when it's read.
; Sort of like a pure virtual method.
(defobject :product []
  :name (mandatory)
  :price (mandatory)
  :warranty (mandatory))

; PC's have 1 year of warranty by default in our shop
(defobject :pc [:product]
  :cpu (mandatory)
  :ram (mandatory)
  :warranty 1)

; Mobiles instead get 3
(defobject :mobile [:product]
  :battery-idle-time (mandatory)
  :warranty 3)

; This FAILS: the system tries to inherit the :warranty property
; from both parents but a conflict occurs (because the values are
different)
(defobject :smartphone [:pc :mobile])

; We must override the :warranty property. This works:
(defobject :smartphone [:pc :mobile]
  :warranty 2)

; Then we can create an "instance"...
(defobject :zamzun-universe [:smartphone]
  :cpu :z80
  :ram "1GB"
  :battery-idle-time "300h")

; ...and use it
(fetch (object :zamzun-universe) :warranty)
; -> 2

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


Re: Summer of Code 2011

2011-03-07 Thread Chas Emerick

On Mar 6, 2011, at 11:53 AM, Ken Wesson wrote:

> On Sun, Mar 6, 2011 at 11:00 AM, Chas Emerick  wrote:
>> Rather than enumerate the places where sexprs are sub-optimal, it would save 
>> a *lot* of time to simply point out that:
>> 
>> (a) Every general-purpose programming language notation is a poor substitute 
>> for the "native" notation of every domain
> 
> Ah, but what, pray tell, *is* "the native notation" of a domain?

Whatever the specialists in that domain say it is.

> And
> why are you so sure it's almost never sexps? Sexps are a natural fit
> to at least one other domain I can think of: mathematics. And if only
> mathematicians used sexps it would be easy to generate things like
> automated proof-vetters and the like using lisp. :)

The fact that mathematicians appear to disagree (viz. Mathematica, MatLab, 
fortress, etc) should be taken into account.

The concept of "natural fit" is inextricably bound up with all sorts of 
context: "natural" for who, working towards what purpose, collaborating with 
which colleagues, etc.  Being Clojure programmers, of course we would prefer 
that the entire world fit itself through our s-expression-shaped lens – things 
would be so much easier for us! – but I suspect the world may not find much 
value in that particular upside.  That assertion can easily be adapted as 
necessary for all programmers.

- Chas

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


Re: Clojure on JS VMs

2011-03-07 Thread James Sofra
This seems a little more up-to-date than clojurescript.

https://github.com/zkim/cljs

It is not complete (the author calls it clojure(ish)) but still seems
pretty nice.

-James S

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