Re: Got a Clojure library?

2009-01-30 Thread Jan Rychter

Dan Larkin  writes:
> Name: clojure-json
> URL: http://github.com/danlarkin/clojure-json/
> Author: Dan Larkin
> Tags: parsing, web, data-interchange
> License: BSD
> Dependencies: clojure-contrib (only for running tests)
> Description:
> A JSON encoder/decoder for clojure.  Supports reading/writing from  
> strings and files, pretty printing and custom encoders for java  
> classes not handled by default. Complete with low memory usage  
> characteristics and best of all... it's fast!

Is this in any way related to JSON code in clojure-contrib? (I guess
not)

Is unification planned?

--J.

> On Jan 29, 2009, at 10:04 AM, Rich Hickey wrote:
>
>>
>> People regularly post here about Clojure libraries they are working
>> on, and it is great to see the explosion of new libs for Clojure!
>>
>> I'd like to try to get a directory of Clojure libs together and up on
>> the Clojure site. Towards that end, I'd appreciate it, if you are the
>> author of a Clojure library (including contrib authors!), you reply in
>> this thread with:
>>
>> The name of your library
>> Library home page URL
>> Your name
>> Category (db, web, UI, parsing etc)
>> License
>> A one-paragraph description. Include 3rd party dependencies if any.
>>
>> (did I miss anything important?)
>>
>> Thanks!
>>
>> 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: Got a Clojure library?

2009-01-30 Thread Stuart Halloway

Lancet
http://github.com/stuarthalloway/lancet
Stuart Halloway
Developer tool
Same License as Clojure
Lancet is a build tool like Ant or Rake. Lancet makes it easy to  
create build targets: any Clojure function can be a build target.  
Lancet can call Ant tasks, or shell out and call other processes.

Programming Clojure
http://github.com/stuarthalloway/programming-clojure
Stuart Halloway
Educational
Same License as Clojure
Sample code for the book "Programming Clojure"  
(http://www.pragprog.com/titles/shcloj/programming-clojure 
)

All of my libraries (now and probably in the future) depend on clojure- 
contrib. Does that even count as third-party?

> The name of your library
> Library home page URL
> Your name
> Category (db, web, UI, parsing etc)
> License
> A one-paragraph description. Include 3rd party dependencies if any.


--~--~-~--~~~---~--~~
You 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: Distributed Clojure

2009-01-30 Thread hank williams
On Thu, Jan 29, 2009 at 7:28 PM, Greg Harman  wrote:

>
> Hank:
>
> I have looked at TC in the past, and took another look today at your
> suggestion. Terracotta certainly seems to have promise feature-wise,
> but I have to admit it's a "heavier" solution than I had been thinking
> of, and there are probably all sorts of gotchas (and reviewing old
> threads on the topic, a few are hinted at) when it comes to
> distributing some of Clojure's concurrency data structures in the
> shared-memory approach.
>


Of course until someone tries we won't know where the limitations are for
sure. But my thought is that even if terracotta turns out not to be ideal as
a mechanism to implement everything, as I see it, the terracotta feature set
(or hazelcast) is critical to anything like this, and I can't see
re-engineering all that work because you need/want certain things that may
need to be done outside it. Regarding it being "heavier", my feeling is that
for what is really needed, it really is a "heavy" problem.

Hank



>
> Kevin:
>
> I hadn't heard of Hadoop before, but at first glance it's exactly what
> I'm looking for. (Thanks!) The problem I am working on is a processing
> pipeline for massive data sets, and that seems to be the advertised
> use case for Hadoop.
>
> On Jan 29, 7:14 pm, Kevin Downey  wrote:
> > have you looked at the available java frameworks like hadoop? there is
> > also some kind of java interface to erlang
> > instead of reinventing the wheel again...
> >
> >
> >
> > On Thu, Jan 29, 2009 at 6:15 AM, Greg Harman  wrote:
> >
> > > One of Clojure's big selling points (obviously) is the support for
> > > concurrent programming. However, the performance gains you get with
> > > this concurrency hits a scalability wall once you're fully utilizing
> > > all the cores available in your server. The next step, of course, is
> > > to add additional servers.
> >
> > > So, I've been mulling over the idea of putting together a framework
> > > for distributed applications. I think it should deal with issues such
> > > as:
> >
> > > * Locating, assessing, and registering CPUs
> > > * Division of large jobs into smaller sub-jobs
> > > * Dispatching of jobs, including optimization planning (send more jobs
> > > to faster CPUs)
> > > * Failure recovery
> > > * Seamless code integration (so that this can be retrofit as an
> > > optimization) both "horizontally" and "vertically"
> > >   * Horizontal = take one time-consuming task and parallelize it
> > >   * Vertical = take two sequential tasks and pipeline them across
> > > different servers
> >
> > > Is anybody already working on something similar? Is this already on
> > > the Clojure language roadmap as something to be added after 1.0?
> >
> > > Any design advice or feature requests if I were to put something like
> > > this together?
> >
> > > -Greg
> >
> > --
> > And what is good, Phaedrus,
> > And what is not good—
> > Need we ask anyone to tell us these things?
> >
>


-- 
blog: whydoeseverythingsuck.com

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

2009-01-30 Thread Tom Ayerst
I think you have to decide what you are aiming for.  Is this a "solution" or
another tool in the toolkit.  I think Rich noted a while back that Clojure
can access many distribution technologies.  So if you want a solution right
now you can wrap one of those up and off you go.

If you want a "distributed clojure" you need to spend a little time working
out the most appropriate abstraction for Clojure to use (This is where Rich
excels IMHO, he always has a well thought out, coherent set of abstractions
he wants to support and is ruthless in trading things off against them).

So may question would be, how should Clojure do parallel computation? rather
than what features should it have?  Then you can see what is available for
leverage.

For example, if you think the best parallel abstraction for Clojure is CSP
because the implecations are well understood then you could look at JCSP as
an initial implementation.  If you think an Actor model is better then find
an Actor implementation.

(My own predjudice is to stick with a pure java toolkit with a simple
install rather than a load of dependencies)

Just my c/2.

Cheers

Tom

2009/1/30 Kevin Downey 

>
> have you looked at the available java frameworks like hadoop? there is
> also some kind of java interface to erlang
> instead of reinventing the wheel again...
>
> On Thu, Jan 29, 2009 at 6:15 AM, Greg Harman  wrote:
> >
> > One of Clojure's big selling points (obviously) is the support for
> > concurrent programming. However, the performance gains you get with
> > this concurrency hits a scalability wall once you're fully utilizing
> > all the cores available in your server. The next step, of course, is
> > to add additional servers.
> >
> > So, I've been mulling over the idea of putting together a framework
> > for distributed applications. I think it should deal with issues such
> > as:
> >
> > * Locating, assessing, and registering CPUs
> > * Division of large jobs into smaller sub-jobs
> > * Dispatching of jobs, including optimization planning (send more jobs
> > to faster CPUs)
> > * Failure recovery
> > * Seamless code integration (so that this can be retrofit as an
> > optimization) both "horizontally" and "vertically"
> >   * Horizontal = take one time-consuming task and parallelize it
> >   * Vertical = take two sequential tasks and pipeline them across
> > different servers
> >
> > Is anybody already working on something similar? Is this already on
> > the Clojure language roadmap as something to be added after 1.0?
> >
> > Any design advice or feature requests if I were to put something like
> > this together?
> >
> > -Greg
> > >
>
>
>
> --
> 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: Alternatives to contains?

