Re: throw-if with no exception class

2008-12-11 Thread Ralf Bensmann
Just throwing "Exception" is discouraged in Java, because its the supertype
checked and unchecked exceptions. I often saw a JVM die of an unproper
exception handling -- mainly when NullPointerExceptions were involved. So we
are on the JVM, want Java interop and so my isistent recommendation is to
use RuntimeException.
-Ralf

On Thu, Dec 11, 2008 at 4:52 AM, Stephen C. Gilardi <[EMAIL PROTECTED]>wrote:

>
> On Dec 10, 2008, at 4:38 AM, Ralf Bensmann wrote:
>
> Being a Java trainer for a long time, we talk with students about the
> "handle-or-declare rule" in Java and the two types of exceptions: "checked"
> (declared) and "unchecked" (runtime). So I prefer using a RuntimeException
> because no exception was specified.
>
>
> I'm inclined to accept the recommendation to make RuntimeException the
> default. I see that Clojure's Java source code uses both. It seems to me
> that within Clojure, the distinction doesn't matter, but in the case of Java
> interop, RuntimeExceptions would be more in keeping with what Clojure's
> "never declare them" philosophy.
>
> Does anyone have any more advice on this?
>
> --Steve
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure Code Analysis Tools

2008-12-11 Thread [EMAIL PROTECTED]

On Dec 2, 4:52 pm, Peter Wolf <[EMAIL PROTECTED]> wrote:
>
> I vote that we take Merlyn's code as a base and put it on SourceForge.  
> I'll add my Lexer and Parser and work on formatting, parens matching and
> coloring.  Erik can add his REPL and completion stuff.
>
> However, I think it would be polite to wait 24 hours for Merlyn to give
> his/her OK before I do this.
>
Any further word on this? Realistically the only way I'll be able to
use clojure in anger (ie. at work) is if I can bring all the Intellij
goodness to bear on it :) Coding without automated refactoring support
and instant code navigation now feels like chopping down trees with a
spoon.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Apache Tapestry Creator to Speak on Clojure, Tapestry 5

2008-12-11 Thread Shaguf

Apache Tapestry Creator to Speak on Clojure, Tapestry 5

Bangalore, December 10, 2008: If you are a Java developer building web-
based applications and tired of the countless frameworks that promise
you a slick UI fast but fail to live up to their promise, then switch
to Apache Tapestry to get more functionality with less code. The
creator of Tapestry, Howard Lewis Ship, is coming this summer to
India's biggest summit for the developer ecosystem - Great Indian
Developer Summit (http://www.developersummit.com/) to speak on the
recently released Tapestry 5.0 version, covering the core IoC
container, how to define and inject services and advanced topics such
as decorating services to provide additional concerns, or creating
services in terms of design patterns such as chain-of-command and
pipeline.

On April 25, the author of 'Tapestry in Action' will also conduct a 3-
hour, hands on workshop on  building your own Tapestry applications.
Hew will cover what it means to be a component web framework, what
advantages that brings, how to create database-driven web applications
using Hibernate, show off Tapestry's live class reloading, advanced
error reporting and other productivity features, how Tapestry can be
tuned and customized and build new components.

A frequent speaker at JavaOne, NoFluffJustStuff, ApacheCon Howard will
also throw the spotlight on Clojure -- made up of one part Lisp (one
of the oldest computer languages), one part Java (so young, yet so
well adopted), a healthy serving of functional programming, and a
state-of-the-art concurrency layer on top. Clojure embraces functional
programming with immutable data types and first class functions. It is
fully interoperable with Java. Clojure's approach to concurrency
includes asynchonous Agents, and Software Transactional Memory.

About Great Indian Developer Summit

Great Indian Developer Summit, produced by Saltmarch Media, is the
biggest gathering of software developers from Java/J2EE, Microsoft
computing technologies, Rich Internet Applications (RIA), Web 2.0,
Ajax, Agile, SOA, and Enterprise IT. For both veterans and newcomers
to the world of .NET, Java, and the Rich Web, the Great Indian
Developer Summit provides participants with a well-balanced learning
experience that guaranteed they went back with a richer understanding
of the technologies that make a difference to their careers. See the
GIDS 2008 Red Stripe Report: 
http://www.developersummit.com/2008/report/pdf/Red_Stripe_Report-GIDS08.zip

Over 3000 qualified and talented delegates - Source, attended GIDS
2008: The Hindu - Monday, 26 May 2008 (http://www.developersummit.com/
2008/report/postPress.html). With outstanding educational sessions,
powerhouse speakers, a high-profile award ceremony, GIDS 2009 will
feature premium knowledge, action plans and advise from been-there-
done-it veterans, creators, and visionaries.

For further information on GIDS 2009, please visit the summit on the
web http://www.developersummit.com/.

A Saltmarch Media Press Release
E: [EMAIL PROTECTED]
Ph: +91 080 4005 1000

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Learning Clojure

2008-12-11 Thread Alex Burka

To the debate on whether there should be examples early in the text,  
here are my two cents:

When I click on something called "Learning [programming language]" I  
like to see a representative example of the syntax early on. If  
there's just text as far as the eye can see (that is, the first  
screen) it is off-putting for some reason. After all, it is a  
programming language.

Alex

On Dec 11, 2008, at 12:55 AM, Timothy Pratley wrote:

>
> Hi Brian,
>
>
>> Rich talks about destructuring in the part about "let" on the  
>> "special
>> forms" page.
>
> Ah indeed, thanks for pointing that out :)
>
>
>> If you have any examples to add, please add them yourself (it is a  
>> wiki
>> page).
>
> You've given some really good reasons why I shouldn't mess with it
> *chuckle* so I'm getting mixed messages. If you do want me to add
> example link, I'm happy to do that but for now I'm assuming you'd
> prefer it left as is :)
>
>
>> Thanks for your feedback.
>
> You are most welcome.
>
>
> Regards,
> Tim.
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



The return of the monads: lessons learned about macros

2008-12-11 Thread Konrad Hinsen

A while ago I uploaded an implementation of monads in Clojure to the
group's file section. I have now replaced it by a more or less complete
rewrite. This rewrite was motivated by one serious problem with the
original implementation, plus a number of minor points that I was not
happy with. I have also integrated some ideas from Jim's alternative monad
implementation. The new implementation has replaced the original one at

http://clojure.googlegroups.com/web/monads.clj

In my original implementation, I had used keywords for the monad
operations. These keywords were replaced by their definitions inside a
given monad using a recursive symbol replacement in the form to be
evaluated. This approach has a major problem: it doesn't combine correctly
with macros. If a macro expands into a form containing monad operation
keywords, they are not replaced at all, because my symbol replacement code
sees only the original form.

The new implementation uses plain functions for the monad operations. The
with-monad form
expands into a straightforward let form that binds the operations to their
names. Generic monad operations such as lift are implemented as functions
that take the four basic monad definitions as additional parameters. These
functions are wrapped by macros that add these parameters to the argument
list. In the new implementation, all form manipulation is done by macros,
and there is much less of it: it no longer has a fundamental role, but
just provides nicer syntax.

To pursue my original idea of a replacement-based implementation, one
would need something like Common Lisp's symbol-macrolet, which is however
not trivial to implement. It requires either an integration with the
compiler's macro expansion mechanism, or a separate implementation of full
macro expansion, including subforms, of an arbitrary form.

With the new monad implementation, client modules can:
- define new monads (monad and defmonad)
- define new generic monad operations (defmonadfn)
- execute code using a monad (with-monad)
- define functions that internally use a specific monad (define the
function inside a with-monad block)
- use monad comprehension syntax (domonad)

Some minor changes:
- All monad operations have names starting with m-.
- There is a single m-lift that takes its arity as an argument.
- m-plus takes an arbitrary number of arguments and respects lazy evaluation.

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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: throw-if with no exception class

2008-12-11 Thread Rich Hickey



On Dec 10, 10:52 pm, "Stephen C. Gilardi" <[EMAIL PROTECTED]> wrote:
> On Dec 10, 2008, at 4:38 AM, Ralf Bensmann wrote:
>
> > Being a Java trainer for a long time, we talk with students about
> > the "handle-or-declare rule" in Java and the two types of
> > exceptions: "checked" (declared) and "unchecked" (runtime). So I
> > prefer using a RuntimeException because no exception was specified.
>
> I'm inclined to accept the recommendation to make RuntimeException the
> default. I see that Clojure's Java source code uses both. It seems to
> me that within Clojure, the distinction doesn't matter, but in the
> case of Java interop, RuntimeExceptions would be more in keeping with
> what Clojure's "never declare them" philosophy.
>
> Does anyone have any more advice on this?
>

Clojure doesn't have 'checked' exceptions. They are a bad idea, and a
misfeature of Java, bad enough with interfaces but completely
incompatible with closures. As a result of the flawed logic that has
grown up around this misfeature, in Java you might choose between
checked and non-checked based on whether you thought a caller could do
anything about it - if not, use unchecked, thus making your method one
that didn't require explicit handling.

Given that there are no 'checked' exceptions in Clojure, the
distinction is moot, except in the case of Java interop, where, at
least through the IFn interface, all Clojure calls declare Exception.
RuntimeException is a particularly dubious notion, a special exemption
granted to those exceptions the Java runtime might throw, created in
acknowledgment of the insufferable pain it would cause to use the
checked exception system for those. If it were a fixed set it would be
one thing - every caller could expect one of those (enumerated,
documented) exceptions, or a declared one. But RuntimeExceptions are
an open set - it's just plain goofy.

Clojure's Java code throws explicit RuntimeExceptions only in those
places where the checked exception system precludes it from letting an
Exception flow out, and it pains me every time.

I guess my recommendation is, if there is an existing exception type
(checked or unchecked) that roughly matches your problem, throw that,
else throw Exception. In this case, perhaps the default should be
IllegalArgumentException.

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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Dr. Dobbs: "It's Time to Get Good at Functional Programming"

2008-12-11 Thread Michael Wood

On Wed, Dec 10, 2008 at 11:28 PM, Randall R Schulz <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I just found this article on Dr. Dobbs' Web site. It's dated Dec 3rd of
> this year:
>
> - "It's Time to Get Good at Functional Programming"
>  Subtitle: "Is it Finally Functional Programming's Turn?"
>  
>
> Headings:
>
> - "FP: What It Is"
> - "Scala: A Hybrid Language"
> - "F#: A Functional Language for .NET"
> - "Erlang: A No-Compromises Approach"
> - "Haskell: A Foundation for Research"
> - Sidebar: "Functional Programming in Mathematica"
>
> There seems to be a bit of an oversight. Perhaps one of the authors
> among us should contact the author of that article, Michael Swaine?

I read the article a couple of days ago and I mailed Michael Swaine to
ask if he knew of Clojure.  DDJ's contact page lists his e-mail
address correctly, but the mailto link, if you click on it, is
incorrect.

He has not responded.

-- 
Michael Wood <[EMAIL PROTECTED]>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Learning Clojure

2008-12-11 Thread janus

 Timothy,
Your post is a great one indeed , you have developed a template that
anyone could use to introduce Clojure. I would implore to fresh out
thoughts and deepen it for all to enjoy.

Emeka


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: why can't I set! stuff in user.clj?

2008-12-11 Thread Stuart Halloway

+1. I would love to see a one-file story.

Stu

> On Dec 10, 2008, at 1:50 PM, Stephen C. Gilardi wrote:
>
>> - I think init.clj and repl-init.clj would be good additions to  
>> what we have now. I'll be happy to write the code if it's welcome.
>
> Alternatively, we could make those hooks be functions that one can  
> (optionally) define in user.clj. The platform entry point would call  
> them if they exist:
>
>   (ns user)
>
>   (defn init
> []
> (set! *compile-path* "my/compiled/clojure"))
>
>   (defn repl-init
> []
> (set! *print-length* 100)
> (set! *print-level* 10)
> (println "Hiya, pal!"))
>
> I like that because it would make for a unified story and single  
> file to worry about for all these initializations.
>
> --Steve
>


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Clojure Code Analysis Tools

2008-12-11 Thread Peter Wolf

Hi Darren,

Work continues.  Merlyn has invited me to take over admin of the code.  
I have taken Merlyn's code as a base, and am fleshing it out.

Currently, I am struggling though the lack of documentation and examples 
for building a custom language plugin.  I have implemented a Lexer, and 
am debugging Brace Matching.  BTW, Rich, I stole the Lexer from the 
Clojure source.  I hope that's OK.

Once I get Brace Matching going, I was going to check it in, and invite 
others to join in the hacking.

Please email me at [EMAIL PROTECTED] if you want to help with the 
IntelliJ plugin.

Peter


[EMAIL PROTECTED] wrote:
> On Dec 2, 4:52 pm, Peter Wolf <[EMAIL PROTECTED]> wrote:
>   
>> I vote that we take Merlyn's code as a base and put it on SourceForge.  
>> I'll add my Lexer and Parser and work on formatting, parens matching and
>> coloring.  Erik can add his REPL and completion stuff.
>>
>> However, I think it would be polite to wait 24 hours for Merlyn to give
>> his/her OK before I do this.
>>
>> 
> Any further word on this? Realistically the only way I'll be able to
> use clojure in anger (ie. at work) is if I can bring all the Intellij
> goodness to bear on it :) Coding without automated refactoring support
> and instant code navigation now feels like chopping down trees with a
> spoon.
> >
>
>   


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



frequency of each unique item in collection

2008-12-11 Thread bOR_

Hi all,

I thought I remembered there was a method in the api somewhere that
would count the frequency of each unique item in a collection, but I
can't find it anymore. What would be a brief way to write that in
clojure?

(In ruby: array.inject(Hash.new(0)) {|hash,key| hash[key] += 1 ;
hash})


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: In core structure editor, anyone?

2008-12-11 Thread evins.mi...@gmail.com



On Dec 10, 2:59 pm, falcon <[EMAIL PROTECTED]> wrote:
> Could you describe in-core editing a bit more?  Sounds interesting.

The canonical structure editor (not "structured editor") is probably
Interlisp-D's SEDIT, or its predecessor DEDIT. (See
http://bitsavers.org/pdf/xerox/interlisp/3102300_interlDprimer_Nov86.pdf
for an archive of Interlisp docs, including docs on SEDIT.) Interlisp
was for a while one of a couple major dialects of Lisp, along with
MACLISP, that were perhaps the most widely used dialects. There were
lots of dialects of lisp in fairly wide use; Common Lisp was intended
to merge the most common idioms in use across a lot of dialects
without losing *too* much of the facilities of any one popular
dialect, but Common Lisp might perhaps resemble MACLISP a little more
than it resembles Interlisp.

Interlisp was the system programming language for the Xerox D-machine
series.

A structure editor, as exemplified by SEDIT, does not operate on text
in a file buffer; instead, it operates on the lisp data structures
represented by the text. When you edit lisp code in emacs, even with a
utility like Paredit, which helps you with the syntactic structure,
you are operating on text characters stored in some sort of array.
There is a connection between the text and what the lisp reader
produces in memory, but you operate on the text, not on the in-memory
lisp objects that are represented by the text.

Structure editors are different: they operate on the in-memory data
structures.

Consider a lisp (or Clojure) list, (a b). This list is a chain of cons
cells, where a cons cell is a pair of pointers. The left pointer
points to the symbol 'a'; the right one points to a second cons cell.
In the second cons cell, the left pointer points to the symbol 'b' and
the right one points to nil.

