On Dec 12, 2008, at 11:08 AM, Rich Hickey <richhic...@gmail.com> wrote:
> > On Fri, Dec 12, 2008 at 11:03 AM, Stephen C. Gilardi > <squee...@mac.com> wrote: >> >>>> 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 >>>> >>> >>> Ok, so calls to them won't change but they will delegate to main/ >>> tell. >> >> They will delegate to clojure.main/-main. Then we'll document only >> clojure.main as the way to run a script or launch Clojure's repl. >> >>>> >>>> >>>> >>>> >>>> >>> >>>> [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)" >>>> >>> >>> This (-e) seems rather unimportant, but I wonder when does 'do' not >>> work? >> >> 'do' doesn't work when an early form uses a namespace and a later >> form >> depends on that. >> >> java -cp clojure.jar clojure.main -e "(use 'clojure.set)" -e "(union >> #{:a} #{:b})" >> >> works. >> >> java -cp clojure.jar clojure.main -e "(do (use 'clojure.set) (union >> #{:a} #{:b}))" >> >> fails. >> > I have to say I find calls to use and other multi-step operations as > command-line args baffling. Who needs this? The general use case is Clojure acting as a provider of capabilities that can be leveraged by a larger, external scripting system or environment. With precedent from other similarly useful languages/ platforms like python and perl, the desire is to be flexible in how clojure.main can be given requests to do work or evaluation. There are at least three (arguably) natural ways for clujure.main to get (batch-style) input from the outside world: from a file, from stdin, or from one or more command line args. Only one is strictly necessary as one can always produce a temporary file and use it instead of stdin or command line args. Providing more options makes using Clojure in this role more convenient. I think providing all three is easy to code correctly and easy to explain in docs, so I recommend it. --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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---