2009-01-30 Thread Mark Volkmann

On Thu, Jan 29, 2009 at 5:23 PM, Achim Passen  wrote:
> Hi!
> Am 29.01.2009 um 23:52 schrieb Mark Volkmann:
>
> I'd like for that to be moved to core so I don't have to load it ...
> which is also verbose for something that is commonly needed.
>
> "includes?" being commonly needed might indicate that people really should
> be using sets instead of lists or vectors in these cases. Sets are the only
> data structures that provide efficient contains?(-value), plus contains?
> works as expected with sets.
> My guess is that the omission of includes? in core is not an oversight after
> all, but an incentive to pick the right data structure for the task at hand.

Embarassingly, I hadn't even considered that option. I'm happy with
the following.

user=> (def s #{"a" "c" "d" "m"})
#'user/s
user=> (contains? s "d")
true
user=> (contains? s "e")
false

You're right. I was using a vector where I should have used a set.

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~-~--~~~---~--~~
You 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: Cells using agents and watchers

2009-01-30 Thread Timothy Pratley

Hi Stuart,

On Jan 30, 1:43 pm, Stuart Sierra  wrote:
> I have put together a another implementation of Cells.

Cool!

One of the things I really like about Cells is that it can really take
the pain out of MVC style GUI building:
http://github.com/timothypratley/strive/blob/8285ef1419601411797205de0d60a2b2c0b71be0/src/clj/cells.clj
should demonstrate better than I can articulate.
To me that's an exciting aspect of cells, but also difficult to cover:
watching-label is quite useful, but people might wish to use a wider
range of controls which would need similar helpers. I'd be interested
in your thoughts on the matter, and whether you think there is scope
to include watching-label and/or similar.


> The idea is the same as Cells. You create a special variable (an "auto-
> agent") whose value is defined by an expression. Whenever one of the
> other variables (agent, atom, or ref) referenced in the expression
> changes its value, the expression is automatically reevaluated and the
> value of the auto-agent is updated.

Nice code - very useful.


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: Got a Clojure library?

2009-01-30 Thread Krešimir


Author: Krešimir Šojat
URL: http://bitbucket.org/ksojat/neman/
Name: neman.cells
Category: dataflow
License: CPL 1.0
Description:
Cell are reference types that automaticly update there value whenever
value of variable they depend on is changed. Cell value can depend on
value of another cell, agent, atom, var, reference and any object that
implement clojure.lang.IRef interface. Values can also be updated when
property of normal Java object is changed if object provides some kind
of notification system for property change (like swing or swt
widgets).

Author: Krešimir Šojat
URL: http://bitbucket.org/ksojat/neman/
Name: neman.cli
Category: command line arguments
License: CPL 1.0
Dependencies: apache commons-cli
Description:
Command line argument processing library using Apache commons-cli,
supports automatic help generation, optional arguments and short and
long argument names.

Author: Krešimir Šojat
URL: http://bitbucket.org/ksojat/neman/
Name: neman.core
Category: object composition
License: CPL 1.0
Description:
Builder macro used for uniform way of constructing large object
compositions like swing guis or XML DOM trees.

Author: Krešimir Šojat
URL: http://bitbucket.org/ksojat/neman/
Name: neman.css
Category: CSS Web
License: CPL 1.0
Description:
Simple library for generation CSS files from Clojure with support for
conversion of css3 properties to equivalent webkit and mozilla
extensions.

Author: Krešimir Šojat
URL: http://bitbucket.org/ksojat/neman/
Name: neman.jetty
Category: web server, jetty
License: CPL 1.0
Dependencies: jetty
Description:
Helpers for constructing Jetty configurations without using external
Jetty XML files.

Author: Krešimir Šojat
URL: http://bitbucket.org/ksojat/neman/
Name: neman.json
Category: JSON
License: CPL 1.0
Dependencies: jackson
Description:
Fast JSON encoder/decoder using Jackson JSON Processor.

Author: Krešimir Šojat
URL: http://bitbucket.org/ksojat/neman/
Name: neman.web
Category: web
License: CPL 1.0
Dependencies: Jetty, truba
Description:
Simple Web framework based on Jetty web server.

Author: Krešimir Šojat
URL: http://bitbucket.org/ksojat/neman/
Name: neman.xml
Category: xml, html, template engine
License: CPL 1.0
Dependencies: JDOM
Description:
Template engine for xml/html files with template inheritence.

Author: Krešimir Šojat
URL: http://bitbucket.org/ksojat/truba/
Name: truba
Category: meta-clojure
License: CPL 1.0
Dependencies: Ant
Description:
Simple build that will download clojure (and jsr166y), clojure-contrib
and clj-backtrace projects, compile them and install in your local
Apache Ivy repository.

--~--~-~--~~~---~--~~
You 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: Got a Clojure library?

2009-01-30 Thread Rich Hickey

The new library page is here:

http://clojure.org/libraries

Keep 'em coming!

Rich

On Jan 29, 10:04 am, Rich Hickey  wrote:
> People regularly post here about Clojure libraries they are working
> on, and it is great to see the explosion of new libs for Clojure!
>
> I'd like to try to get a directory of Clojure libs together and up on
> the Clojure site. Towards that end, I'd appreciate it, if you are the
> author of a Clojure library (including contrib authors!), you reply in
> this thread with:
>
> The name of your library
> Library home page URL
> Your name
> Category (db, web, UI, parsing etc)
> License
> A one-paragraph description. Include 3rd party dependencies if any.
>
> (did I miss anything important?)
>
> Thanks!
>
> 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: Got a Clojure library?

2009-01-30 Thread Stuart Sierra

Here they are, all these are in contrib. There's also
clojure.contrib.enum, clojure.contrib.import-static, and
clojure.contrib.javalog, which I consider deprecated.
-Stuart Sierra

clojure.contrib.apply-macro
http://code.google.com/p/clojure-contrib/
Stuart Sierra
Category: language extension
License: EPL
A sneaky way to apply a macro as if it were a function.  Mostly for
demonstration purposes.

clojure.contrib.auto-agent
http://code.google.com/p/clojure-contrib/
Stuart Sierra
Category: language extension
License: EPL
Dependencies: clojure.contrib.test-is, clojure.contrib.walk
Cell-like agents that are automatically updated based on a formula.

clojure.contrib.condt
http://code.google.com/p/clojure-contrib/
Stuart Sierra
Category: language extension
License: EPL
Dependencies: clojure-contrib.template
A "case" or "condp"-like macro that tests values using a template
expression.

clojure.contrib.duck-streams
http://code.google.com/p/clojure-contrib/
Stuart Sierra
Category: I/O
License: EPL
Utilities to create Java Readers and Writers out of any reasonable
type, like File, URL, String, etc.

clojure.contrib.fcase
http://code.google.com/p/clojure-contrib/
Stuart Sierra
Category: language extension
License: EPL
Several "case"-like macros using functional predicates.

clojure.contrib.json.read
http://code.google.com/p/clojure-contrib/
Stuart Sierra
Category: JSON
License: EPL
Dependencies: clojure.contrib.test-is
Simple JSON parser in pure Clojure.

clojure.contrib.json.write
http://code.google.com/p/clojure-contrib/
Stuart Sierra
Category: JSON
License: EPL
Dependencies: clojure.contrib.test-is
Simple JSON generator in pure Clojure.

clojure.contrib.prxml
http://code.google.com/p/clojure-contrib/
Stuart Sierra
Category: XML
License: EPL
Dependencies: clojure.contrib.lazy-xml
Compact syntax for generating XML.

clojure.contrib.seq-utils
http://code.google.com/p/clojure-contrib/
Stuart Sierra and others
Category: language utilities
License: EPL
Various utilities for working with sequences.

clojure.contrib.stacktrace
http://code.google.com/p/clojure-contrib/
Stuart Sierra
Category: debugging
License: EPL
Friendlier, more Clojure-oriented stack traces.

clojure.contrib.str-utils
http://code.google.com/p/clojure-contrib/
Stuart Sierra and others
Category: language utilities
License: EPL
Various utilities for working with strings and regular expressions.

clojure.contrib.template
http://code.google.com/p/clojure-contrib/
Stuart Sierra
Category: language extension
License: EPL
Dependencies: clojure-contrib.walk
Macros to create and apply "template expressions" with "holes" that
can be filled in later.

clojure.contrib.test-is
http://code.google.com/p/clojure-contrib/
Stuart Sierra
Category: testing
License: EPL
Dependencies: clojure-contrib.template, clojure.contrib.stacktrace
Unit test framework, with generic "is" assertion macro.  Supports
storing tests as var metadata.

clojure.contrib.trace
http://code.google.com/p/clojure-contrib/
Stuart Sierra
Category: debugging
License: EPL
Dependencies: clojure-contrib
Simple tracing macro to insert debugging messages into code.

clojure.contrib.walk
http://code.google.com/p/clojure-contrib/
Stuart Sierra
Category: language extension
License: EPL
Generic tree walkers for any data structure, with modification and
replacement.  Makes it easy to implement things like macroexpand-all,
which is included as an example.

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



Re: Cells using agents and watchers

2009-01-30 Thread Stuart Sierra

Thanks, Tim, glad you like it.  I agree one of the most interesting
uses for Cells is GUI programming.  I'd love to see a library for
building Swing GUIs this way, although I would want to keep the GUI
functions separate from the cell library itself.

>From the libraries thread, I can see that there are at least two other
implementations of Cell-like libraries, so clearly there's a lot of
interest in this topic.

-Stuart Sierra


On Jan 30, 8:53 am, Timothy Pratley  wrote:
> Hi Stuart,
>
> On Jan 30, 1:43 pm, Stuart Sierra  wrote:
>
> > I have put together a another implementation of Cells.
>
> Cool!
>
> One of the things I really like about Cells is that it can really take
> the pain out of MVC style GUI 
> building:http://github.com/timothypratley/strive/blob/8285ef1419601411797205de...
> should demonstrate better than I can articulate.
> To me that's an exciting aspect of cells, but also difficult to cover:
> watching-label is quite useful, but people might wish to use a wider
> range of controls which would need similar helpers. I'd be interested
> in your thoughts on the matter, and whether you think there is scope
> to include watching-label and/or similar.
>
> > The idea is the same as Cells. You create a special variable (an "auto-
> > agent") whose value is defined by an expression. Whenever one of the
> > other variables (agent, atom, or ref) referenced in the expression
> > changes its value, the expression is automatically reevaluated and the
> > value of the auto-agent is updated.
>
> Nice code - very useful.
>
> 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: time lies, even with doall

2009-01-30 Thread Michael Wood

On Mon, Jan 26, 2009 at 6:24 AM, e  wrote:
> ok, I'll check that stuff out.  Thanks.
>
> It occurs to me this is being compared to something in ruby called
> partition.  I like that name.  "partition-by" ... but maybe it was opted to
> use the simpler name, which I can appreciate.

There is already a function called "partition":

user=> (doc partition)
-
clojure.core/partition
([n coll] [n step coll])
  Returns a lazy sequence of lists of n items each, at offsets step
  apart. If step is not supplied, defaults to n, i.e. the partitions
  do not overlap.
nil
user=> (range 21)
(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20)
user=> (partition 7 (range 21))
((0 1 2 3 4 5 6) (7 8 9 10 11 12 13) (14 15 16 17 18 19 20))
user=> (partition 2 (range 21))
((0 1) (2 3) (4 5) (6 7) (8 9) (10 11) (12 13) (14 15) (16 17) (18 19))
user=> (partition 2 3 (range 21))
((0 1) (3 4) (6 7) (9 10) (12 13) (15 16) (18 19))

Note: If the collection cannot be divided evenly then some elements at
the end are discarded.

-- 
Michael Wood 

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



Re: clojure.contrib.sql and SQL Server = cast exceptions?

2009-01-30 Thread Stephen C. Gilardi

Hi Brian,

On Jan 29, 2009, at 11:03 AM, BrianS wrote:


  Now that I am beginning to really investigate this cool part of the
clojure-contrib library with SQL Server, I have hit the point where I
would like to call parameterized stored procedures, which is why you
said you changed the SQL command from a string to a vector.


The change to a vector was for parameterized queries (using  
PreparedStatement, prepareStatement), not for parameterized calls to  
stored procedures (using CallableStatement, prepareCall). Here's an  
example of the former from clojure.contrib.sql.test:


(defn db-grade-range
  "Print rows describing fruit that are within a grade range"
  [min max]
  (sql/with-connection
   db
   (sql/with-query-results
res
[(str "SELECT name, cost, grade "
  "FROM fruit "
  "WHERE grade >= ? AND grade <= ?")
 min max]
(doseq [rec res]
  (println rec)

I haven't yet tried to work with CallableStatements. In reading about  
them, I see that they need some more setup (registering OUT parameters  
for example) than PreparedStatements do.


At one point, someone did mention needing access to the current  
connection so they could work with them. Since you can call Java  
easily from Clojure, working with a particular case (or a few) should  
be quite doable without specific support from clojure.contrib.sql. If  
you come up with some ideas and suggestions along the lines of with- 
query-results (say, with-call-results) that are generally useful, I'll  
be happy to work on getting them integrated into clojure.contrib.sql.


--Steve



smime.p7s
Description: S/MIME cryptographic signature


Re: Simple Examples of Concurrency?

2009-01-30 Thread wubbie

Hi Telman,

Thanks, I got it.

-sun


On Jan 29, 9:58 pm, Telman Yusupov  wrote:
> Clojure sets the value of this var. If you call this var from REPL it
> will evaluate to nil:
>
> user=> *file*
> nil
>
> If you pass a file to Clojure on the command line, Clojure will set it
> to the location of this file.
>
> For example, create a simple file called test.clj with one line in it:
>
> (println *file*)
>
> Now, go to your shell/command prompt and run this from the directory
> where test.clj is:
>
> java clojure.main test.clj
>
> or run this
>
> java clojure.lang.Script test.clj
>
> - the output will be the value of *file* in both cases.
>
> I assume that your CLASSPATH contains path to clojure.jar, otherwise
> you will have to provide it:
>
> java -cp /path/to/clojure.jar clojure.main test.clj
>
> Cheers,
>
> Telman
>
> On Jan 29, 9:23 pm, wubbie  wrote:
>
> > Hi Telman,
>
> > I know *file* is a built-in global. My question is that how
> > the value of *file* is set in the program.  It is in the first line
> > of the program so I don't know how it's set.
>
> > -sun
>
> > On Jan 29, 7:44 pm, Telman Yusupov  wrote:
>
> > > Hi Sun,
>
> > > *file* seems to be one of the built-in global vars (there is more -
> > > vars like *command-line-args*, *compile-path* and others in core.clj
> > > file).
>
> > > If you really need to see the source of it, look for SOURCE_PATH in
> > > Compiler.java in Clojure's source code in jvm/clojure/lang directory.
>
> > > Cheers,
>
> > > Telman
>
> > > On Jan 29, 1:00 pm, wubbie  wrote:
>
> > > > again I don't know how *file* gets current dir value. Maybe some
> > > > magic?
>
> > > > -sun
>
> > > > On Jan 29, 12:30 pm, Telman Yusupov  wrote:
>
> > > > > I had the same question, that was answered by typing this into REPL:
>
> > > > > user=> (doc *file*)
>
> > > > > Output:
>
> > > > > -
> > > > > clojure.core/*file*
> > > > > nil
> > > > >   The path of the file being evaluated, as a String.
> > > > >   Evaluates to nil when there is no file, eg. in the REPL.
>
> > > > > On Jan 29, 7:03 am, wubbie  wrote:
>
> > > > > > Hello,
>
> > > > > > As you see, java.io.File. construct takes path argument but it is 
> > > > > > the
> > > > > > first line of code and I don't know how *file* gets value of current
> > > > > > directory.
>
> > > > > > #!/usr/bin/env clj
>
> > > > > > (add-classpath (str "file://" (.getParent (java.io.File. *file*))
> > > > > > "/"))
>
> > > > > > (ns mire
> > > > > >   (:use [mire commands player rooms])
> > > > > >   (:use [clojure.contrib server-socket duck-streams]))
> > > > > > 
>
> > > > > > thanks,
> > > > > > sun
>
> > > > > > On Jan 28, 8:05 pm, wubbie  wrote:
>
> > > > > > > Hi,
>
> > > > > > > I see
> > > > > > > (add-classpath (str "file://" (.getParent (java.io.File. *file*))
> > > > > > > "/"))
> > > > > > > in mire.clj.
> > > > > > > What value of *file* is it? I failed to see *file* is assigned at 
> > > > > > > all.
>
> > > > > > > -thanks
> > > > > > > sun
>
>
--~--~-~--~~~---~--~~
You 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
-~--~~~~--~~--~--~---



Object system for Clojure?

2009-01-30 Thread Jan Rychter

There is something I don't understand about Clojure. There are
multimethods (great), but I can't seem to find objects they can operate
on. I come to Clojure from a Common Lisp background, having done a fair
bit of CLOS programming. Mind you, I am not necessarily a fan of overly
complex object hierarchies. But still -- I've been trying and I just
can't seem to make objects in Clojure work.

>From what I read, the reasoning is that Clojure provides extremely
general multimethods where you have to define a dispatch function. On
the object side, there is metadata and you can do with it whatever you
want. But this seems to leave a gaping hole saying "fill me with an
object system". Is the goal for everyone to roll their own?

I'm against overusing objects, but there are things which quite
naturally map into the object-oriented paradigm. Let's take windowing
systems for example -- let's assume you have various kinds of windows,
each with its own unique attributes and attributes which are inherited
(e.g. a window-id attribute is common to all windows). I can't see how
you'd implement that in Clojure when you can't inherit structmap
attributes. How do I build my-special-window which is a kind of window
and also inherits window's window-id attribute? I know how to inherit
behavior, but there is behavior that requires data, and I have no idea
how to store and inherit that data. I looked at merge, but it seems you
can't merge structure basis objects.

Unfortunately, all discussion on Clojure polymorphism, multimethods and
objects that I could find seems to use overly simplified examples (it
really only shows that there are multimethods which can do multiple
dispatch on anything), and doesn't really help. Even Stuart Halloway's
beta "Programming Clojure" book has very simple examples that don't
inherit attributes, just use different type tags for the same
information.

--J.

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



Should the memfn macro be updated for the new Java call convention?

2009-01-30 Thread Everyman

I have been reading through the API examples on:
http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples.

For memfn we have:

(map (memfn charAt i) ["fred" "ethel" "lucy"] [1 2 3])
-> (\r \h \y)

This still works, but I thought that:  charAt aught to be .charAt
following the new Java call changes.

Thoughts?

--~--~-~--~~~---~--~~
You 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: Should the memfn macro be updated for the new Java call convention?

2009-01-30 Thread Christophe Grand

Everyman a écrit :
> I have been reading through the API examples on:
> http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples.
>
> For memfn we have:
>
> (map (memfn charAt i) ["fred" "ethel" "lucy"] [1 2 3])
> -> (\r \h \y)
>
> This still works, but I thought that:  charAt aught to be .charAt
> following the new Java call changes.
>
> Thoughts?
>   

memfn predates anonymous function literals. I think it's better to use 
#(.charAt % i) than (memfn charAt i).

Plus memfn won't let you add type hints on you arg so you can't avoid 
reflective calls.
  #(.charAt #^String % i)

Christophe

--~--~-~--~~~---~--~~
You 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: clojure.contrib.sql and SQL Server = cast exceptions?

2009-01-30 Thread BrianS

Steve

Thanks, this works as described, I am going to look into what it would
take to do a call to a parameterized stored
proc.  BTW, I did get a parameterized SP working, here is my sample
code:

(defn sp-test
  "test of stored procedures"
  [min max]
  (sql/with-connection
   db
   (sql/with-query-results
res
["EXEC ProdIVR.dbo.SelectByGradeRange @lowerRange=?,
@upperRange=?" min max]
(doseq [rec res]
  (println rec)

This works, and is nice, but does not take full advantage of SQL
Server's stored procedure cache, the way a true JDBC call to
a parameterized SP would work, with a PreparedStatement object.  I am
looking into that, to see how I could spec out a "with-call-results"
requirements for addition to clojure-contrib.sql.  Once again, thanks
for your assistance, attention, and efforts.

Brian


On Jan 30, 11:12 am, "Stephen C. Gilardi"  wrote:
> Hi Brian,
>
> On Jan 29, 2009, at 11:03 AM, BrianS wrote:
>
> >   Now that I am beginning to really investigate this cool part of the
> > clojure-contrib library with SQL Server, I have hit the point where I
> > would like to call parameterized stored procedures, which is why you
> > said you changed the SQL command from a string to a vector.
>
> The change to a vector was for parameterized queries (using  
> PreparedStatement, prepareStatement), not for parameterized calls to  
> stored procedures (using CallableStatement, prepareCall). Here's an  
> example of the former from clojure.contrib.sql.test:
>
>         (defn db-grade-range
>           "Print rows describing fruit that are within a grade range"
>           [min max]
>           (sql/with-connection
>            db
>            (sql/with-query-results
>             res
>             [(str "SELECT name, cost, grade "
>                   "FROM fruit "
>                   "WHERE grade >= ? AND grade <= ?")
>              min max]
>             (doseq [rec res]
>               (println rec)
>
> I haven't yet tried to work with CallableStatements. In reading about  
> them, I see that they need some more setup (registering OUT parameters  
> for example) than PreparedStatements do.
>
> At one point, someone did mention needing access to the current  
> connection so they could work with them. Since you can call Java  
> easily from Clojure, working with a particular case (or a few) should  
> be quite doable without specific support from clojure.contrib.sql. If  
> you come up with some ideas and suggestions along the lines of with-
> query-results (say, with-call-results) that are generally useful, I'll  
> be happy to work on getting them integrated into clojure.contrib.sql.
>
> --Steve
>
>  smime.p7s
> 3KViewDownload
--~--~-~--~~~---~--~~
You 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: Object system for Clojure?

2009-01-30 Thread David Nolen
At this point you have to roll your own, I have an experimental thing I plan
on fleshing out temporarily called CLJOS. I've implemented field
inheritance, type inheritance, basic multiple inheritance, basic
introspection.  Search the mailing list for CLJOS and you'll see more
details.  It only took 200 lines of code
You mention in particular field inheritance.  In CLJOS, you can define
default initializers for fields.  When you inherit from a class(es), a look
up table of default initializers is consulted, the values are merged in the
direction of the inheritance chain.

Admittedly, it is a bit of a toy example at this point, but it shows that
without too much effort you could build a very powerful object system based
on structs, and I've already found CLJOS to useful in my own hacking.  In
fact I would be happy to collaborate on something more substantial.
http://github.com/swannodette/cljos/blob/8167d3b58f536f89011a811d270a3cc72a289b1a/cljos.clj

Examples here and here:
http://github.com/swannodette/cljos/blob/8167d3b58f536f89011a811d270a3cc72a289b1a/cljos_example.clj
http://github.com/swannodette/cljos/blob/8167d3b58f536f89011a811d270a3cc72a289b1a/cljos_example_two.clj

Not too many people are doing heavy or fancy GUI related stuff (as far as I
can tell) so I can understand why this hasn't come up often.  I note that
you work with weblocks so I can see where you're coming from and I'm glad
you're bringing it up.

That said, I imagine if a decent, useful, and complete lightweight object
system could be designed I'm sure it could get rolled into clojure-contrib
without too much brouhaha.

On Fri, Jan 30, 2009 at 1:09 PM, Jan Rychter  wrote:

>
> There is something I don't understand about Clojure. There are
> multimethods (great), but I can't seem to find objects they can operate
> on. I come to Clojure from a Common Lisp background, having done a fair
> bit of CLOS programming. Mind you, I am not necessarily a fan of overly
> complex object hierarchies. But still -- I've been trying and I just
> can't seem to make objects in Clojure work.
>
> From what I read, the reasoning is that Clojure provides extremely
> general multimethods where you have to define a dispatch function. On
> the object side, there is metadata and you can do with it whatever you
> want. But this seems to leave a gaping hole saying "fill me with an
> object system". Is the goal for everyone to roll their own?
>
> I'm against overusing objects, but there are things which quite
> naturally map into the object-oriented paradigm. Let's take windowing
> systems for example -- let's assume you have various kinds of windows,
> each with its own unique attributes and attributes which are inherited
> (e.g. a window-id attribute is common to all windows). I can't see how
> you'd implement that in Clojure when you can't inherit structmap
> attributes. How do I build my-special-window which is a kind of window
> and also inherits window's window-id attribute? I know how to inherit
> behavior, but there is behavior that requires data, and I have no idea
> how to store and inherit that data. I looked at merge, but it seems you
> can't merge structure basis objects.
>
> Unfortunately, all discussion on Clojure polymorphism, multimethods and
> objects that I could find seems to use overly simplified examples (it
> really only shows that there are multimethods which can do multiple
> dispatch on anything), and doesn't really help. Even Stuart Halloway's
> beta "Programming Clojure" book has very simple examples that don't
> inherit attributes, just use different type tags for the same
> information.
>
> --J.
>
> >
>

--~--~-~--~~~---~--~~
You 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: Object system for Clojure?

2009-01-30 Thread Stuart Sierra

On Jan 30, 1:09 pm, Jan Rychter  wrote:
> From what I read, the reasoning is that Clojure provides extremely
> general multimethods where you have to define a dispatch function. On
> the object side, there is metadata and you can do with it whatever you
> want. But this seems to leave a gaping hole saying "fill me with an
> object system". Is the goal for everyone to roll their own?

I think the goal is to provide object-like capabilities without
needing actual objects.  The emerging pattern is to use maps, with
a :tag key identifying the type.  Types are usually namespace-
qualified keywords.  You can create any kind of inheritance hierarchy
with "derive".

(defn make-window [id]
  {:tag ::window, :id id})

(defn make-color-window [id color]
  (assoc (make-window id)
:tag ::color-window
:color color))

(derive ::color-window ::window)

(defmulti describe-window :tag)

(defmethod describe-window ::window [w]
  (println "Window with ID" (:id w)))

(defmethod describe-window ::color-window [w]
  (println (:color w) "Window with ID" (:id w)))

(let [w (make-color-window 24 "blue")]
  (describe-window w))
;; => prints "blue window with ID 24"

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



Re: Object system for Clojure?

2009-01-30 Thread Graham Fawcett

On Fri, Jan 30, 2009 at 1:09 PM, Jan Rychter  wrote:

> From what I read, the reasoning is that Clojure provides extremely
> general multimethods where you have to define a dispatch function. On
> the object side, there is metadata and you can do with it whatever you
> want. But this seems to leave a gaping hole saying "fill me with an
> object system". Is the goal for everyone to roll their own?

Hi,

Just curious, have you seen the "a la carte hierarchies" scheme that
Rich worked up last summer?

http://groups.google.com/group/clojure/browse_frm/thread/9cc9926de1bdb128?pli=1

Best,
Graham

--~--~-~--~~~---~--~~
You 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: Object system for Clojure?

2009-01-30 Thread Colin Walters

On Jan 30, 3:16 pm, Stuart Sierra  wrote:
>
> I think the goal is to provide object-like capabilities without
> needing actual objects.

Why is that the goal?  I mean, the JVM provides a well defined, high
performance object oriented system.  Clojure can already generate
classes - the main issue I see looking at the API is that it doesn't
look convenient to make "property bag" classes.

There could be an API like: (class Window :properties [height width])
That could auto-generate constructors and property accessors too.  You
could also have a flag like :immutable which would prevent it from
generating setters, and that would fit in well with Clojure's general
immutability.
--~--~-~--~~~---~--~~
You 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: Object system for Clojure?

2009-01-30 Thread David Nolen
>
> (defn make-window [id]
>  {:tag ::window, :id id})
>
> (defn make-color-window [id color]
>  (assoc (make-window id)
>:tag ::color-window
>:color color))
>
> (derive ::color-window ::window)
>
> (defmulti describe-window :tag)
>
> (defmethod describe-window ::window [w]
>  (println "Window with ID" (:id w)))
>
> (defmethod describe-window ::color-window [w]
>  (println (:color w) "Window with ID" (:id w)))
>
> (let [w (make-color-window 24 "blue")]
>  (describe-window w))
> ;; => prints "blue window with ID 24"


In any fairly large UI system this would become tedious in no time and a hit
on readability.  For example consider building a UI system from scratch for
a JOGL game of even medium complexity in pure Clojure (scrollbars, views,
zoomable views, sprites, physics, icons, buttons, et al.). A higher level
abstraction is required.  I'm not arguing that the language needs to provide
it directly, but at least have the framework in place so that it can be done
via macros (which already is the 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: Object system for Clojure?

2009-01-30 Thread David Nolen
>
> On Jan 30, 3:16 pm, Stuart Sierra  wrote:
> >
> > I think the goal is to provide object-like capabilities without
> > needing actual objects.
>
> Why is that the goal?  I mean, the JVM provides a well defined, high
> performance object oriented system.  Clojure can already generate
> classes - the main issue I see looking at the API is that it doesn't
> look convenient to make "property bag" classes.
>

Except that compared to Clojure's multihierarchy multimethod system, Java's
object system seems a bit, shall we say, weak.  And why program in Java when
you can program in Clojure? Why deal with Java UI interop if you don't
need/want it? Just saying the OP has a valid point.

Perhaps someone wants to build a web based UI framework along the lines of
weblocks.  Perhaps you want to define easily extendable widgets in this UI
framework...

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



Documenting Clojure Code

2009-01-30 Thread Kevin Albrecht

How are people generating HTML or text documentation from their
Clojure code?
--~--~-~--~~~---~--~~
You 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: Documenting Clojure Code

2009-01-30 Thread bOR_

Related.

(defn myfunc
 "a nice description here"
 [coll]
 (apply + coll))

but no

(def myvar
 ; cant do a nice " "description here, even though hash-maps can stand
in for functions.
(hash-map :a 1 :b 3))



On Jan 30, 10:42 pm, Kevin Albrecht  wrote:
> How are people generating HTML or text documentation from their
> Clojure code?
--~--~-~--~~~---~--~~
You 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: Documenting Clojure Code

2009-01-30 Thread Meikel Brandmeyer

Hi,

Am 30.01.2009 um 22:49 schrieb bOR_:


(def myvar
; cant do a nice " "description here, even though hash-maps can stand
in for functions.
(hash-map :a 1 :b 3))


Currently only (def #^{:doc "A Foo"} foo ...) is possible.

Alternatively clojure.contrib.def/defvar:

(defvar foo
  (hash-map :a :b)
  "A Foo")

I'm missing this also in core...

Note that for namespaces und defmulti docstrings are
now available. :)

Sincerely
Meikel



smime.p7s
Description: S/MIME cryptographic signature


Re: Documenting Clojure Code

2009-01-30 Thread Stephen C. Gilardi


On Jan 30, 2009, at 4:49 PM, bOR_ wrote:


(def myvar
; cant do a nice " "description here, even though hash-maps can stand
in for functions.
(hash-map :a 1 :b 3))



clojure.contrib.def/defvar offers some help with that:

-
clojure.contrib.def/defvar
([name] [name init] [name init doc])
Macro
  Defines a var with an optional intializer and doc string

For example:

(defvar myvar
  (hash-map :a 1 :b 3)
  "a nice description here")

This also works:

(def
  #^{:doc "a nice description here"}
  myvar
  (hash-map :a 1 :b 3))

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Clojure Plugin for Netbeans Pre-Alpha Release-20090130

2009-01-30 Thread Ffailla

A new Clojure Plugin for Netbeans is available at
http://code.google.com/p/enclojure-nb-clojure-plugin/.  Some issues
addressed are:

- Enabled Windows support (only Windows XP has been tested)
- Project Support
   * Enabled Clojure Project Run/Debug functionality
   * Clojure Project Debugging support
- REPL Enhancements
   * REPLs can now be created per project
   * REPL std out and std err has been separated into tabs
- Code Completion Enhancements
   * invoke completion --> ctrl+space (also returns results from
hippie completion)
   * search through clojure namespaces/ java Classes --> search-string
+dot
   * get members for a java class --> Class + "/"
   * get clojure functions for a namespace-->  namespace + "/"
   * get clojure.core functions --> ctrl+space or search-string + ctrl
+ space
- Editor Enhancements
   * Lexer bug fixes related to string encoding (regular expression
support will be available in next release)
   * Editor Context Menu displays Clojure Actions
  = Re-Indent (format) code
  = Evaluate Current Expression
  = Load File into REPL
  = Toggle Comments
  = Select Top Clojure Form
  = Select Enclosing Clojure Form
  = Navigate to Start of Clojure Form
  = Navigate to End of Clojure Form
  = Change the REPL namespace to be the namespace defined in the
file

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



improvement: make main.clj not die when exception in --init

2009-01-30 Thread Allen Rohner

A minor annoyance of mine is that clojure.main exits if there is an
exception in an --init file, even if you ask for a repl. i.e.

java -cp clojure.jar clojure.main --init file-with-errors.clj -r

It would be useful to get to the repl so I can read doc strings and
experiment with solutions. I have a patch ready for this.

Allen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from 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: improvement: make main.clj not die when exception in --init

2009-01-30 Thread Stephen C. Gilardi

A minor annoyance of mine is that clojure.main exits if there is an
exception in an --init file, even if you ask for a repl. i.e.



+1 in favor of fixing this.

--Steve



smime.p7s
Description: S/MIME cryptographic signature


Documentation of lazy-cat should contain a warning

2009-01-30 Thread André Thieme

Some minutes ago I found out that there is a mismatch between my
interpretation of lazy-cats docstring and the actual behaviour of that
macro.

Its docstring says:
"Expands to code which yields a lazy sequence of the concatenation
 of the supplied colls.  Each coll expr is not evaluated until it is
needed."

I would expect that in
(take 0 (lazy-cat [(println 10)] [(println 20)]))
no evaluation is needed. If lazy-cat were lazy it would return
immediately,
without concatenating anything.

Maybe the docstring can get modified?
Although I personally see this current behaviour as not correct, while
the
docstring is right.
--~--~-~--~~~---~--~~
You 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: Got a Clojure library?

2009-01-30 Thread Mark Fredrickson

>
Name: Dejcartes
URL: http://www.markmfredrickson.com/code
Category: reporting, UI
License: LGPL
Depends: JFreeChart (included with source)
A wrapper around JFreeChart (jfree.org), a Java graphing/charting  
libraries. Allows use of native Clojure collections in charts (e.g.  
pie charts, scatter plots, histograms, etc).

- Mark Fredrickson
mark.m.fredrick...@gmail.com
http://www.markmfredrickson.com







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

2009-01-30 Thread Kevin Albrecht

Using #^{:doc ...} documents the code, but are there any tools out
there for creating HTML API documentation from the documented code?

Stephen C. Gilardi wrote:
>         (def
>           #^{:doc "a nice description here"}
>           myvar
>           (hash-map :a 1 :b 3))

--~--~-~--~~~---~--~~
You 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: Loading two namespaces that :use each other.

2009-01-30 Thread CuppoJava

Mmm, I could create a third namespace that contained the common
functionality. But it is an artificial separation. If a user read
through the source code, he would think "why is this code separated
into two files, when it's dealing with the same thing?"

Anyway, here's my use-case:
I wrote a sprite_engine.clj file. This file contains the internal
workings of creating and manipulating a graphics engine for different
types of sprites.

Sprites should be defined in their own file. ie. box_sprite.clj,
cursor_sprite.clj, player_sprite.clj.
These sprites :use sprite_engine.clj for some utility methods for
manipulating the sprite_engine.

By default, a sprite_engine has only one sprite. A cursor sprite.
So my sprite_engine.clj :uses cursor_sprite.clj, but my
cursor_sprite.clj also uses sprite_engine.clj.

---sprite_engine.clj--
(ns sprite_engine
  (:uses cursor_sprite))

(defn add_sprite [sprite engine]
  ...)

(defn get_sprite_id [engine]
  ...)

(defn new_sprite_engine []
  ...
  (add_sprite (new_cursor_sprite))
  ...)

--cursor_sprite.clj-
(ns cursor_sprite
  (:uses sprite_engine))

(defn new_cursor_sprite []
  (assign_id (new_sprite_id))
  ...)


So, my code (I think) is pretty well separated in terms of
responsibility. But as it's structured right now, I can't load the
file. Is there an elegant way of going about this?
  -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: Documentation of lazy-cat should contain a warning

2009-01-30 Thread Daniel Renfer

user=> (take 0 (lazy-cat [(println 10)] [(println 20)]))
10
nil

What you see here is not an issue with lazy-cat, but rather an issue
with take. The current implementation of take evaluates one more than
the n passed to it.

So in this case, 1 element of the seq is evaluated and "10" is printed.

I don't know if there is an easy fix for this or not. I assume if
there were, it would probably have been fixed by now.

If this is indeed part of the desired effect of calling take and not
just a side-effect of the current implementation, perhaps we need a
warning on take that it is a tad too eager. I know this has bit myself
and others on more than one occasion.

On Fri, Jan 30, 2009 at 6:55 PM, André Thieme
 wrote:
>
> Some minutes ago I found out that there is a mismatch between my
> interpretation of lazy-cats docstring and the actual behaviour of that
> macro.
>
> Its docstring says:
> "Expands to code which yields a lazy sequence of the concatenation
>  of the supplied colls.  Each coll expr is not evaluated until it is
> needed."
>
> I would expect that in
> (take 0 (lazy-cat [(println 10)] [(println 20)]))
> no evaluation is needed. If lazy-cat were lazy it would return
> immediately,
> without concatenating anything.
>
> Maybe the docstring can get modified?
> Although I personally see this current behaviour as not correct, while
> the
> docstring is right.
> >
>

--~--~-~--~~~---~--~~
You 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: Documentation of lazy-cat should contain a warning

2009-01-30 Thread Jason Wolfe

I think this behavior is as-intended, although I agree that it is
confusing.

The reason for this stems from the fact that lazy-cat returns a seq,
and the only allowed representation for the empty seq is "nil" (i.e.,
Java null).  Thus, lazy-cat must always do enough evaluation to know
whether to return an Object representing a non-empty seq, or nil, even
if you never explicitly ask for any of the elements of the returned
seq.   This means evaluating each of its arguments in turn until it
finds an argument x for which (seq x) is non-nil.

HTH,
Jason

On Jan 30, 3:55 pm, André Thieme  wrote:
> Some minutes ago I found out that there is a mismatch between my
> interpretation of lazy-cats docstring and the actual behaviour of that
> macro.
>
> Its docstring says:
> "Expands to code which yields a lazy sequence of the concatenation
>  of the supplied colls.  Each coll expr is not evaluated until it is
> needed."
>
> I would expect that in
> (take 0 (lazy-cat [(println 10)] [(println 20)]))
> no evaluation is needed. If lazy-cat were lazy it would return
> immediately,
> without concatenating anything.
>
> Maybe the docstring can get modified?
> Although I personally see this current behaviour as not correct, while
> the
> docstring is right.
--~--~-~--~~~---~--~~
You 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: Documentation of lazy-cat should contain a warning

2009-01-30 Thread Jason Wolfe



On Jan 30, 5:44 pm, Daniel Renfer  wrote:
> user=> (take 0 (lazy-cat [(println 10)] [(println 20)]))
> 10
> nil
>
> What you see here is not an issue with lazy-cat, but rather an issue
> with take. The current implementation of take evaluates one more than
> the n passed to it.

Hmm, I don't think this is it. For instance,

(take 0 (lazy-cons (prn "asdf") nil))

prints nothing.  (Lazy-cons doesn't need to evaluate things up-front
like lazy-cat, since lazy-cons always returns a (non-empty) seq with
at least one element).

-Jason
--~--~-~--~~~---~--~~
You 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: Documenting Clojure Code

2009-01-30 Thread Mark McGranaghan

Hi Kevin,

You should try clj-doc:

http://github.com/mmcgrana/clj-doc

clj-doc generates HTML API documentation that is searchable via
JavaScript and includes source snippets for the code that defined each
var.

I update clj-doc tonight to include example docs, just clone my
clj-doc repo and open example/index.html in your browser to see what
the docs look like.

In my update I also made it easier to generate docs for your own sets
of libs: check out the README and let me know if you have any
questions/problems.

I've had clj-doc on hold for a little while as I've been waiting for
various documentation-related features to find their way into core,
especially the ns docstrings. Now that we have most of those (though
(def foo "docstring" :bar) is noticeably missing) I'm going to be
working more on clj-doc.

Hope you find it useful,
- Mark McGranaghan

On Fri, Jan 30, 2009 at 7:31 PM, Kevin Albrecht  wrote:
>
> Using #^{:doc ...} documents the code, but are there any tools out
> there for creating HTML API documentation from the documented code?
>
> Stephen C. Gilardi wrote:
>> (def
>>   #^{:doc "a nice description here"}
>>   myvar
>>   (hash-map :a 1 :b 3))
>
> >
>

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



Bug or desired behavior: "contains?" doesn't seem to work on java.util.Sets.

2009-01-30 Thread Jason Wolfe

While "contains?" treats Clojure maps and java.util.Maps the same, it
doesn't seem to work on java.util.Sets:

user> (let [m (HashMap.)] (.put m "test" "test") (contains? m "test"))
true
user> (let [s (HashSet.)] (.add s "test") (contains? s "test"))
false
user> (let [s (HashSet.)] (.add s "test") (contains? (set s) "test"))
true

Bug or desired behavior?

Thanks,
Jason
--~--~-~--~~~---~--~~
You 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: Questions about a Clojure Datalog

2009-01-30 Thread Jeffrey Straszheim

Doing something like Datalog would be terrific fun.  I might
contribute if there is interest.

I'm not an academic, so most of my contributions would be on a
practical level.  We'd need someone else to provide the deeper aspects
of theory.

I've read Norvig's book, and understand his code, and my database book
(Mollina, Ullman, and Wisdom's) has a chapter on Datalog.

On Jan 29, 8:34 am, Rich Hickey  wrote:
> On Jan 26, 11:44 pm, smanek  wrote:
>
> > Hello all,
>
> > I'm a Common Lisp programmer who has just started learning Clojure. I
> > saw it mentioned online that several members of the existing community
> > were looking for someone to build adatalogfor Clojure: I was
> > wondering what exactly you had in mind?
>
> > Were you thinking of a faithful implementation of the originalDatalog
> > rule/query language?
>
> Yes, plus stratified negation at least.
>
> > Or, if not, what features would you like this
> >datalogto have that aren't present in, say, the toy implementation of
> > Prolog that Norvig defines in PAIP? (See chapter11, if you have a copy
> > handy).
>
> I'd like it to beDatalog, and not Prolog, as I'd prefer the stronger
> guarantees ofDatalog. In particular, I like the fact that clause
> order does not matter, queries will complete, the distinction between
> intensional and extensional etc.
>
> > Or, more to the point, what did you see thisdatalogbeing
> > used for?
>
> As a declarative query/rule language for in-memory use (although
> mappingdatalogqueries to SQL is also possible).
>
> > It seems like this could potentially be a fun little non-trivial
> > problem to get started with Clojure in.
>
> I think so. There are two ways to go depending on one's interests.
>
> One would be a from-scratch Clojure implementation. The other would be
> a Clojure wrapper for IRIS Reasoner:
>
> http://iris-reasoner.org/
>
> Unfortunately I haven't had time to pursue either of these beyond some
> initial exploration, but I think a simple declarative rule engine
> would be a terrific addition to Clojure.
>
> 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
-~--~~~~--~~--~--~---



That Zipper thing

2009-01-30 Thread Jeffrey Straszheim

Does anyone know of a gentle introduction to the Zipper stuff, and how
it is used in Clojure?

Thanks in advance.
--~--~-~--~~~---~--~~
You 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: Documenting Clojure Code

2009-01-30 Thread Daniel E. Renfer

Mark,

Glad to see you are putting some more work into clj-doc again. I tried
compiling it a couple weeks ago, and after I downloaded the 4 or 5
libraries it depended on and fixed some of the references to code that
had been moved, I got an exception when I tried running it. I gave up
after that.

Is clj-doc usable yet, or should I still wait a little bit? Ideally I
would like to be able to include an ant task in my build file that
generates all the documentation for the code in my project much like you
can get in Java-land with javadoc.

Btw, the bookmark I have to your generated clj-doc documentation is
still my prefered way to find the function I'm looking for. Are you
still keeping that up to date, or has it stagnated since you first
announced it?

Mark McGranaghan  writes:
> Hi Kevin,
>
> You should try clj-doc:
>
> http://github.com/mmcgrana/clj-doc
>
> clj-doc generates HTML API documentation that is searchable via
> JavaScript and includes source snippets for the code that defined each
> var.
>
> I update clj-doc tonight to include example docs, just clone my
> clj-doc repo and open example/index.html in your browser to see what
> the docs look like.
>
> In my update I also made it easier to generate docs for your own sets
> of libs: check out the README and let me know if you have any
> questions/problems.
>
> I've had clj-doc on hold for a little while as I've been waiting for
> various documentation-related features to find their way into core,
> especially the ns docstrings. Now that we have most of those (though
> (def foo "docstring" :bar) is noticeably missing) I'm going to be
> working more on clj-doc.
>
> Hope you find it useful,
> - Mark McGranaghan
>

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



Clojure is "not a serious language"

2009-01-30 Thread Jon Harrop


Apologies if you've seen this before but I just thought it was absolutely 
hillarious:

http://www.3ofcoins.net/2009/01/30/common-lisp-clojure-and-seriousness/

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

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



Re: Clojure is "not a serious language"

2009-01-30 Thread David Nolen
Agreed :)

On Fri, Jan 30, 2009 at 11:40 PM, Jon Harrop  wrote:

>
>
> Apologies if you've seen this before but I just thought it was absolutely
> hillarious:
>
> http://www.3ofcoins.net/2009/01/30/common-lisp-clojure-and-seriousness/
>
> --
> Dr Jon Harrop, Flying Frog Consultancy Ltd.
> http://www.ffconsultancy.com/?e
>
> >
>

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