Now consider the text "(a b)", as seen by some editor. It's a row of
character values: '(', 'a', ' ', 'b', ')'.

The lisp (or Clojure) reader converts that row of characters into the
chain of cons cells described above; the printer converts the chain of
cons cells into the row of characters. There is necessarily a close
correspondence between the text and the in-memory objects, but they
are not the same thing.

Text editors edit text. Structure editors edit the in-memory data
structures.

This might be a good place to repeat that in lisp, and perhaps in
Clojure, I'm not sure, the code is not the text; it's the in-memory
objects. This differs from most  programming languages. In most
languages, when you say "source code," you mean text. Strictly
speaking, the text in a ".lisp" text file is not the source code for a
lisp program; it is a text description of lisp source code; the actual
source code is constructed by the lisp reader when it reads the file.
Indeed, given the syntactic rules of Common Lisp, it's possible to
have two very different text files that contain (text specifications
for) exactly the same source code.

Most of the time, this distinction is pretty much academic, because of
the close and necessary correspondence between lisp source code and
its textual representation. There are a few places where the
difference is noticeable, though, and some of them illustrate how a
structure editor differs from a text editor.

For example, consider a circular list: suppose we used RPLACD to make
the nil at the end of (a b) point at the first cons cell, the one
whose left side points to the symbol 'a'. If that value is returned at
the repl (and *print-circle* is not configured to inhibit it) then the
printer will be stuck in an infinite loop printing (a b a b a b a
b

Now, of course, the circular data structure is not infinite, it's just
circular; it points to itself. But the textual representation is a
little inconvenient for printing such a structure, and indeed, it's
inconvenient for constructing it in the first place (the Common Lisp
reader and printer have a sort of a hack specified in them for these
purposes).

It's quite a bit more convenient to work with such a data structure in
a structure editor, which makes it clear that there isn't really
anything weird or magical about the circular list. It just has an
arrow in the rightmost box of the chain that points to the leftmost
box. No big deal.

Structure editors are not in common use, maybe because, while they're
a valid and maybe cool alternative to text editors for lisp code, it's
not clear how useful they are for other kinds of code. In most
programming languages a lexer and parser construct an abstract syntax
tree from the source code. In lisp, the abstract syntax tree *is* the
source code. That being the case, it makes a lot of sense with lisp to
operate directly on the parse tree. In other languages, not so much.

Some folks love structure editors. I never really used one, but my old
friend and longtime lisp hacker Philip McBride really likes them. I'd
be very glad to see one for Clojure just because it would be fun to
have the option to play around with the

Re: Is it possible to tell programatically if I'm in a transactional context?

2008-12-11 Thread Rich Hickey



On Dec 8, 7:44 pm, Dave Griffith <[EMAIL PROTECTED]> wrote:
> The basic use case is as a guard for I/O, to prevent them from from
> filling the disk/spamming the network accidentally in case of
> transaction live-lock.  Probably a bit more paranoia than is idiomatic
> in the dynamically-typed world, but there are domains where that's
> necessary.  The workaround is perfectly fine, although it looks like
> exposing a method in LockingTransaction would be more performant.
>

I've added io! blocks, which will throw an exception when run in a
transaction:

(dosync (io! 42))
-> java.lang.IllegalStateException: I/O in transaction (NO_SOURCE_FILE:
0)

They take an optional string which will serve as the exception text:

(dosync (io! "bad" 42))
-> java.lang.IllegalStateException: bad (NO_SOURCE_FILE:0)

await and await-for now contain io! blocks.

Rich


>
> On Dec 8, 6:07 pm, Stuart Halloway <[EMAIL PROTECTED]> wrote:
>
> > Hi Dave,
>
> > It looks like LockingTransaction.getRunning would need to be made
> > public. What do you plan to do with it?
>
> > As a workaround:
>
> >   (defn in-tx? [] (try (ensure (ref true)) (catch
> > IllegalStateException e false)))
>
> > Stuart
>
> > > I gave a small talk on Clojure this afternoon to my team.  It went
> > > well, and got the expected oohs and ahhs with respect to the potential
> > > of software transactional memory.  One question asked, though, was
> > > about I/O in softwaretransactions.  It was clear to everyone why I/O
> > > needed to be prohibitted intransactions, but questions were raised as
> > > to whether there was any way to actually prevent it.  Looking through
> > > the API, I couldn't find any way of detecting when execution was
> > > occuring in a transactional context or not.
>
> > > --Dave Griffith
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: frequency of each unique item in collection

2008-12-11 Thread Dave Griffith


(defn frequencies [coll]
  (reduce  (fn [map val] (assoc map val (if (contains map val)
(get map val) 1))  #{})
)

On Dec 11, 9:21 am, bOR_ <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I thought I remembered there was a method in the api somewhere that
> would count the frequency of each unique item in a collection, but I
> can't find it anymore. What would be a brief way to write that in
> clojure?
>
> (In ruby: array.inject(Hash.new(0)) {|hash,key| hash[key] += 1 ;
> hash})
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: frequency of each unique item in collection

2008-12-11 Thread Mark McGranaghan

I don't recall a histogram-like method, though I may just be forgetting.

(defn frequencies [coll]
  (reduce
(fn [map val] (assoc map val (inc (get map val 1
{}
coll))


On Thu, Dec 11, 2008 at 9:33 AM, Dave Griffith
<[EMAIL PROTECTED]> wrote:
>
>
> (defn frequencies [coll]
>  (reduce  (fn [map val] (assoc map val (if (contains map val)
> (get map val) 1))  #{})
> )
>
> On Dec 11, 9:21 am, bOR_ <[EMAIL PROTECTED]> wrote:
>> Hi all,
>>
>> I thought I remembered there was a method in the api somewhere that
>> would count the frequency of each unique item in a collection, but I
>> can't find it anymore. What would be a brief way to write that in
>> clojure?
>>
>> (In ruby: array.inject(Hash.new(0)) {|hash,key| hash[key] += 1 ;
>> hash})
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: In core structure editor, anyone?

2008-12-11 Thread Stuart Sierra

On Dec 11, 9:32 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I don't know whether Rich regards the text of a Clojure program as the
> source, or whether he thinks of the source as the data structure
> created by the reader when it reads the text. In Common Lisp and some
> older dialects, it's pretty clear that the latter is the case.

I think Clojure, by avoiding reader macros and reader side-effects,
actually comes closer to the code-is-data ideal than Common Lisp
does.  It might not lure me away from Emacs, but it would be
interesting to see an editor that goes all the way and abandons text
sources altogether.

-Stuart Sierra
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Is it possible to tell programatically if I'm in a transactional context?

2008-12-11 Thread Dave Griffith

Excellent! This is a great way of making code fail-fast for a class of
bugs that would normally only occur under load (i.e. at the worst
possible time).

--Dave Griffith

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: frequency of each unique item in collection

2008-12-11 Thread Randall R Schulz

On Thursday 11 December 2008 06:33, Dave Griffith wrote:
> On Dec 11, 9:21 am, bOR_ <[EMAIL PROTECTED]> wrote:
> > Hi all,
> >
> > I thought I remembered there was a method in the api somewhere that
> > would count the frequency of each unique item in a collection, but
> > I can't find it anymore. What would be a brief way to write that in
> > clojure?
> >
> > (In ruby: array.inject(Hash.new(0)) {|hash,key| hash[key] += 1 ;
> > hash})
>
> (defn frequencies [coll]
>  (reduce  (fn [map val] (assoc map val (if (contains map val) (get map val) 
> 1))  #{})
> )

Shooting from the hip, eh? There is no "contains", it's "contains?".
There's a missing close parenthesis. I don't see where this is doing any
counting. How does it compute occurrence frequencies?


Randall Schulz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: frequency of each unique item in collection

2008-12-11 Thread Stuart Sierra

On Dec 11, 9:21 am, bOR_ <[EMAIL PROTECTED]> wrote:
> I thought I remembered there was a method in the api somewhere that
> would count the frequency of each unique item in a collection, but I
> can't find it anymore. What would be a brief way to write that in
> clojure?

I think what you want is:

(defn frequencies [coll]
  (reduce
   (fn [counts x]
 (assoc counts x
(if-let [c (counts x)] (inc c) 1)))
   {} coll))

user=> (frequencies [:a :a :b :a :b])
{:b 2, :a 3}

-Stuart Sierra
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: frequency of each unique item in collection

2008-12-11 Thread Dave Griffith

Yup, five bugs by my count.  Not bad for a one-liner. More coffee
necessary.

Same algorithm, but tested.

 (defn frequencies [coll]
(reduce  (fn [map val] (assoc map val (if (contains? map val) (+ 1
(get map val)) 1)))  {} coll)
 )

On Dec 11, 9:52 am, Randall R Schulz <[EMAIL PROTECTED]> wrote:
> On Thursday 11 December 2008 06:33, Dave Griffith wrote:
>
> > On Dec 11, 9:21 am, bOR_ <[EMAIL PROTECTED]> wrote:
> > > Hi all,
>
> > > I thought I remembered there was a method in the api somewhere that
> > > would count the frequency of each unique item in a collection, but
> > > I can't find it anymore. What would be a brief way to write that in
> > > clojure?
>
> > > (In ruby: array.inject(Hash.new(0)) {|hash,key| hash[key] += 1 ;
> > > hash})
>
> > (defn frequencies [coll]
> >  (reduce  (fn [map val] (assoc map val (if (contains map val) (get map val) 
> > 1))  #{})
> > )
>
> Shooting from the hip, eh? There is no "contains", it's "contains?".
> There's a missing close parenthesis. I don't see where this is doing any
> counting. How does it compute occurrence frequencies?
>
> Randall Schulz
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: frequency of each unique item in collection

2008-12-11 Thread Stuart Sierra

I've added a slightly modified version to clojure.contrib.seq-utils:

(defn frequencies
  "Returns a map from distinct items in coll to the number of times
  they appear."
  [coll]
  (reduce (fn [counts x]
  (assoc counts x (inc (get counts x 0
  {} coll))

-Stuart Sierra


On Dec 11, 10:07 am, Dave Griffith <[EMAIL PROTECTED]> wrote:
> Yup, five bugs by my count.  Not bad for a one-liner. More coffee
> necessary.
>
> Same algorithm, but tested.
>
>  (defn frequencies [coll]
>     (reduce  (fn [map val] (assoc map val (if (contains? map val) (+ 1
> (get map val)) 1)))  {} coll)
>  )
>
> On Dec 11, 9:52 am, Randall R Schulz <[EMAIL PROTECTED]> wrote:
>
> > On Thursday 11 December 2008 06:33, Dave Griffith wrote:
>
> > > On Dec 11, 9:21 am, bOR_ <[EMAIL PROTECTED]> wrote:
> > > > Hi all,
>
> > > > I thought I remembered there was a method in the api somewhere that
> > > > would count the frequency of each unique item in a collection, but
> > > > I can't find it anymore. What would be a brief way to write that in
> > > > clojure?
>
> > > > (In ruby: array.inject(Hash.new(0)) {|hash,key| hash[key] += 1 ;
> > > > hash})
>
> > > (defn frequencies [coll]
> > >  (reduce  (fn [map val] (assoc map val (if (contains map val) (get map 
> > > val) 1))  #{})
> > > )
>
> > Shooting from the hip, eh? There is no "contains", it's "contains?".
> > There's a missing close parenthesis. I don't see where this is doing any
> > counting. How does it compute occurrence frequencies?
>
> > Randall Schulz
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Learning Clojure

2008-12-11 Thread samppi

Great article, but I'm not sure this part in the keyword section is
correct:

"Keywords exist simply because, as you'll see, it's useful to have
names in code which are symbol-like but not actually symbols. Keywords
have no concept of being namespace qualified as they have nothing to
do with namespaces."

Isn't it possible to qualify keywords like :clojure/tag?

On Dec 11, 6:58 am, janus <[EMAIL PROTECTED]> wrote:
>  Timothy,
> Your post is a great one indeed , you have developed a template that
> anyone could use to introduce Clojure. I would implore to fresh out
> thoughts and deepen it for all to enjoy.
>
> Emeka
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Learning Clojure

2008-12-11 Thread Randall R Schulz

On Thursday 11 December 2008 07:41, samppi wrote:
> Great article, but I'm not sure this part in the keyword section is
> correct:
>
> "Keywords exist simply because, as you'll see, it's useful to have
> names in code which are symbol-like but not actually symbols.
> Keywords have no concept of being namespace qualified as they have
> nothing to do with namespaces."
>
> Isn't it possible to qualify keywords like :clojure/tag?

It is.

Furthermore, keywords have the fascinating property of being functions 
over maps, effecting look-up of their entry, if any, in the map to 
which they're applied. Symmetrically, and more conventionally, maps are 
functions of keywords.

Both cute _and_ clever. And functional.


Randall Schulz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: The return of the monads: lessons learned about macros

2008-12-11 Thread jim

Konrad,

I haven't had a chance to look at this in depth but I did see two
things.

First, the function 'group' that you define seems to be the same as
Clojure's 'partition' function.

Second, when I tried to load monads, I get the following error.

java.lang.ExceptionInInitializerError (monads.clj:
165)
Caused by: java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException:
java.lang.ClassNotFoundException: user$m_PLUS_m_seq_PLUS_m__252
at clojure.lang.RT.readString(RT.java:1163)
at user$m_PLUS_m_map_PLUS_m__272.(monads.clj:165)
... 26 more
Caused by: java.lang.ClassNotFoundException: user
$m_PLUS_m_seq_PLUS_m__252

(I snipped out some of the call stack.)

Looking forward to digging into this later.

Jim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: In core structure editor, anyone?

2008-12-11 Thread falcon

Can't say I understood all of it (being a LISP noob) but appreciate
the explanation.

Does the following fit into the current discussion?

Barista editor: http://faculty.washington.edu/ajko/barista.shtml

Barista editor is based on Citrus 
http://faculty.washington.edu/ajko/citrus.shtml

The citrus page has some _VERY_ cool videos.  They are worth watching,
just for entertainment value (entertainment for developers only
though).



On Dec 11, 9:32 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> On Dec 10, 2:59 pm, falcon <[EMAIL PROTECTED]> wrote:
>
> > Could you describe in-core editing a bit more?  Sounds interesting.
>
> The canonical structure editor (not "structured editor") is probably
> Interlisp-D's SEDIT, or its predecessor DEDIT. 
> (Seehttp://bitsavers.org/pdf/xerox/interlisp/3102300_interlDprimer_Nov86.pdf
> for an archive of Interlisp docs, including docs on SEDIT.) Interlisp
> was for a while one of a couple major dialects of Lisp, along with
> MACLISP, that were perhaps the most widely used dialects. There were
> lots of dialects of lisp in fairly wide use; Common Lisp was intended
> to merge the most common idioms in use across a lot of dialects
> without losing *too* much of the facilities of any one popular
> dialect, but Common Lisp might perhaps resemble MACLISP a little more
> than it resembles Interlisp.
>
> Interlisp was the system programming language for the Xerox D-machine
> series.
>
> A structure editor, as exemplified by SEDIT, does not operate on text
> in a file buffer; instead, it operates on the lisp data structures
> represented by the text. When you edit lisp code in emacs, even with a
> utility like Paredit, which helps you with the syntactic structure,
> you are operating on text characters stored in some sort of array.
> There is a connection between the text and what the lisp reader
> produces in memory, but you operate on the text, not on the in-memory
> lisp objects that are represented by the text.
>
> Structure editors are different: they operate on the in-memory data
> structures.
>
> Consider a lisp (or Clojure) list, (a b). This list is a chain of cons
> cells, where a cons cell is a pair of pointers. The left pointer
> points to the symbol 'a'; the right one points to a second cons cell.
> In the second cons cell, the left pointer points to the symbol 'b' and
> the right one points to nil.
>
> Now consider the text "(a b)", as seen by some editor. It's a row of
> character values: '(', 'a', ' ', 'b', ')'.
>
> The lisp (or Clojure) reader converts that row of characters into the
> chain of cons cells described above; the printer converts the chain of
> cons cells into the row of characters. There is necessarily a close
> correspondence between the text and the in-memory objects, but they
> are not the same thing.
>
> Text editors edit text. Structure editors edit the in-memory data
> structures.
>
> This might be a good place to repeat that in lisp, and perhaps in
> Clojure, I'm not sure, the code is not the text; it's the in-memory
> objects. This differs from most  programming languages. In most
> languages, when you say "source code," you mean text. Strictly
> speaking, the text in a ".lisp" text file is not the source code for a
> lisp program; it is a text description of lisp source code; the actual
> source code is constructed by the lisp reader when it reads the file.
> Indeed, given the syntactic rules of Common Lisp, it's possible to
> have two very different text files that contain (text specifications
> for) exactly the same source code.
>
> Most of the time, this distinction is pretty much academic, because of
> the close and necessary correspondence between lisp source code and
> its textual representation. There are a few places where the
> difference is noticeable, though, and some of them illustrate how a
> structure editor differs from a text editor.
>
> For example, consider a circular list: suppose we used RPLACD to make
> the nil at the end of (a b) point at the first cons cell, the one
> whose left side points to the symbol 'a'. If that value is returned at
> the repl (and *print-circle* is not configured to inhibit it) then the
> printer will be stuck in an infinite loop printing (a b a b a b a
> b
>
> Now, of course, the circular data structure is not infinite, it's just
> circular; it points to itself. But the textual representation is a
> little inconvenient for printing such a structure, and indeed, it's
> inconvenient for constructing it in the first place (the Common Lisp
> reader and printer have a sort of a hack specified in them for these
> purposes).
>
> It's quite a bit more convenient to work with such a data structure in
> a structure editor, which makes it clear that there isn't really
> anything weird or magical about the circular list. It just has an
> arrow in the rightmost box of the chain that points to the leftmost
> box. No big deal.
>
> Structure editors are not in common use, maybe because, while they're
> 

Re: The return of the monads: lessons learned about macros

2008-12-11 Thread Konrad Hinsen

Jim,

thanks for your comments!

> First, the function 'group' that you define seems to be the same as
> Clojure's 'partition' function.

Indeed. I have spent some time checking if something like this exists  
already, but I didn't consider "partition" as a name!

> Second, when I tried to load monads, I get the following error.
>
> java.lang.ExceptionInInitializerError (monads.clj:
> 165)
> Caused by: java.lang.ExceptionInInitializerError
> Caused by: java.lang.RuntimeException:
> java.lang.ClassNotFoundException: user$m_PLUS_m_seq_PLUS_m__252
> at clojure.lang.RT.readString(RT.java:1163)
> at user$m_PLUS_m_map_PLUS_m__272.(monads.clj:165)
> ... 26 more
> Caused by: java.lang.ClassNotFoundException: user
> $m_PLUS_m_seq_PLUS_m__252

The definition of m-map makes use of m-seq, which is a macro that  
expands into a call to the function m+m-seq+m. It seems that this  
function doesn't exist on your system. It should have been created by  
the (defmonadfn m-seq...) just before.

On my system this works fine, but since I use a pretty old Clojure  
version (the 20080916 release), it is possible that something  
important has changed since. Unfortunately I can't easily test with  
more recent SVN versions as I live behind a firewall that doesn't let  
the SVN protocol pass.

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
To unsubscribe from 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: Learning Clojure

2008-12-11 Thread Brian Will

Tim, just go ahead and make any changes you like. If I don't like
them, I can always revert ;) Actually, I'm sure anything you add we
can find a place for, but like I said, that would likely be a separate
example page in most cases.

Thanks, Randall, I mention keywords-as-functions where I talk about
collection functions, but I forgot maps-as-functions.

Perhaps future discussion of the text should move to the talk page on
the wiki. This thread's getting pretty long.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: memory issue with nth

2008-12-11 Thread Paul Mooser

I think this might just be a JVM version issue. I can reproduce this
issue with a 1.5 JVM, but I can't reproduce it with 1.6.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Patch: precompiling Clojure core sources in Ant build script

2008-12-11 Thread MattyDub

Well, I had the .clj files in my clojure.jar, and clojure.jar is on
slime-search-paths, but I still wasn't getting M-. to work with
clojure's functions and macros.  I added the source files to my
classpath, and I get them now.
   Also, I updated clojure and swank-clojure this morning, so it looks
like the latest and greatest are playing well with each other.
   Thanks for the help, Bill.
-Matt


On Dec 10, 9:04 pm, "Bill Clementson"  wrote:
> Hi Matt,
>
> FYI - Jeffrey Chu just sent me an email and the patch has now been
> applied to swank-clojure.
>
> - Bill
>
> On Wed, Dec 10, 2008 at 1:09 PM, Bill Clementson  wrote:
> > Hi Matt,
>
> > On Wed, Dec 10, 2008 at 12:47 PM, MattyDub  wrote:
>
> >> I can confirm that that patch fixed my problem - I can now M-. to
> >> render-place.  Thanks, Bill!
>
> > Good to hear that the patch fixes the issue for you.
>
> >>   What paths does slime-edit-definition search for the definitions?
> >> It's not finding the clojure macros/functions (like defn, dosync,
> >> etc.), so I must not have that path configured correctly.
> >> -Matt
>
> > Basically, it searches a bunch of standard Java locations plus the
> > locations you specified in your classpath. If you want to see what
> > will be searched, enter the following 2 statements in your Clojure
> > REPL:
> > (in-ns 'swank.commands.basic)
> > (slime-search-paths)
>
> > Note: the function "slime-search-paths" isn't public
>
> > If M-. isn't working on standard Clojure symbols, it could be for a
> > number of reasons:
> > 1. You're using an old version of Clojure
> > 2. You've built Clojure excluding source from the jar file
> > 3. The Clojure source isn't in your classpath (only necessary if #2 is true)
>
> > - Bill
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: jEdit Mode for Clojure

2008-12-11 Thread Daniel Spiewak

It's been too long since I've looked at this thread...

I took a look at the mode you linked.  My mode is quite a bit more
powerful, particularly with the changes I added today.  The linked
mode does do some highlighting of special forms like @[...] that mine
doesn't do yet, mainly because I didn't know about them.  Also, the
linked mode seems to be a bit inconsistent about which keyword levels
are used for what forms.  Finally, the linked mode has very limited
support for comments (highlighting only).  Using my mode, C+e C+c and C
+e C+k both work as expected, inserting ; and (comment ... ) as
necessary.

Daniel

On Nov 23, 7:31 am, Patrick Wright  wrote:
> FYI, another developer has been working on an edit mode for clojure.
> You can download it 
> fromhttp://sourceforge.net/tracker/?func=detail&atid=300588&aid=2201893&g...
>
> See also this 
> threadhttp://www.nabble.com/Edit-mode-for-Clojure-ts20168077.html#a20168077
>
> Note that the version in thejEdittracker appears to be newer than
> the one posted on the mailing list thread.
>
> I haven't tried comparing them yet, but at some point I guess we
> should pull them together into one.
>
> Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: jEdit Mode for Clojure

2008-12-11 Thread Daniel Spiewak

Oh, also I should mention that I found the magic incantation to make
auto-indentation work perfectly.  It handles multiple unindents just
fine now.

Daniel

On Dec 11, 12:34 pm, Daniel Spiewak  wrote:
> It's been too long since I've looked at this thread...
>
> I took a look at the mode you linked.  My mode is quite a bit more
> powerful, particularly with the changes I added today.  The linked
> mode does do some highlighting of special forms like @[...] that mine
> doesn't do yet, mainly because I didn't know about them.  Also, the
> linked mode seems to be a bit inconsistent about which keyword levels
> are used for what forms.  Finally, the linked mode has very limited
> support for comments (highlighting only).  Using my mode, C+e C+c and C
> +e C+k both work as expected, inserting ; and (comment ... ) as
> necessary.
>
> Daniel
>
> On Nov 23, 7:31 am, Patrick Wright  wrote:
>
> > FYI, another developer has been working on an edit mode for clojure.
> > You can download it 
> > fromhttp://sourceforge.net/tracker/?func=detail&atid=300588&aid=2201893&g...
>
> > See also this 
> > threadhttp://www.nabble.com/Edit-mode-for-Clojure-ts20168077.html#a20168077
>
> > Note that the version in thejEdittracker appears to be newer than
> > the one posted on the mailing list thread.
>
> > I haven't tried comparing them yet, but at some point I guess we
> > should pull them together into one.
>
> > Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: In core structure editor, anyone?

2008-12-11 Thread TNeste



On Dec 10, 2:15 pm, Simon Brooke  wrote:
> I note people seem mainly to be using Emacs as an editing/development
> environment for Clojure. But as people keep pointing out, Clojure is
> homoiconic; the canonical source of a function is not a stream of
> bytes read from a file, but is a structure in core.
>
> Now, in-core editing does raise some issues - there needs to be some
> means of associating the structure which is the canonical source of a
> function with the function itself, so that when the user invokes (edit
> froboz) (or (edit 'froboz), or whatever), the source structure for
> froboz is displayed in the editor. But in-core structure editors are
> extremely powerful and useful when editing homoiconic languages, so...
> is anyone working on an in-core editor for Clojure?

Do you mean structured editing combined with image based development?
I haven't really looked that closely at the old Interlisp documents
but I suppose the source code is managed the same way it is in most
Smalltalk systems but I have always been a bit puzzled about how that
works with Lisp.

In Smalltalk it is fairly straightforward since there is an obvious
mapping from classes and methods to source code. With lisp it is not
that simple as there is no limit to the syntactic forms that the user
might want to query and edit in different forms. For example, if I
have (define-foo my-foo ...) macro that is used to define some complex
function named my-foo what happens when I do (edit 'my-foo)? Do I get
the original define-foo form or the macroexpansion? What about when
define-foo does something more complex like defines a bunch of methods
and datastructures or binds my-foo to a closure? There needs to be
mechanism that associates evaluated forms with the name(s) of the
resulting object(s) and it probably couldn't, in general, be done
automatically.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: jEdit Mode for Clojure

2008-12-11 Thread Randall R Schulz

On Thursday 11 December 2008 10:34, Daniel Spiewak wrote:
> It's been too long since I've looked at this thread...
>
> I took a look at the mode you linked.  My mode is quite a bit more
> powerful, particularly with the changes I added today.  ...

Where do we find your latest version? Or do you want / need to refine it 
further?

I never really thought I'd go back to jEdit, but Enclojure's still 
broken and Peter's just getting started on his IDEA plug-in.


> Daniel


Randall Schulz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: memory issue with nth

2008-12-11 Thread Christian Vest Hansen

Wo-hoo! I found a fix.

I think it is only a JVM issue to the extent that the 1.6 JVM might be
able to mask the bug by doing escape analysis or some such other
magic, but that dosn't mean that the bug isn't there.

It's a super-simple little thing, and I can't imagine a CA is needed
to apply it. Patch:

Index: src/jvm/clojure/lang/RT.java
===
--- src/jvm/clojure/lang/RT.java(revision 1151)
+++ src/jvm/clojure/lang/RT.java(working copy)
@@ -697,6 +697,7 @@
else if(coll instanceof Sequential)
{
ISeq seq = ((IPersistentCollection) coll).seq();
+   coll = null;
for(int i = 0; i <= n && seq != null; ++i, seq = seq.rest())
{
if(i == n)
@@ -759,6 +760,7 @@
else if(coll instanceof Sequential)
{
ISeq seq = ((IPersistentCollection) coll).seq();
+   coll = null;
for(int i = 0; i <= n && seq != null; ++i, seq = seq.rest())
{
if(i == n)



On Thu, Dec 11, 2008 at 7:00 PM, Paul Mooser  wrote:
>
> I think this might just be a JVM version issue. I can reproduce this
> issue with a 1.5 JVM, but I can't reproduce it with 1.6.
> >
>



-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Java interop question

2008-12-11 Thread Mark Engelberg

I understand how Clojure lets you consume Java objects, and pass
Clojure objects to Java programs.

However, it is not uncommon for Java libraries to be designed in such
a way that you need to create a subclass of something in the library
in order to make use of the library.  I don't understand whether this
is possible in Clojure.

As a case in point, I'd like to know how to make use of Gecode/J in
Clojure.  If you look at the introduction,
http://www.gecode.org/gecodej/doc/PageComp.html, you'll see that the
first step is to subclass org.gecode.Space, adding special logic to
your constructor and creating a custom copy constructor.  How would
one do something like that from Clojure?

Thanks,

Mark

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



xml/parse

2008-12-11 Thread Robert Koberg

Hi, (very new to clojure, emacs and lispish things)

I am using the latest downloadable clojure (rather than SVN, which I  
do have and see it is a bit different) in Aquamacs. I have installed  
the clojure mode and am using it with inferior-lisp to see output.

When looking at the source for the clojure/xml/xml.clj, I see the  
example at the bottom which I modified to get to work (note the  
apostrophe before xml/parse):

(load-file "/Users/me/Downloads/clojure/src/clj/clojure/xml/xml.clj")
(def x ('xml/parse "/Users/me/correct/path/to/my.xml"))

; also tried URIs with file:///, file:// and file:/

Am I doing something wrong (my actual path to the xml is truly  
correct)? When I don't use the apostrophe I get an exception saying  
the namespace xml cannot be found.

But, since it seems to parse my xml, I get nil when trying to look at  
what it is parsed to:

user=> #'clojure.xml/emit
user=> #'user/x
user=> x ;also tried user/x, 'user/x, #'user/x...
nil

I am sure this is an error between keyboard and chair, but what?

thanks,
-Rob

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: jEdit Mode for Clojure

2008-12-11 Thread David Moss
Hi, just saw this thread. I had made some modifications to the edit mode and
uploaded it for inclusion (as a patch) here:
http://sourceforge.net/tracker/index.php?func=detail&aid=2201893&group_id=588&atid=300588
.

I haven't checked the status in a while as my internet is very intermittent
ATM. Please let me know if there is anything missing from it or if I can in
any way enhance the mode.

Kind Regards,

David.

2008/12/11 Randall R Schulz 

>
> On Thursday 11 December 2008 10:34, Daniel Spiewak wrote:
> > It's been too long since I've looked at this thread...
> >
> > I took a look at the mode you linked.  My mode is quite a bit more
> > powerful, particularly with the changes I added today.  ...
>
> Where do we find your latest version? Or do you want / need to refine it
> further?
>
> I never really thought I'd go back to jEdit, but Enclojure's still
> broken and Peter's just getting started on his IDEA plug-in.
>
>
> > Daniel
>
>
> Randall Schulz
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Learning Clojure

2008-12-11 Thread rb



On Dec 11, 7:06 am, Alex Burka  wrote:
> To the debate on whether there should be examples early in the text,  
> here are my two cents:
>
> When I click on something called "Learning [programming language]" I  
> like to see a representative example of the syntax early on. If  
> there's just text as far as the eye can see (that is, the first  
> screen) it is off-putting for some reason. After all, it is a  
> programming language.
>


Hi,

I've discovered Clojure recently, and so I guess I'm part of the
target audience for such a document :-)
I must say I agree with Alex: I would really like to see code
examples.

>From the title, I had expected a step by step tutorial for building my
first Clojure program.
I find your documentation *very* interesting but I filed it under
'Understanding Clojure' ;-)


Raph



> Alex
>
> On Dec 11, 2008, at 12:55 AM, Timothy Pratley wrote:
>
>
>
> > Hi Brian,
>
> >> Rich talks about destructuring in the part about "let" on the  
> >> "special
> >> forms" page.
>
> > Ah indeed, thanks for pointing that out :)
>
> >> If you have any examples to add, please add them yourself (it is a  
> >> wiki
> >> page).
>
> > You've given some really good reasons why I shouldn't mess with it
> > *chuckle* so I'm getting mixed messages. If you do want me to add
> > example link, I'm happy to do that but for now I'm assuming you'd
> > prefer it left as is :)
>
> >> Thanks for your feedback.
>
> > You are most welcome.
>
> > Regards,
> > Tim.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Java interop question

2008-12-11 Thread Randall R Schulz

On Thursday 11 December 2008 11:31, Mark Engelberg wrote:
> I understand how Clojure lets you consume Java objects, and pass
> Clojure objects to Java programs.
>
> However, it is not uncommon for Java libraries to be designed in such
> a way that you need to create a subclass of something in the library
> in order to make use of the library.  I don't understand whether this
> is possible in Clojure.

It's not only possible, but quite straightforward. The basic thing 
you're looking for is (proxy ...). In some cases, you may need 
(gen-class). Check them out. They'll get you everything you need for 
working with white-box frameworks.

(I'll check out Geocode/J as soon as I get Firefox back up. It just 
crashed and I keep 9 windows and over 80 tabs open, so starting it up 
is pretty slow...)


> ...
>
> Thanks,
>
> Mark


Randall Schulz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: xml/parse

2008-12-11 Thread Kevin Downey
your problem is '
' makes xml/parse a symbol and stops evaling it to a function
symbols are callable like keywords so if you have a hash with symbols
as keys you can
('a {'a 1 'b 2}) -> 1

so ('xml/parse "/Users/me/correct/path/to/my.xml") is trying to lookup
'xml/parse in "/Users/me/correct/path/to/my.xml" doesn't find it, and
returns nil


On Thu, Dec 11, 2008 at 12:01 PM, Robert Koberg  wrote:
>
> Hi, (very new to clojure, emacs and lispish things)
>
> I am using the latest downloadable clojure (rather than SVN, which I
> do have and see it is a bit different) in Aquamacs. I have installed
> the clojure mode and am using it with inferior-lisp to see output.
>
> When looking at the source for the clojure/xml/xml.clj, I see the
> example at the bottom which I modified to get to work (note the
> apostrophe before xml/parse):
>
> (load-file "/Users/me/Downloads/clojure/src/clj/clojure/xml/xml.clj")
> (def x ('xml/parse "/Users/me/correct/path/to/my.xml"))
>
> ; also tried URIs with file:///, file:// and file:/
>
> Am I doing something wrong (my actual path to the xml is truly
> correct)? When I don't use the apostrophe I get an exception saying
> the namespace xml cannot be found.
>
> But, since it seems to parse my xml, I get nil when trying to look at
> what it is parsed to:
>
> user=> #'clojure.xml/emit
> user=> #'user/x
> user=> x ;also tried user/x, 'user/x, #'user/x...
> nil
>
> I am sure this is an error between keyboard and chair, but what?
>
> thanks,
> -Rob
>
> >
>



-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: xml/parse

2008-12-11 Thread Shawn Hoover
On Thu, Dec 11, 2008 at 3:01 PM, Robert Koberg  wrote:

>
> Hi, (very new to clojure, emacs and lispish things)
>
> I am using the latest downloadable clojure (rather than SVN, which I
> do have and see it is a bit different) in Aquamacs. I have installed
> the clojure mode and am using it with inferior-lisp to see output.
>
> When looking at the source for the clojure/xml/xml.clj, I see the
> example at the bottom which I modified to get to work (note the
> apostrophe before xml/parse):
>
> (load-file "/Users/me/Downloads/clojure/src/clj/clojure/xml/xml.clj")
> (def x ('xml/parse "/Users/me/correct/path/to/my.xml"))
>

Hi Robert,

Try calling (clojure.xml/parse "your-file") instead of 'xml/parse. The full
namespace clojure.xml is required. You could also (refer 'clojure.xml) and
then just call (parse "your-file").

Shawn

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: xml/parse

2008-12-11 Thread Robert Koberg


On Dec 11, 2008, at 3:23 PM, Kevin Downey wrote:

> your problem is '
> ' makes xml/parse a symbol and stops evaling it to a function
> symbols are callable like keywords so if you have a hash with symbols
> as keys you can
> ('a {'a 1 'b 2}) -> 1
>
> so ('xml/parse "/Users/me/correct/path/to/my.xml") is trying to lookup
> 'xml/parse in "/Users/me/correct/path/to/my.xml" doesn't find it, and
> returns nil

OK, that is basically what I thought. But why doesn't it work? I do  
seem to be loading the xml.clj correctly (?) because I see:

user=> #'clojure.xml/emit

but if I use:

(def x (xml/parse "/Users/me/correct/path/to/my.xml"))

I get:

user=> java.lang.Exception: No such namespace: xml
clojure.lang.Compiler$CompilerException: NO_SOURCE_FILE:94: No such  
namespace: xml
at clojure.lang.Compiler.analyze(Compiler.java:3713)
at clojure.lang.Compiler.analyze(Compiler.java:3671)
at clojure.lang.Compiler.access$100(Compiler.java:37)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:2634)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3860)
at clojure.lang.Compiler.analyze(Compiler.java:3698)
at clojure.lang.Compiler.access$200(Compiler.java:37)
at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:343)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:3858)
at clojure.lang.Compiler.analyze(Compiler.java:3698)
at clojure.lang.Compiler.analyze(Compiler.java:3671)
at clojure.lang.Compiler.eval(Compiler.java:3895)
at clojure.lang.Repl.main(Repl.java:75)
Caused by: java.lang.Exception: No such namespace: xml
at clojure.lang.Compiler.resolveIn(Compiler.java:3998)
at clojure.lang.Compiler.resolve(Compiler.java:3972)
at clojure.lang.Compiler.analyzeSymbol(Compiler.java:3955)
at clojure.lang.Compiler.analyze(Compiler.java:3686)
... 12 more

>
>
>
> On Thu, Dec 11, 2008 at 12:01 PM, Robert Koberg   
> wrote:
>>
>> Hi, (very new to clojure, emacs and lispish things)
>>
>> I am using the latest downloadable clojure (rather than SVN, which I
>> do have and see it is a bit different) in Aquamacs. I have installed
>> the clojure mode and am using it with inferior-lisp to see output.
>>
>> When looking at the source for the clojure/xml/xml.clj, I see the
>> example at the bottom which I modified to get to work (note the
>> apostrophe before xml/parse):
>>
>> (load-file "/Users/me/Downloads/clojure/src/clj/clojure/xml/xml.clj")
>> (def x ('xml/parse "/Users/me/correct/path/to/my.xml"))
>>
>> ; also tried URIs with file:///, file:// and file:/
>>
>> Am I doing something wrong (my actual path to the xml is truly
>> correct)? When I don't use the apostrophe I get an exception saying
>> the namespace xml cannot be found.
>>
>> But, since it seems to parse my xml, I get nil when trying to look at
>> what it is parsed to:
>>
>> user=> #'clojure.xml/emit
>> user=> #'user/x
>> user=> x ;also tried user/x, 'user/x, #'user/x...
>> nil
>>
>> I am sure this is an error between keyboard and chair, but what?
>>
>> thanks,
>> -Rob
>>
>>>
>>
>
>
>
> -- 
> And what is good, Phaedrus,
> And what is not good—
> Need we ask anyone to tell us these things?
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Why allow both ({:map 'example} :map) and (:map {:map 'example})?

2008-12-11 Thread Aaron Cohen

Isn't it just asking for confusion?

I really like that maps are functions of their keys though.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Why allow both ({:map 'example} :map) and (:map {:map 'example})?

2008-12-11 Thread Rich Hickey



On Dec 11, 3:29 pm, "Aaron Cohen"  wrote:
> Isn't it just asking for confusion?
>
> I really like that maps are functions of their keys though.

If you want to pull the same key from a bunch of maps, being able to
map the key is handy.

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
To unsubscribe from 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: xml/parse

2008-12-11 Thread Robert Koberg


On Dec 11, 2008, at 3:25 PM, Shawn Hoover wrote:

> On Thu, Dec 11, 2008 at 3:01 PM, Robert Koberg  wrote:
>
> Hi, (very new to clojure, emacs and lispish things)
>
> I am using the latest downloadable clojure (rather than SVN, which I
> do have and see it is a bit different) in Aquamacs. I have installed
> the clojure mode and am using it with inferior-lisp to see output.
>
> When looking at the source for the clojure/xml/xml.clj, I see the
> example at the bottom which I modified to get to work (note the
> apostrophe before xml/parse):
>
> (load-file "/Users/me/Downloads/clojure/src/clj/clojure/xml/xml.clj")
> (def x ('xml/parse "/Users/me/correct/path/to/my.xml"))
>
> Hi Robert,
>
> Try calling (clojure.xml/parse "your-file") instead of 'xml/parse.  
> The full namespace clojure.xml is required. You could also (refer  
> 'clojure.xml) and then just call (parse "your-file").

Thanks, that works!

-Rob

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Java interop question

2008-12-11 Thread Brian Doyle
This article has a good example using the proxy function.

http://gnuvince.wordpress.com/2008/11/18/fetching-web-comics-with-clojure-part-2/

On Thu, Dec 11, 2008 at 1:22 PM, Randall R Schulz  wrote:

>
> On Thursday 11 December 2008 11:31, Mark Engelberg wrote:
> > I understand how Clojure lets you consume Java objects, and pass
> > Clojure objects to Java programs.
> >
> > However, it is not uncommon for Java libraries to be designed in such
> > a way that you need to create a subclass of something in the library
> > in order to make use of the library.  I don't understand whether this
> > is possible in Clojure.
>
> It's not only possible, but quite straightforward. The basic thing
> you're looking for is (proxy ...). In some cases, you may need
> (gen-class). Check them out. They'll get you everything you need for
> working with white-box frameworks.
>
> (I'll check out Geocode/J as soon as I get Firefox back up. It just
> crashed and I keep 9 windows and over 80 tabs open, so starting it up
> is pretty slow...)
>
>
> > ...
> >
> > Thanks,
> >
> > Mark
>
>
> Randall Schulz
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



XML Namespaces :xmlns, was Re: xml/parse

2008-12-11 Thread Robert Koberg

Hi again,

I see the default ContentHandler implementation does not handle XML  
Namespaces. Is that the case or does the :xmlns symbol provide some  
meaning to the (nested) collection(s)? Is there such a thing as  
namespacing a collection that would be based on the xmlns?

thanks,
-Rob

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: XML Namespaces :xmlns, was Re: xml/parse

2008-12-11 Thread Robert Koberg


On Dec 11, 2008, at 3:44 PM, Robert Koberg wrote:

>
> Hi again,
>
> I see the default ContentHandler implementation does not handle XML
> Namespaces. Is that the case or does the :xmlns symbol

I meant keyword (I think) here. For example, say I have  /xml/ like:

{:tag :my-root, attrs {:xmlns:x  "http://www.w3.org/1999/ 
xhtml", :xmlns:o "http://other/ns"}, content[
   {:tag :x:input}
   {:tag :o:something}
]}

Is there some awareness in clojure code that manipulates/reads these  
collections that one child belongs to one namespace and the other  
belongs to the other namespace?

thanks,
-Rob

> provide some
> meaning to the (nested) collection(s)? Is there such a thing as
> namespacing a collection that would be based on the xmlns?



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: jEdit Mode for Clojure

2008-12-11 Thread Randall R Schulz

On Thursday 11 December 2008 12:54, Daniel Spiewak wrote:
> > Where do we find your latest version? Or do you want / need to
> > refine it further?
>
> I'm constantly messing around with it and trying to make it a little
> better.  The very latest version is always here:
> http://github.com/djspiewak/jedit-modes/tree/master/clojure.xml

Thanks. Is there any particular jEdit version requirement? I'm currently 
running 4.3pre14


> Daniel


Randall Schulz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: jEdit Mode for Clojure

2008-12-11 Thread Daniel Spiewak

> Hi, just saw this thread. I had made some modifications to the edit mode and
> uploaded it for inclusion (as a patch) 
> here:http://sourceforge.net/tracker/index.php?func=detail&aid=2201893&grou...
> .
>
> I haven't checked the status in a while as my internet is very intermittent
> ATM. Please let me know if there is anything missing from it or if I can in
> any way enhance the mode.

I'll have to take a closer look at your new version.  We probably
should merge our efforts.  Your mode does do some things that mine
doesn't, and it doesn't really benefit anyone to have three competing
Clojure modes.  :-)  My mode is pretty convoluted in the way it uses
some  tricks to highlight things like (def blah), so it's
probably easier if I steal your improvements and merge them into
mine.  I'll give that a try later today and post back with the
results.

Daniel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: jEdit Mode for Clojure

2008-12-11 Thread Daniel Spiewak

> Where do we find your latest version? Or do you want / need to refine it
> further?

I'm constantly messing around with it and trying to make it a little
better.  The very latest version is always here:
http://github.com/djspiewak/jedit-modes/tree/master/clojure.xml

Daniel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: XML Namespaces :xmlns, was Re: xml/parse

2008-12-11 Thread Robert Koberg

>

Apologies for responding to myself, but maybe an example might help  
(inline below)

>>
>> Hi again,
>>
>> I see the default ContentHandler implementation does not handle XML
>> Namespaces. Is that the case or does the :xmlns symbol
>
> I meant keyword (I think) here. For example, say I have  /xml/ like:
>
> {:tag :my-root, attrs {:xmlns:x  "http://www.w3.org/1999/
> xhtml", :xmlns:o "http://other/ns"}, content[
>   {:tag :x:input}
>   {:tag :o:something}
> ]}
>
> Is there some awareness in clojure code that manipulates/reads these
> collections that one child belongs to one namespace and the other
> belongs to the other namespace?

For example, a common scenario in XSL might be to perform an identity  
transform on elements in the XHTML namespace and handle other  
namespaced items as needed:

http://www.w3.org/1999/XSL/Transform";
   version="2.0"
   xmlns:x="http://www.w3.org/1999/xhtml";
   xmlns:o="other/ns">
   
   
 
   
   
   
 
   
 
   
   
   
 
   
   
   
 handle in some desired way...
   



>
>
> thanks,
> -Rob
>
>> provide some
>> meaning to the (nested) collection(s)? Is there such a thing as
>> namespacing a collection that would be based on the xmlns?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Paul Barry

I've been reading the latest chapter from Stuart's book, Chapter 7:
Macros, and he makes this statement:

"Clojure has no special syntax for code. Code is simply Clojure data.
This is true for normal functions, but also for special forms and
macros. Consider a language with syntax, such as Java. ..."

It seems to me that just like all lisps, Clojure has syntax.  The
first and most obvious piece of syntax is the parenthesises.  Lists
start with an open paren and end with a closing paren.  This is syntax
and you can't change it with a macro.

Next is the single quote, which is just an alias for quote.  Somewhere
along the line, someone decided that (quote foo) was too verbose and
they wanted 'foo to be syntactic sugar for (quote foo).  That wasn't
and can't be done as a macro.  For example, if I wanted to define my
own single quote, say $foo, I can't without modifying the parser.

Clojure goes on to add a lot of syntax.  The literal syntax for
vectors [], maps {}, sets #{}, functions #(), keywords :, etc. are all
syntax, not possible with macros, and then there are all the "reader
macros" that are listed in Section 2.2, Comment ;, Deref @, Meta ^,
Metadata #^, regex #"", syntax-quote `, unquote ~, unquote-splicing
~@, and var-quote #'.

So is it really valid to claim Clojure has no syntax?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Strings as functions of maps

2008-12-11 Thread Stefan Rusek

If we have the following map:

(def m {:key 1 'sym 2 "str" 3})

The following are equivalent:

(:key m)
(m :key)

As are the following:

('sym m)
(m 'sym)

I think the commutativity of maps with symbols and keywords is a
valuable and good thing. I realize that the String class doesn't
implement the IFn interface, but it would be nice if maps and strings
were commutative. Unfortunately they aren't:

("str" m) ; throws invalid cast
(m "str") ; works fine

I realize that almost any type can be used as a key for a map, but
keywords, symbols, and strings are by far the most common, and it
would make sense to bring strings in line with the other two.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: jEdit Mode for Clojure

2008-12-11 Thread Randall R Schulz

On Thursday 11 December 2008 12:54, Daniel Spiewak wrote:
> > Where do we find your latest version? Or do you want / need to
> > refine it further?
>
> I'm constantly messing around with it and trying to make it a little
> better.  The very latest version is always here:
> http://github.com/djspiewak/jedit-modes/tree/master/clojure.xml

Works in 4.3pre14 and looks great.

Thanks!


> Daniel


Randall Schulz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Randall R Schulz

On Thursday 11 December 2008 13:37, Paul Barry wrote:
> I've been reading the latest chapter from Stuart's book, Chapter 7:
> Macros, and he makes this statement:
>
> "Clojure has no special syntax for code. Code is simply Clojure data.
> This is true for normal functions, but also for special forms and
> macros. Consider a language with syntax, such as Java. ..."
>
> It seems to me that just like all lisps, Clojure has syntax.  The
> first and most obvious piece of syntax is the parenthesises.  Lists
> start with an open paren and end with a closing paren.  This is
> syntax and you can't change it with a macro.

Punctuation is not syntax. Lisp can be said to have a syntax, that of 
the S-Expression. Beyond that, as someone else pointed out in another 
thread here recently, when we write Lisp code, we're basically writing 
directly the AST that other languages would need a parser implementing 
a complicated grammar to produce.


> Next is the single quote, which is just an alias for quote. 
> Somewhere along the line, someone decided that (quote foo) was too
> verbose and they wanted 'foo to be syntactic sugar for (quote foo). 
> That wasn't and can't be done as a macro.  For example, if I wanted
> to define my own single quote, say $foo, I can't without modifying
> the parser.
>
> Clojure goes on to add a lot of syntax.  The literal syntax for
> vectors [], maps {}, sets #{}, functions #(), keywords :, etc. are
> all syntax, not possible with macros, and then there are all the
> "reader macros" that are listed in Section 2.2, Comment ;, Deref @,
> Meta ^, Metadata #^, regex #"", syntax-quote `, unquote ~,
> unquote-splicing ~@, and var-quote #'.

All these things are syntactic sugar. Shorthand ways to write things 
that have vanilla S-Expression counterparts. Again, I would not call 
them syntax.


> So is it really valid to claim Clojure has no syntax?

Very nearly so.


Randall Schulz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Sean Spencer
That was one of the best explanations of code as data I've ever read.
Kudos!

On Thu, Dec 11, 2008 at 4:44 PM, Randall R Schulz  wrote:

>
> On Thursday 11 December 2008 13:37, Paul Barry wrote:
> > I've been reading the latest chapter from Stuart's book, Chapter 7:
> > Macros, and he makes this statement:
> >
> > "Clojure has no special syntax for code. Code is simply Clojure data.
> > This is true for normal functions, but also for special forms and
> > macros. Consider a language with syntax, such as Java. ..."
> >
> > It seems to me that just like all lisps, Clojure has syntax.  The
> > first and most obvious piece of syntax is the parenthesises.  Lists
> > start with an open paren and end with a closing paren.  This is
> > syntax and you can't change it with a macro.
>
> Punctuation is not syntax. Lisp can be said to have a syntax, that of
> the S-Expression. Beyond that, as someone else pointed out in another
> thread here recently, when we write Lisp code, we're basically writing
> directly the AST that other languages would need a parser implementing
> a complicated grammar to produce.
>
>
> > Next is the single quote, which is just an alias for quote.
> > Somewhere along the line, someone decided that (quote foo) was too
> > verbose and they wanted 'foo to be syntactic sugar for (quote foo).
> > That wasn't and can't be done as a macro.  For example, if I wanted
> > to define my own single quote, say $foo, I can't without modifying
> > the parser.
> >
> > Clojure goes on to add a lot of syntax.  The literal syntax for
> > vectors [], maps {}, sets #{}, functions #(), keywords :, etc. are
> > all syntax, not possible with macros, and then there are all the
> > "reader macros" that are listed in Section 2.2, Comment ;, Deref @,
> > Meta ^, Metadata #^, regex #"", syntax-quote `, unquote ~,
> > unquote-splicing ~@, and var-quote #'.
>
> All these things are syntactic sugar. Shorthand ways to write things
> that have vanilla S-Expression counterparts. Again, I would not call
> them syntax.
>
>
> > So is it really valid to claim Clojure has no syntax?
>
> Very nearly so.
>
>
> Randall Schulz
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Paul Barry


On Dec 11, 4:44 pm, Randall R Schulz  wrote:
> All these things are syntactic sugar. Shorthand ways to write things
> that have vanilla S-Expression counterparts. Again, I would not call
> them syntax.

syntactic sugar is not syntax?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Randall R Schulz

On Thursday 11 December 2008 13:47, Sean Spencer wrote:
> That was one of the best explanations of code as data I've ever read.
> Kudos!

Thanks. You forced me to look up the reference to which I alluded:

On Thursday 11 December 2008 06:32, evins.mi...@gmail.com wrote:
> Subject: Re: In core structure editor, anyone?
>
> Structure editors are not in common use, maybe because, while they're
> a valid and maybe cool alternative to text editors for lisp code,
> it's not clear how useful they are for other kinds of code. In most
> programming languages a lexer and parser construct an abstract syntax
> tree from the source code. In lisp, the abstract syntax tree *is* the
> source code. That being the case, it makes a lot of sense with lisp
> to operate directly on the parse tree. In other languages, not so
> much.

So the kudos go to Mikel Evins (or is it Evins Mikel?).


Randall Schulz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Stuart Halloway

Randall,

Well said, and I need to find a place to make this explanation in the  
book prior to chapter 7. :-)

Stuart

> On Thursday 11 December 2008 13:37, Paul Barry wrote:
>> I've been reading the latest chapter from Stuart's book, Chapter 7:
>> Macros, and he makes this statement:
>>
>> "Clojure has no special syntax for code. Code is simply Clojure data.
>> This is true for normal functions, but also for special forms and
>> macros. Consider a language with syntax, such as Java. ..."
>>
>> It seems to me that just like all lisps, Clojure has syntax.  The
>> first and most obvious piece of syntax is the parenthesises.  Lists
>> start with an open paren and end with a closing paren.  This is
>> syntax and you can't change it with a macro.
>
> Punctuation is not syntax. Lisp can be said to have a syntax, that of
> the S-Expression. Beyond that, as someone else pointed out in another
> thread here recently, when we write Lisp code, we're basically writing
> directly the AST that other languages would need a parser implementing
> a complicated grammar to produce.
>
>
>> Next is the single quote, which is just an alias for quote.
>> Somewhere along the line, someone decided that (quote foo) was too
>> verbose and they wanted 'foo to be syntactic sugar for (quote foo).
>> That wasn't and can't be done as a macro.  For example, if I wanted
>> to define my own single quote, say $foo, I can't without modifying
>> the parser.
>>
>> Clojure goes on to add a lot of syntax.  The literal syntax for
>> vectors [], maps {}, sets #{}, functions #(), keywords :, etc. are
>> all syntax, not possible with macros, and then there are all the
>> "reader macros" that are listed in Section 2.2, Comment ;, Deref @,
>> Meta ^, Metadata #^, regex #"", syntax-quote `, unquote ~,
>> unquote-splicing ~@, and var-quote #'.
>
> All these things are syntactic sugar. Shorthand ways to write things
> that have vanilla S-Expression counterparts. Again, I would not call
> them syntax.
>
>
>> So is it really valid to claim Clojure has no syntax?
>
> Very nearly so.
>
>
> Randall Schulz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Daniel Eklund



> I've been reading the latest chapter from Stuart's book, Chapter 7:
> Macros, and he makes this statement:
>
> "Clojure has no special syntax for code. Code is simply Clojure data.
> This is true for normal functions, but also for special forms and
> macros. Consider a language with syntax, such as Java. ..."
>
> It seems to me that just like all lisps, Clojure has syntax.  The
> first and most obvious piece of syntax is the parenthesises.  Lists
> start with an open paren and end with a closing paren.  This is syntax
> and you can't change it with a macro.

I would agree with you, but I do not feel too strongly about the
matter.  The statement "clojure has _no_ syntax" is probably not
defensible with an eye towards formal rigor.. I have no idea what a
syntax-less language would look like.  I feel fairly certain that the
book's aims are not to provide a hard stance on no-syntax but to open
the eyes of those people who have been dealing with the Java's and the
C's for their entire careers, where syntax is locked in by convention
and grammar specs.

Despite quote and {} and [] being syntax-tic sugar, they certainly
have their sexp counterparts, and all of this is driven from the
reader which could possibly be extended or reduced for particular
needs --  although Clojure does not allow for programmer-defined
reader macros (unlike other lisps).

The existence of the reader makes the "no syntax" claim a lot easier
to understand, but in the end, this could be a long discussion about
what each person feels "syntax" is.

my $0.02
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Randall R Schulz

On Thursday 11 December 2008 13:50, Paul Barry wrote:
> On Dec 11, 4:44 pm, Randall R Schulz  wrote:
> > All these things are syntactic sugar. Shorthand ways to write
> > things that have vanilla S-Expression counterparts. Again, I would
> > not call them syntax.
>
> syntactic sugar is not syntax?

I have to say "no."

Syntax is about complex ordering rules. Take a look at the grammar for 
Java or C or Pascal or Ada or even for YACC or JavaCC! They're 
horrendously complicated. There's nothing like that in Lisps.

Syntactic sugar of the sort present in Lisps is very simple. One or two 
characters trigger a small modification or adornment of what 
immediately follows.

A more interesting contrast, perhaps, is CLIF, the Common Logic 
Interchange Format (successor to KIF). If I flashed a page of it in 
front of you, you'd think it was Lisp. It uses prefix, fully 
parenthesized notation. But it requires a grammar specified in BNF.

So you _can_ have syntax in such notational forms, but Lisp doesn't


Randall Schulz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: Why allow both ({:map 'example} :map) and (:map {:map 'example})?

2008-12-11 Thread Stephen C. Gilardi


On Dec 11, 2008, at 3:29 PM, Aaron Cohen wrote:


Isn't it just asking for confusion?

I really like that maps are functions of their keys though.


It's nice to be able to use (:key some-argument) if some-argument  
might be nil.


(:key nil) => nil (a useful answer)
(nil :key) => IllegalArgumentException, can't call nil

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: memory issue with nth

2008-12-11 Thread Paul Mooser

Nice job finding it ...! Once I could not reproduce it on JDK 6, I
stopped looking for a real answer.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: memory issue with nth

2008-12-11 Thread Rich Hickey



On Dec 11, 2:28 pm, "Christian Vest Hansen" 
wrote:
> Wo-hoo! I found a fix.
>
> I think it is only a JVM issue to the extent that the 1.6 JVM might be
> able to mask the bug by doing escape analysis or some such other
> magic, but that dosn't mean that the bug isn't there.
>
> It's a super-simple little thing, and I can't imagine a CA is needed

Fixed in svn 1153 - thanks for the report.

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
To unsubscribe from 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: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Dave Newton

--- On Thu, 12/11/08, Paul Barry wrote:
> syntactic sugar is not syntax?

I think that depends on which particular nits are being picked.

Is it strictly true that Clojure has "no syntax"? Meh--probably not.

(defun foo [bar] ...) has more unique characters than (defun foo (bar) ...) or 
(define (foo bar) ...) but is it a *meaningful* difference?

Is '(foo) meaningfully different than (quote (foo))? Again, more unique 
characters... but is it in the language, or is it in the reader? They're called 
reader macros for a reason.

All in all, not something I'll be terribly concerned with either way.

Dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Rich Hickey



On Dec 11, 5:03 pm, Daniel Eklund  wrote:
> > I've been reading the latest chapter from Stuart's book, Chapter 7:
> > Macros, and he makes this statement:
>
> > "Clojure has no special syntax for code. Code is simply Clojure data.
> > This is true for normal functions, but also for special forms and
> > macros. Consider a language with syntax, such as Java. ..."
>
> > It seems to me that just like all lisps, Clojure has syntax.  The
> > first and most obvious piece of syntax is the parenthesises.  Lists
> > start with an open paren and end with a closing paren.  This is syntax
> > and you can't change it with a macro.
>
> I would agree with you, but I do not feel too strongly about the
> matter.  The statement "clojure has _no_ syntax" is probably not
> defensible with an eye towards formal rigor.. I have no idea what a
> syntax-less language would look like.  I feel fairly certain that the
> book's aims are not to provide a hard stance on no-syntax but to open
> the eyes of those people who have been dealing with the Java's and the
> C's for their entire careers, where syntax is locked in by convention
> and grammar specs.
>
> Despite quote and {} and [] being syntax-tic sugar, they certainly
> have their sexp counterparts, and all of this is driven from the
> reader which could possibly be extended or reduced for particular
> needs --  although Clojure does not allow for programmer-defined
> reader macros (unlike other lisps).
>
> The existence of the reader makes the "no syntax" claim a lot easier
> to understand, but in the end, this could be a long discussion about
> what each person feels "syntax" is.
>

Yes, the critical point is that the text-based representation of code
is completely secondary:

(def x (list (list (symbol "fn") (vector) "Hello World")))

(class (second (first x)))
-> clojure.lang.PersistentVector

(class (first (first x)))
-> clojure.lang.Symbol

x
-> ((fn [] "Hello World"))

(eval x)
-> "Hello World"

You could build code via Java calls to the Clojure lib:

(import '(clojure.lang RT Symbol PersistentVector))

(def y (RT/list (RT/list (Symbol/create "fn")
 (PersistentVector/EMPTY)
 (Symbol/create "Hello World")

Parens, square brackets, #, "", etc are reader syntax for data
structures. You could define a different reader and completely
different text-based syntax for the language.

The language syntax is defined in terms of data structures, not text,
and in that respect doesn't have (text-based) syntax. The reader has
text-based syntax for data.

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
To unsubscribe from 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: Strings as functions of maps

2008-12-11 Thread Rich Hickey



On Dec 11, 4:37 pm, Stefan Rusek  wrote:
> If we have the following map:
>
> (def m {:key 1 'sym 2 "str" 3})
>
> The following are equivalent:
>
> (:key m)
> (m :key)
>
> As are the following:
>
> ('sym m)
> (m 'sym)
>
> I think the commutativity of maps with symbols and keywords is a
> valuable and good thing. I realize that the String class doesn't
> implement the IFn interface, but it would be nice if maps and strings
> were commutative. Unfortunately they aren't:
>
> ("str" m) ; throws invalid cast
> (m "str") ; works fine
>
> I realize that almost any type can be used as a key for a map, but
> keywords, symbols, and strings are by far the most common, and it
> would make sense to bring strings in line with the other two.

That's not likely to happen. Being pragmatic, Clojure values strings
being Java Strings and no conditionals on fn calls more highly than
that feature. It's a tradeoff.

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
To unsubscribe from 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: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Dave Griffith


My view is that Lisps have very a simple syntax, achieved at the cost
of moving a fair amount of error checking until runtime.   If you
ignore reader macros, you can tell if a Clojure expression is well-
formed by just keeping a count of open parentheses, which is about the
least amount of state that a parser could theoretically have.  On the
downside, you can't tell until runtime whether a given function call
has an acceptable arity, which pretty much any other popular language
can check at edit-time.

--Dave Griffith
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Randall R Schulz

On Thursday 11 December 2008 15:24, Dave Griffith wrote:
> ... 
> On the downside, you can't tell until runtime whether a given function
> call has an acceptable arity, which pretty much any other popular
> language can check at edit-time.

Given that function definitions are closed, it's eminently feasible for 
an editor to detect whether a calling form is valid or not. Keep in 
mind that the only kind of function overloading in Clojure is that 
based on arity.

More complex forms of overloading require the use of multimethods, which 
do their dispatching dynamically and arbitrarily based on the supplied 
arguments (dynamically). In that case, not all calling forms will be 
statically validateable, though some still will.


> --Dave Griffith


Randall Schulz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: memory issue with nth

2008-12-11 Thread Rich Hickey



On Dec 11, 5:56 pm, Rich Hickey  wrote:
> On Dec 11, 2:28 pm, "Christian Vest Hansen" 
> wrote:
>
> > Wo-hoo! I found a fix.
>
> > I think it is only a JVM issue to the extent that the 1.6 JVM might be
> > able to mask the bug by doing escape analysis or some such other
> > magic, but that dosn't mean that the bug isn't there.
>
> > It's a super-simple little thing, and I can't imagine a CA is needed
>
> Fixed in svn 1153 - thanks for the report.
>

And thanks to all who helped chase it down!

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
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Retired: clojure.contrib.pred and clojure.contrib.memoize

2008-12-11 Thread Stephen C. Gilardi
I removed the "pred" and "memoize" libs from clojure.contrib today.  
The most useful functions formerly in pred and the only function in  
memoize are now defined in clojure.core.


--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-12-11 Thread mosi

Hi Bill,
it seems I found the tick with swank-clojure, slime and emacs.

Swank/clojure works only if the user is not root. (Or so it seems on
my linux setup)
Following your instructions on http://bc.tech.coop/blog/081023.html
if the user is root, swank-clojure spawns a server listening on a
given port, and the slime (or for that matter any other program, e.g.
telnet) cannot connect to the given port.

Nevermind the protocol version, the bug is reproducible with both of
them, "2008-11-23" and "2008-12-07".
Installation: debian lenny up-to-date 12/2008.
Emacs 21, Emacs 22, X or text versions
Slime from repository and git slime from 12/2008 tested
swank/clojure "2008-12-07" and newer tested.

I didn`t find out if the bug is in my linux config (no firewall
installed, no selinux) or in any of the packages (Emacs?)
It`s probably not slime. Slime works with sbcl and clisp.
Could anybody confirm/reject my wild assumtions?

Have a nice day,
mosi

PS: Thanx Feng hou for helping to find out the most basic swank-
clojure setup. It was not clear from the docs, that the following is
needed to start:
(swank/start-server "/dev/null" :port 4005 :dont-close true)

In all the web tutorials the old function name is used.

On Dec 9, 2:10 am, "Bill Clementson"  wrote:
> On Mon, Dec 8, 2008 at 4:29 PM, mosi  wrote:
> > thank you for helping the beginners like me with the setup of emacs,
> > slime and clojure.
> > I tried first the official method described elsewhere on this forum -
> > ubuntu linux instructions.
> > Unsuccessful.
> > Following your instructions, the same issue, my linux emacs22 gets to
> > this point:
>
> > (add-classpath "file:install/swank-clojure/")
> > (require (quote swank))
> > (swank/ignore-protocol-version "2008-11-23")
> > (swank/start-server "/tmp/slime.10616" :encoding "iso-latin-1-unix")
> > Clojure
> > user=> nil
> > user=> nil
> > user=> "2008-11-23"
> > user=> Connection opened on local port  58654
> > 58654
> > user=>
>
> > And waits for connection. The socket (or a file?) /tmp/slime. does
> > not exist. Connection time-out causes an error - waiting for slime
> > session to connect to swank server.
> > My impression is: the swank server never started. Probably swank-
> > clojure broken? I have the latest git version as of 07.12.2008.
> > Any ideas?
> > thanks a lot.
> > mosi
>
> You said that you followed my instructions; however, the protocol
> version that prints out in the inferior-lisp buffer is "2008-11-23".
> In my version of SLIME (which is several days old) the protocol
> version that prints out in the inferior-lisp buffer is "2008-12-02".
> If you have a swank-clojure from 07.12.2008, I suspect (at least) your
> SLIME install is older than that. Therefore, I would suggest that you
> repeat steps 1-5 (from my original email) to make certain you really
> have compatible versions of each package.
>
> - Bill
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: why can't I set! stuff in user.clj?

2008-12-11 Thread Rich Hickey


On Dec 10, 2008, at 1:50 PM, Stephen C. Gilardi wrote:

>
> On Dec 10, 2008, at 8:51 AM, Stuart Halloway wrote:
>
>> Thanks for the info. Is this limitation of user.clj arbitrary, or
>> motivated by some concern that the average Clojure user should know
>> about?  Is the a reason not to load the bindings first? Does user.clj
>> (in current form) do more harm than good?
>
>
> I think it comes down to separating "Clojure the library of  
> capabilities" from "Clojure the platform for running Clojure repls  
> and programs".
>
> Initializing the library
>
> By default the Clojure library provides its many capabilities and a  
> user namespace that's empty and refers to clojure.core. The  
> "user.clj" hook is provided to configure the Clojure library such  
> that the "user" namespace is not empty. It may provide arbitrary  
> capabilities beyond what's provided by Clojure out of the box  
> including loading other namespaces. user.clj is loaded at static  
> initialization time, it runs to completion and exits. When static  
> init time is over, the augmented Clojure library including  
> customizations from user.clj is loaded and ready, but nothing is  
> running.
>
> Defining the Platform
>
> The Clojure platform is the Clojure library plus an entry point  
> function. The Clojure distribution provides a few entry point  
> functions, but a user of the Clojure library is also free to write  
> their own. I think it makes sense for the Clojure distribution to  
> provide only one entry point function out of the box. That's what  
> clojure.main/-main is intended to be *see note below*. Clojure.main/- 
> main can provide a repl, or run a program, or just do a calculation  
> and exit. I think it should replace Repl.java and Script.java.  
> Clojure.main/-main does push bindings for several vars to make them  
> settable and it does it the same way whether it's providing a repl,  
> a script, or an eval: see clojure.main/with-bindings .
>
> Initializing the Platform
>
> I think Clojure should provide one or more hooks (in the form of  
> files that are loaded automatically if present) for initializing the  
> one platform it provides. If there's only one hook, I think  
> /init.clj would be a good choice. It would be loaded  
> every time Clojure.main/-main runs and it would do so after thread  
> bindings have been pushed so it could "set!" any of the variables  
> covered by clojure.main/with-bindings.
>
> This hook would *not* be loaded automatically if the user provides  
> their own entry point function that uses the Clojure library. This  
> is in contrast to user.clj which will *always* be loaded if present.
>
> Beyond /init.clj which runs for repl, script, and eval  
> sessions, a /repl-init.clj hook would also be useful. In  
> it, one could customize how repls behave independently from how  
> scripts behave. For example, I would set *print-length* in repl- 
> init.clj, but not init.clj.
>
> Summary
>
> - user.clj is the way it is for a good reason: it must run to  
> completion to provide an initialized Clojure library augmented with  
> custom capabilities. Since it doesn't wrap a runtime session, it  
> shouldn't be the way enable setting of vars and doesn't need to  
> support setting of vars.
>
> - I think init.clj and repl-init.clj would be good additions to what  
> we have now. I'll be happy to write the code if it's welcome.
>
> --Steve
>
> *note* on 7 December, on this mailing list, "User Jon" suggested  
> that Clojure have a tiny main function written in Java whose role it  
> is to invoke clojure.main/-main. This would relax the current  
> requirement that clojure.jar contain compiled Clojure code. I agree  
> with that suggestion and plan to provide a patch that implements  
> that idea if it's welcome.
>

I am interested in the issues you are trying to address, and thanks  
for volunteering! I'd like to try to focus our efforts on release 1.0.  
Towards that end, it would be nice if your repl code got more  
exercise, which it probably isn't given existing scripts which run  
clojure.lang.Repl. Maybe it would be useful to have that just call  
clojure.main/repl?


Other than that, I think we should hang on to these ideas post 1.0,  
since adding them now doesn't give us enough time to shake them out.  
Do you have a short list of things in this area that need to be fixed  
for 1.0?

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
To unsubscribe from 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: Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-12-11 Thread Bill Clementson

Hi Matt,

On Thu, Dec 11, 2008 at 4:22 PM, mosi  wrote:
>
> it seems I found the tick with swank-clojure, slime and emacs.
>
> Swank/clojure works only if the user is not root. (Or so it seems on
> my linux setup)

Why would you want to run swank-clojure as root? That would be
extremely dangerous.

Bill



> Following your instructions on http://bc.tech.coop/blog/081023.html
> if the user is root, swank-clojure spawns a server listening on a
> given port, and the slime (or for that matter any other program, e.g.
> telnet) cannot connect to the given port.
>
> Nevermind the protocol version, the bug is reproducible with both of
> them, "2008-11-23" and "2008-12-07".
> Installation: debian lenny up-to-date 12/2008.
> Emacs 21, Emacs 22, X or text versions
> Slime from repository and git slime from 12/2008 tested
> swank/clojure "2008-12-07" and newer tested.
>
> I didn`t find out if the bug is in my linux config (no firewall
> installed, no selinux) or in any of the packages (Emacs?)
> It`s probably not slime. Slime works with sbcl and clisp.
> Could anybody confirm/reject my wild assumtions?
>
> Have a nice day,
> mosi
>
> PS: Thanx Feng hou for helping to find out the most basic swank-
> clojure setup. It was not clear from the docs, that the following is
> needed to start:
> (swank/start-server "/dev/null" :port 4005 :dont-close true)
>
> In all the web tutorials the old function name is used.
>
> On Dec 9, 2:10 am, "Bill Clementson"  wrote:
>> On Mon, Dec 8, 2008 at 4:29 PM, mosi  wrote:
>> > thank you for helping the beginners like me with the setup of emacs,
>> > slime and clojure.
>> > I tried first the official method described elsewhere on this forum -
>> > ubuntu linux instructions.
>> > Unsuccessful.
>> > Following your instructions, the same issue, my linux emacs22 gets to
>> > this point:
>>
>> > (add-classpath "file:install/swank-clojure/")
>> > (require (quote swank))
>> > (swank/ignore-protocol-version "2008-11-23")
>> > (swank/start-server "/tmp/slime.10616" :encoding "iso-latin-1-unix")
>> > Clojure
>> > user=> nil
>> > user=> nil
>> > user=> "2008-11-23"
>> > user=> Connection opened on local port  58654
>> > 58654
>> > user=>
>>
>> > And waits for connection. The socket (or a file?) /tmp/slime. does
>> > not exist. Connection time-out causes an error - waiting for slime
>> > session to connect to swank server.
>> > My impression is: the swank server never started. Probably swank-
>> > clojure broken? I have the latest git version as of 07.12.2008.
>> > Any ideas?
>> > thanks a lot.
>> > mosi
>>
>> You said that you followed my instructions; however, the protocol
>> version that prints out in the inferior-lisp buffer is "2008-11-23".
>> In my version of SLIME (which is several days old) the protocol
>> version that prints out in the inferior-lisp buffer is "2008-12-02".
>> If you have a swank-clojure from 07.12.2008, I suspect (at least) your
>> SLIME install is older than that. Therefore, I would suggest that you
>> repeat steps 1-5 (from my original email) to make certain you really
>> have compatible versions of each package.
>>
>> - Bill
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



defining keywords ?

2008-12-11 Thread Robert Koberg

Hi,

Would it be desirable to further define keywords such that it allows a  
special kind of namespacing.

* This could allow for more efficient (for the user) and targeted  
navigation over large, nested collections.
* It would allow for mixing related data that might need to be treated  
in different ways.
* It could provide the building blocks for a collection transformation  
language

For example:

:keyword or :nil:keyword - defines a keyword in a null namespace
   -- keeps backward compatibility
   -- equivalent to the XML element  (no namepsace defined)

::keyword - defines a namespaced keyword in a default namespace
   -- equivalent to the XML element http://some/namespace"/>

:myns:keyword - defines a namespaced keyword in a named namespace
   -- equivalent to the XML element http://some/namespace 
"/>

Perhaps a requirement for this type of thing would be that the  
namespaces need to be declared on the root element of the (nested)  
collection.


what do you think?

best,
-Rob

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Working combination of .emacs, Aquamacs, swank-clojure, clojure-mode?

2008-12-11 Thread mosi

My apologies,
found the error. It was the linux setup.
The portmap daemon was interfering with the swank server.
If the portmap is stopped, everything works fine.
Running everything as a root?
I like to live on the edge of a cliff, gives me a nice buzz high ;-)
You don`t?

Bye,
mosi

On Dec 12, 1:34 am, "Bill Clementson"  wrote:
> Hi mosi,
>
> On Thu, Dec 11, 2008 at 4:22 PM, mosi  wrote:
>
> > it seems I found the tick with swank-clojure, slime and emacs.
>
> > Swank/clojure works only if the user is not root. (Or so it seems on
> > my linux setup)
>
> Why would you want to run swank-clojure as root? That would be
> extremely dangerous.
>
> Bill
>
> > Following your instructions onhttp://bc.tech.coop/blog/081023.html
> > if the user is root, swank-clojure spawns a server listening on a
> > given port, and the slime (or for that matter any other program, e.g.
> > telnet) cannot connect to the given port.
>
> > Nevermind the protocol version, the bug is reproducible with both of
> > them, "2008-11-23" and "2008-12-07".
> > Installation: debian lenny up-to-date 12/2008.
> > Emacs 21, Emacs 22, X or text versions
> > Slime from repository and git slime from 12/2008 tested
> > swank/clojure "2008-12-07" and newer tested.
>
> > I didn`t find out if the bug is in my linux config (no firewall
> > installed, no selinux) or in any of the packages (Emacs?)
> > It`s probably not slime. Slime works with sbcl and clisp.
> > Could anybody confirm/reject my wild assumtions?
>
> > Have a nice day,
> > mosi
>
> > PS: Thanx Feng hou for helping to find out the most basic swank-
> > clojure setup. It was not clear from the docs, that the following is
> > needed to start:
> > (swank/start-server "/dev/null" :port 4005 :dont-close true)
>
> > In all the web tutorials the old function name is used.
>
> > On Dec 9, 2:10 am, "Bill Clementson"  wrote:
> >> On Mon, Dec 8, 2008 at 4:29 PM, mosi  wrote:
> >> > thank you for helping the beginners like me with the setup of emacs,
> >> > slime and clojure.
> >> > I tried first the official method described elsewhere on this forum -
> >> > ubuntu linux instructions.
> >> > Unsuccessful.
> >> > Following your instructions, the same issue, my linux emacs22 gets to
> >> > this point:
>
> >> > (add-classpath "file:install/swank-clojure/")
> >> > (require (quote swank))
> >> > (swank/ignore-protocol-version "2008-11-23")
> >> > (swank/start-server "/tmp/slime.10616" :encoding "iso-latin-1-unix")
> >> > Clojure
> >> > user=> nil
> >> > user=> nil
> >> > user=> "2008-11-23"
> >> > user=> Connection opened on local port  58654
> >> > 58654
> >> > user=>
>
> >> > And waits for connection. The socket (or a file?) /tmp/slime. does
> >> > not exist. Connection time-out causes an error - waiting for slime
> >> > session to connect to swank server.
> >> > My impression is: the swank server never started. Probably swank-
> >> > clojure broken? I have the latest git version as of 07.12.2008.
> >> > Any ideas?
> >> > thanks a lot.
> >> > mosi
>
> >> You said that you followed my instructions; however, the protocol
> >> version that prints out in the inferior-lisp buffer is "2008-11-23".
> >> In my version of SLIME (which is several days old) the protocol
> >> version that prints out in the inferior-lisp buffer is "2008-12-02".
> >> If you have a swank-clojure from 07.12.2008, I suspect (at least) your
> >> SLIME install is older than that. Therefore, I would suggest that you
> >> repeat steps 1-5 (from my original email) to make certain you really
> >> have compatible versions of each package.
>
> >> - Bill
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: why can't I set! stuff in user.clj?

2008-12-11 Thread Stephen C. Gilardi


On Dec 11, 2008, at 7:24 PM, Rich Hickey wrote:


I am interested in the issues you are trying to address, and thanks
for volunteering!


Excellent. You're welcome.


I'd like to try to focus our efforts on release 1.0.


Sounds good.


Towards that end, it would be nice if your repl code got more
exercise, which it probably isn't given existing scripts which run
clojure.lang.Repl. Maybe it would be useful to have that just call
clojure.main/repl?


I think clojure.lang.Repl should translate its args to the new format  
and call clojure.main/-main:


  old: clojure.lang.Repl file1 file2 -- a b c
  new: clojure.main -i file1 -i file2 -r a b c

Similarly for clojure.lang.Script:

  old: clojure.lang.Script file1 file2 file3 -- a b c
  new: clojure.main -i file1 -i file2 file3 a b c


Other than that, I think we should hang on to these ideas post 1.0,
since adding them now doesn't give us enough time to shake them out.
Do you have a short list of things in this area that need to be fixed
for 1.0?


There are the two things I think need to be fixed for 1.0. (If you're  
including [1] below in the set of things you want to defer until  
post-1.0, please veto it.)


[1] Stub launcher written in Java for when clojure.jar contains only  
source code:


  - the new clojure.lang.Repl could fill this role, but I think  
that's not ideal for 1.0


  - Better would be to allow this java command line to work:

  java -cp clojure.jar clojure.main ...

whether or not clojure.jar contains only source code.

We could do this by writing a clojure/main.java that calls  
clojure.main/-main and removing :genclass in clojure/main.clj. I think  
that's a simple change that provides an important flexibility for  
clojure.jar. Adding a "source_jar" target to build.xml would go hand  
in hand with this.


[2] A single "-e" or "--eval" option should be allowed to contain  
multiple forms and it should evaluate them sequentially. There are  
cases where wrapping multiple forms in a "do" does not work and writing


  -e (this) -e (that) -e (the-other)

is tedious compared to

  -e "(this) (that) (the-other)"

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: jEdit Mode for Clojure

2008-12-11 Thread Daniel Spiewak

I merged in all the interesting stuff from David Moss's Clojure jEdit
mode.  We do highlight things in very different colors, but all of the
elements that his recognizes are also recognized by mine now.  Also, I
fixed the annoying issue with def:

(def this)(def that)

The above now highlights correctly.

Feedback is welcome.  I'm certainly willing to change the way things
are highlighted, add highlighting or remove it.

Daniel

On Dec 11, 2:58 pm, Daniel Spiewak  wrote:
> > Hi, just saw this thread. I had made some modifications to the edit mode and
> > uploaded it for inclusion (as a patch) 
> > here:http://sourceforge.net/tracker/index.php?func=detail&aid=2201893&grou...
> > .
>
> > I haven't checked the status in a while as my internet is very intermittent
> > ATM. Please let me know if there is anything missing from it or if I can in
> > any way enhance the mode.
>
> I'll have to take a closer look at your new version.  We probably
> should merge our efforts.  Your mode does do some things that mine
> doesn't, and it doesn't really benefit anyone to have three competing
> Clojure modes.  :-)  My mode is pretty convoluted in the way it uses
> some  tricks to highlight things like (def blah), so it's
> probably easier if I steal your improvements and merge them into
> mine.  I'll give that a try later today and post back with the
> results.
>
> Daniel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: XML Namespaces :xmlns, was Re: xml/parse

2008-12-11 Thread Robert Koberg

Hi,

Given an XML structure like:

http://purl.org/dc/elements/1.1/";  >
   http://www.w3.org/1999/xhtml";>
 A HEAD Title
 A BODY Title
   
   http://www.w3.org/1999/xhtml";>
 A HEAD Title
 A BODY Title
   


which will be parsed by clojure.xml/parse and converted into a nested  
collection.

How would you find the title elements that need to be treated the same  
(those in the xhtml namespace) and those that need to be treated  
different (those in the dublin core namespace)?

Now assume that you don't know what namespace prefix some XML that is  
not in your control will use.

To an XML parser the fragment at position 1 is basically the same as  
the fragment at position 2. Is this the case in clojure?

thanks,
-Rob


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: defining keywords ?

2008-12-11 Thread Chouser
On Thu, Dec 11, 2008 at 7:49 PM, Robert Koberg  wrote:

>
> Hi,
>
> Would it be desirable to further define keywords such that it allows a
> special kind of namespacing.
>
> * This could allow for more efficient (for the user) and targeted
> navigation over large, nested collections.
> * It would allow for mixing related data that might need to be treated
> in different ways.
> * It could provide the building blocks for a collection transformation
> language
>
> For example:
>
> :keyword or :nil:keyword - defines a keyword in a null namespace
>   -- keeps backward compatibility
>   -- equivalent to the XML element  (no namepsace defined)
>
> ::keyword - defines a namespaced keyword in a default namespace
>   -- equivalent to the XML element http://some/namespace"/>
>
> :myns:keyword - defines a namespaced keyword in a named namespace
>   -- equivalent to the XML element http://some/namespace
> "/>
>
> Perhaps a requirement for this type of thing would be that the
> namespaces need to be declared on the root element of the (nested)
> collection.
>

Keywords can already be namespace-qualified:

user=> (namespace :foo)
nil
user=> (namespace :my-ns/foo)
"my-ns"
user=> (namespace ::foo)
"user"

The idea of using this feature to specify XML namespaces has been
discussed.  Rich even adjusted the reader rules to allow fully-qualified
URLs as namespaces:

user=> (namespace :http://n01se.net/chouser/tag)
"http://n01se.net/chouser";

This should allow something to parse XML and produce a tree of Clojure
collections representing it with full namespace qualifications, though to my
knowledge this hasn't been done yet.

--Chouser

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Purpose of memfn?

2008-12-11 Thread Oscar Picasso

On Programming Clojure I read:

> The method-as-function idiom is a common one, so Clojure provides
> the memfn macro to wrap methods for you:

(map (memfn toUpperCase) ["a" "short" "message"])
-> ("A" "SHORT" "MESSAGE")

But one could already write:

(map #(.toUpperCase %) ["a" "short" "message"])
-> ("A" "SHORT" "MESSAGE")

Are they cases where we cannot use the second form and the first is
required?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Purpose of memfn?

2008-12-11 Thread Stuart Halloway

I like the second form better, and may remove memfn from the book  
entirely.

Stuart

> On Programming Clojure I read:
>
>> The method-as-function idiom is a common one, so Clojure provides
>> the memfn macro to wrap methods for you:
>
> (map (memfn toUpperCase) ["a" "short" "message"])
> -> ("A" "SHORT" "MESSAGE")
>
> But one could already write:
>
> (map #(.toUpperCase %) ["a" "short" "message"])
> -> ("A" "SHORT" "MESSAGE")
>
> Are they cases where we cannot use the second form and the first is
> required?
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Purpose of memfn?

2008-12-11 Thread Chouser

On Thu, Dec 11, 2008 at 7:44 PM, Oscar Picasso  wrote:
>
> (map (memfn toUpperCase) ["a" "short" "message"])
> -> ("A" "SHORT" "MESSAGE")
>
> But one could already write:
>
> (map #(.toUpperCase %) ["a" "short" "message"])
> -> ("A" "SHORT" "MESSAGE")
>
> Are they cases where we cannot use the second form and the first is
> required?

'memfn' predates the #(...) syntax and is unnecessary now, I think.

--Chouser

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Swing GUI Builder and Clojure

2008-12-11 Thread wubbie

Hi,
The same hello world did not work for me.
The error msgs are:
(defn hello-world []
  (qt4
   (let [app (QCoreApplication/instance)
 button (new QPushButton "Go Clojure Go")]
 (.. button clicked (connect app "quit()"))
 (doto button
   (resize 250 100)
   (setFont (new QFont "Deja Vu Sans" 18 (.. QFont$Weight Bold
value)))
   (setWindowTitle "Go Clojure Go")
   (show)
java.lang.Exception: Unable to resolve symbol: resize in this context
(NO_SOURCE_FILE:44)


Sun



On Nov 4, 5:26 pm, Brian Carper  wrote:
> On Nov 4, 9:06 am, "Geoffrey Teale"  wrote:
>
> > If you teach the general principles ofClojurethen using any of them should
> > be easy enough.   As Graham said, it's better to stick with the out of the
> > box GUI layer for a general purpose book.  QtJambi was actually a little
> > tricky to set up on my (rather esoteric!) Linux box, and you don't want
> > readers to get pissed off and give up!
>
> I blogged a little aboutQtJambi +Clojurerecently [1], for what
> it's worth.  I found it very easy to set up and use, on Gentoo Linux
> and on Vista.  I'm using it to build an app in my spare time and it's
> working well.  I would be interested to see anyone write up a HOWTO
> for using a GUI builder tool withClojure, for Swing orQtor any
> other framework.  It is a bit tedious to do by hand.
>
> I agree though, for a book it might be better to stick with native
> Java stuff.  No sense needlessly complicating matters with external
> libraries.  QtJambi had a couple of odd quirks that I was unable to
> figure out.  (Randomly killing myClojureprocess under SLIME for
> example.)
>
> [1]http://briancarper.net/2008/10/31/qt4-in-lisp/
>
> --Brian

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Apache Tapestry Creator to Speak on Clojure, Tapestry 5

2008-12-11 Thread Shaguf

Apache Tapestry Creator to Speak on Clojure, Tapestry 5

Bangalore, December 10, 2008: If you are a Java developer building web-
based applications and tired of the countless frameworks that promise
you a slick UI fast but fail to live up to their promise, then switch
to Apache Tapestry to get more functionality with less code. The
creator of Tapestry, Howard Lewis Ship, is coming this summer to
India's biggest summit for the developer ecosystem - Great Indian
Developer Summit (http://www.developersummit.com/) to speak on the
recently released Tapestry 5.0 version, covering the core IoC
container, how to define and inject services and advanced topics such
as decorating services to provide additional concerns, or creating
services in terms of design patterns such as chain-of-command and
pipeline.

On April 25, the author of 'Tapestry in Action' will also conduct a 3-
hour, hands on workshop on  building your own Tapestry applications.
Hew will cover what it means to be a component web framework, what
advantages that brings, how to create database-driven web applications
using Hibernate, show off Tapestry's live class reloading, advanced
error reporting and other productivity features, how Tapestry can be
tuned and customized and build new components.

A frequent speaker at JavaOne, NoFluffJustStuff, ApacheCon Howard will
also throw the spotlight on Clojure -- made up of one part Lisp (one
of the oldest computer languages), one part Java (so young, yet so
well adopted), a healthy serving of functional programming, and a
state-of-the-art concurrency layer on top. Clojure embraces functional
programming with immutable data types and first class functions. It is
fully interoperable with Java. Clojure's approach to concurrency
includes asynchonous Agents, and Software Transactional Memory.

About Great Indian Developer Summit

Great Indian Developer Summit, produced by Saltmarch Media, is the
biggest gathering of software developers from Java/J2EE, Microsoft
computing technologies, Rich Internet Applications (RIA), Web 2.0,
Ajax, Agile, SOA, and Enterprise IT. For both veterans and newcomers
to the world of .NET, Java, and the Rich Web, the Great Indian
Developer Summit provides participants with a well-balanced learning
experience that guaranteed they went back with a richer understanding
of the technologies that make a difference to their careers. See the
GIDS 2008 Red Stripe Report: 
http://www.developersummit.com/2008/report/pdf/Red_Stripe_Report-GIDS08.zip

Over 3000 qualified and talented delegates - Source, attended GIDS
2008: The Hindu - Monday, 26 May 2008 (http://www.developersummit.com/
2008/report/postPress.html). With outstanding educational sessions,
powerhouse speakers, a high-profile award ceremony, GIDS 2009 will
feature premium knowledge, action plans and advise from been-there-
done-it veterans, creators, and visionaries.

For further information on GIDS 2009, please visit the summit on the
web http://www.developersummit.com/.

A Saltmarch Media Press Release
E: i...@developersummit.com
Ph: +91 080 4005 1000

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Venkat Subramaniam to Speak on Debugging Ajax, Agile Development, Test Driven Development in .NET, Programming Groovy

2008-12-11 Thread Shaguf

Venkat Subramaniam to Speak on Debugging Ajax, Agile Development, Test
Driven Development in .NET, Programming Groovy
Great Indian Developer Summit 2009 – India’s Biggest Gathering of
Software Developers

Bangalore, November 24, 2008:  Developing Ajax applications is a lot
of fun, up until things stop working. In addition to the general
programming complexities, you need to deal with browser differences,
JavaScript, and framework idiosyncrasies. alert() often helps only to
get our blood pressure high. Agile practitioner Venkat Subramaniam is
coming back this summer to India's biggest summit for the developer
ecosystem - Great Indian Developer Summit (http://
www.developersummit.com/) with a two-prong approach to debugging Ajax.
The first is a proactive step towards testing and developing Ajax
applications in smaller steps. Second, when bugs still manage to creep
in, exploring what tools can help to fix those bugs and keep your BP
normal at the same time.

The co-author of the award-winning book 'Practices of an Agile
Developer' Grails, along with its facility to develop test driven, is
a killer combination, along with agile development, for rapidly
developing web applications. Venkat will teach how to develop fully
functional web application in Grails while also utilizing other
capabilities like Ajax.

Venkat will be covering some tricky features of Java, those that can
trip you over, and also look at some ways to improve your Java code.
He will also step through the benefits of using Groovy, its features,
how you can take advantage of metaprogramming and intermix with Java.

The founder of Agile Developer, Inc., will also conduct two 3-hour
workshops -- on developing a sample application using Test Driven
Development and; differentiating between different Domain Specific
Languages (DSLs), their characteristics and how to edit, parse, and
validate external DSLs using Java based tools.

About Great Indian Developer Summit
Great Indian Developer Summit, produced by Saltmarch Media is the
biggest gathering of software developers from Java/J2EE, Microsoft
computing technologies, Rich Internet Applications (RIA), Web 2.0,
Ajax, Agile, SOA, and Enterprise IT. For both veterans and newcomers
to the world of .NET, Java, and the Rich Web, the Great Indian
Developer Summit provides participants with a well-balanced learning
experience that guaranteed they went back with a richer understanding
of the technologies that make a difference to their careers. See the
GIDS 2008 Red Stripe Report: 
http://www.developersummit.com/2008/report/pdf/Red_Stripe_Report-GIDS08.zip

Over 3000 qualified and talented delegates attended GIDS 2008 -
Source: The Hindu - Monday, 26 May 2008 (http://
www.developersummit.com/2008/report/postPress.html). With outstanding
educational sessions, powerhouse speakers, a high-profile award
ceremony, GIDS 2009 will feature premium knowledge, action plans and
advise from been-there-done-it veterans, creators, and visionaries.
For further information on GIDS 2009, please visit the summit on the
web http://www.developersummit.com/

A Saltmarch Media Press Release
E: i...@saltmarch.com
Ph: +91 80 4005 1000


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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-seq and other functions

2008-12-11 Thread Oscar Picasso

user> (sort (re-seq #"\w+" "the quick brown fox"))
("brown" "fox" "quick" "the")

but
user> (sort (re-seq #"q(u(i))?" "the quick brown fox"))
(["qui" "ui" "i"])

Why it's not sorted on the later case?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Running out of memory when using filter?

2008-12-11 Thread Mark Engelberg

On Mon, Dec 8, 2008 at 6:51 PM, Rich Hickey  wrote:
I don't have the latest build of Clojure with atoms, so I
reimplemented Rich's filter solution using refs, turning:

> (defn filter
>   [pred coll]
> (let [sa (atom (seq coll))
>   step (fn step []
>   (when-let [s @sa]
> (let [x (first s)]
>   (if (pred x)
> (lazy-cons x (do (swap! sa rest) (step)))
> (do (swap! sa rest)
> (recur))]
>   (step)))
>

into:

(defn safe-filter
  [pred coll]
  (let [sa (ref (seq coll)),
step (fn step []
   (when-let [s @sa]
 (let [x (first s)]
 (if (pred x)
   (lazy-cons x (do
 (dosync (ref-set sa (rest s)))
 (step)))
   (do
 (dosync (ref-set sa (rest s)))
 (recur))]
(step)))

But splode still splodes!:

(defn splode [n]
  (doseq [i (safe-filter #(= % 20) (map inc (range n)))]))

Any idea why the ref version wouldn't be working?

> But it's not pretty. Fortunately, this segues with work I have been
> doing on I/O and generators/streams.

I'm really looking forward to seeing how this all turns out.  Cached
lazy sequences seems to be a bad default for all the standard sequence
operations.  You have to be very careful to not retain the head of one
of these sequences (can't give names to intermediate results, for
example), and it's very hard to predict when the head of one of these
sequences might be unintentionally held.  This seems to make code more
brittle.  Probably the best solution is to default to sequences that
always freshly generate the results, and you have to intentionally
cache the sequence if that is what you want.

Mark

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: defining keywords ?

2008-12-11 Thread Mon Key


cool. was wondering if this was possible the other day myself :)
Good to know RH & crew have accounted for this possibility already.

s_P
On Dec 11, 10:08 pm, Chouser  wrote:
> On Thu, Dec 11, 2008 at 7:49 PM, Robert Koberg  wrote:
>
> > Hi,
>
> > Would it be desirable to further define keywords such that it allows a
> > special kind of namespacing.
>
> > * This could allow for more efficient (for the user) and targeted
> > navigation over large, nested collections.
> > * It would allow for mixing related data that might need to be treated
> > in different ways.
> > * It could provide the building blocks for a collection transformation
> > language
>
> > For example:
>
> > :keyword or :nil:keyword - defines a keyword in a null namespace
> >   -- keeps backward compatibility
> >   -- equivalent to the XML element  (no namepsace defined)
>
> > ::keyword - defines a namespaced keyword in a default namespace
> >   -- equivalent to the XML element http://some/namespace"/>
>
> > :myns:keyword - defines a namespaced keyword in a named namespace
> >   -- equivalent to the XML element http://some/namespace
> > "/>
>
> > Perhaps a requirement for this type of thing would be that the
> > namespaces need to be declared on the root element of the (nested)
> > collection.
>
> Keywords can already be namespace-qualified:
>
> user=> (namespace :foo)
> nil
> user=> (namespace :my-ns/foo)
> "my-ns"
> user=> (namespace ::foo)
> "user"
>
> The idea of using this feature to specify XML namespaces has been
> discussed.  Rich even adjusted the reader rules to allow fully-qualified
> URLs as namespaces:
>
> user=> (namespace :http://n01se.net/chouser/tag)
> "http://n01se.net/chouser";
>
> This should allow something to parse XML and produce a tree of Clojure
> collections representing it with full namespace qualifications, though to my
> knowledge this hasn't been done yet.
>
> --Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: re-seq and other functions

2008-12-11 Thread Stephen C. Gilardi

In the latter case the result is a seq containing a single element:  
the vector. There is nothing to sort/it us sorted.

--Steve


On Dec 12, 2008, at 12:14 AM, Oscar Picasso   
wrote:

>
> user> (sort (re-seq #"\w+" "the quick brown fox"))
> ("brown" "fox" "quick" "the")
>
> but
> user> (sort (re-seq #"q(u(i))?" "the quick brown fox"))
> (["qui" "ui" "i"])
>
> Why it's not sorted on the later case?
>
>
> >

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: frequency of each unique item in collection

2008-12-11 Thread mago

Slightly shorter version:

(defn frequencies
  "Returns a map from distinct items in coll to the number of
times they appear."
  [coll]
 (reduce (fn [counts x]
   (merge-with + counts {x 1}))
  {} coll))

On Dec 11, 9:14 am, Stuart Sierra  wrote:
> I've added a slightly modified version to clojure.contrib.seq-utils:
>
> (defn frequencies
>   "Returns a map from distinct items in coll to the number of times
>   they appear."
>   [coll]
>   (reduce (fn [counts x]
>   (assoc counts x (inc (get counts x 0
>   {} coll))
>
> -Stuart Sierra
>
> On Dec 11, 10:07 am, Dave Griffith  wrote:
>
> > Yup, five bugs by my count.  Not bad for a one-liner. More coffee
> > necessary.
>
> > Same algorithm, but tested.
>
> >  (defn frequencies [coll]
> > (reduce  (fn [map val] (assoc map val (if (contains? map val) (+ 1
> > (get map val)) 1)))  {} coll)
> >  )
>
> > On Dec 11, 9:52 am, Randall R Schulz  wrote:
>
> > > On Thursday 11 December 2008 06:33, Dave Griffith wrote:
>
> > > > On Dec 11, 9:21 am, bOR_  wrote:
> > > > > Hi all,
>
> > > > > I thought I remembered there was a method in the api somewhere that
> > > > > would count the frequency of each unique item in a collection, but
> > > > > I can't find it anymore. What would be a brief way to write that in
> > > > > clojure?
>
> > > > > (In ruby: array.inject(Hash.new(0)) {|hash,key| hash[key] += 1 ;
> > > > > hash})
>
> > > > (defn frequencies [coll]
> > > >  (reduce  (fn [map val] (assoc map val (if (contains map val) (get map 
> > > > val) 1))  #{})
> > > > )
>
> > > Shooting from the hip, eh? There is no "contains", it's "contains?".
> > > There's a missing close parenthesis. I don't see where this is doing any
> > > counting. How does it compute occurrence frequencies?
>
> > > Randall Schulz
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Mon Key

> Clojure does not allow for programmer-defined
> reader macros (unlike other lisps).

I know this has been touched upon last Spring - and Stu Halloway refs
at least one discussion of this in his book.

>From a practical standpoint I am beginning to understand more why the
choice was made to not support reader macros.

But can someone (RH?) clarify the following?

Is it possible to introduce reader macros (albeit unsupported frowned
upon ones).

> You could define a different reader and completely different text-based 
> syntax for the language.

Given the suggestion that Clojure could potentially be reimplemented
with a different text-based syntax utilizing an alternate reader does
this imply that reader macros are possible under a modified REPL?.

>From a purely speculative standpoint, if this is possible - the
assertion that "Clojure does not allow for..." may be misplaced.

I'm wondering to the extent that it *may* be possible to 'Rig the
REPL' where would/does the Clojure license stand on this?

I ask, because I remember reading in one of P. Graham's books '.*
LISP' that some commercial LISPs were/are distributed with exceptions
for calling `eval' at the top level - presumably to prevent one from
modifying the REPL with some combination of macros/reader macros.

Has Clojure taken an alternate approach whereby code distributed under
license simply doesn't permit user defined reader macros?

And if so - would it not be more appropriate to communicate (as a
matter of policy - and stakeholder prudence) - "The Clojure License
agreement doesn't *permit* user introduction of reader macros which
when expanded  at compile time attempt to modify the designer(s)
intended specification of Clojure's REPL"?

I tend to recoil at the use of the phrase, "not allowed", and while
I'm not personally even remotely capable of even beginning an attempt
to endeavor to introduce any sort of modification as envisioned above
I can certainly imagine situations/environments where such an attempt
might be made - advocate(s) of competitive open source license models
being one of the more benign examples...

If I have mis-characterized something or have otherwise misunderstood
the situation/possibilities I apologize.

s_P

On Dec 11, 5:03 pm, Daniel Eklund  wrote:
> > I've been reading the latest chapter from Stuart's book, Chapter 7:
> > Macros, and he makes this statement:
>
> > "Clojure has no special syntax for code. Code is simply Clojure data.
> > This is true for normal functions, but also for special forms and
> > macros. Consider a language with syntax, such as Java. ..."
>
> > It seems to me that just like all lisps, Clojure has syntax.  The
> > first and most obvious piece of syntax is the parenthesises.  Lists
> > start with an open paren and end with a closing paren.  This is syntax
> > and you can't change it with a macro.
>
> I would agree with you, but I do not feel too strongly about the
> matter.  The statement "clojure has _no_ syntax" is probably not
> defensible with an eye towards formal rigor.. I have no idea what a
> syntax-less language would look like.  I feel fairly certain that the
> book's aims are not to provide a hard stance on no-syntax but to open
> the eyes of those people who have been dealing with the Java's and the
> C's for their entire careers, where syntax is locked in by convention
> and grammar specs.
>
> Despite quote and {} and [] being syntax-tic sugar, they certainly
> have their sexp counterparts, and all of this is driven from the
> reader which could possibly be extended or reduced for particular
> needs --  although Clojure does not allow for programmer-defined
> reader macros (unlike other lisps).
>
> The existence of the reader makes the "no syntax" claim a lot easier
> to understand, but in the end, this could be a long discussion about
> what each person feels "syntax" is.
>
> my $0.02

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: Lisp/Clojure doesn't have syntax?

2008-12-11 Thread Mon Key

> Clojure does not allow for programmer-defined
> reader macros (unlike other lisps).

I know this has been touched upon last Spring - and Stu Halloway refs
at least one discussion of this in his book.

>From a practical standpoint I am beginning to understand more why the
choice was made to not support reader macros.

But can someone (RH?) clarify the following?

Is it possible to introduce reader macros (albeit unsupported frowned
upon ones).

> You could define a different reader and completely different text-based 
> syntax for the language.

Given the suggestion that Clojure could potentially be reimplemented
with a different text-based syntax utilizing an alternate reader does
this imply that reader macros are possible under a modified REPL?.

>From a purely speculative standpoint, if this is possible - the
assertion that "Clojure does not allow for..." may be misplaced.

I'm wondering to the extent that it *may* be possible to 'Rig the
REPL' where would/does the Clojure license stand on this?

I ask, because I remember reading in one of P. Graham's books '.*
LISP' that some commercial LISPs were/are distributed with exceptions
for calling `eval' at the top level - presumably to prevent one from
modifying the REPL with some combination of macros/reader macros.

Has Clojure taken an alternate approach whereby code distributed under
license simply doesn't permit user defined reader macros?

And if so - would it not be more appropriate to communicate (as a
matter of policy - and stakeholder prudence) - "The Clojure License
agreement doesn't *permit* user introduction of reader macros which
when expanded  at compile time attempt to modify the designer(s)
intended specification of Clojure's REPL"?

I tend to recoil at the use of the phrase, "not allowed", and while
I'm not personally even remotely capable of even beginning an attempt
to endeavor to introduce any sort of modification as envisioned above
I can certainly imagine situations/environments where such an attempt
might be made - advocate(s) of competitive open source license models
being one of the more benign examples...

If I have mis-characterized something or have otherwise misunderstood
the situation/possibilities I apologize.

s_P

On Dec 11, 5:03 pm, Daniel Eklund  wrote:
> > I've been reading the latest chapter from Stuart's book, Chapter 7:
> > Macros, and he makes this statement:
>
> > "Clojure has no special syntax for code. Code is simply Clojure data.
> > This is true for normal functions, but also for special forms and
> > macros. Consider a language with syntax, such as Java. ..."
>
> > It seems to me that just like all lisps, Clojure has syntax.  The
> > first and most obvious piece of syntax is the parenthesises.  Lists
> > start with an open paren and end with a closing paren.  This is syntax
> > and you can't change it with a macro.
>
> I would agree with you, but I do not feel too strongly about the
> matter.  The statement "clojure has _no_ syntax" is probably not
> defensible with an eye towards formal rigor.. I have no idea what a
> syntax-less language would look like.  I feel fairly certain that the
> book's aims are not to provide a hard stance on no-syntax but to open
> the eyes of those people who have been dealing with the Java's and the
> C's for their entire careers, where syntax is locked in by convention
> and grammar specs.
>
> Despite quote and {} and [] being syntax-tic sugar, they certainly
> have their sexp counterparts, and all of this is driven from the
> reader which could possibly be extended or reduced for particular
> needs --  although Clojure does not allow for programmer-defined
> reader macros (unlike other lisps).
>
> The existence of the reader makes the "no syntax" claim a lot easier
> to understand, but in the end, this could be a long discussion about
> what each person feels "syntax" is.
>
> my $0.02

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Extending deref

2008-12-11 Thread Mark Engelberg

If you wanted to extend deref to new types, is there any way to do
that?  For example, deref of a delay could be equivalent to a force.
Or deref of a Future could invoke the Future's get method.  This would
give you the handy @ reader macro for things that frequently need to
be forced to evaluate further in some way.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---