The problem is, I think, that everyone will have a slightly different
definition of "interactive environment."  If I run
    java ... clojure.main path/to/file.clj
does that count?  What about
    java ... my.compiled.namespace
?  Or what about a REPL thread inside another application?  Or a
Clojure function invoked from Java code?

The problem isn't even well-defined in Java.  The runtime doesn't
provide an easy way to find out which "main" class started the VM, nor
does it offer a standard way to determine what sort of container your
code is running in.  The assumption seems to be that code should not
care about its environment.

I think the solution is to define your own *environment* var and bind
it where you see fit, wrapping clojure.main if necessary.
-SS


On Sep 3, 11:10 pm, Phil Hagelberg <p...@hagelb.org> wrote:
> I'm finding some situations in my projects where I want to know if the
> code is running from an interactive environment or not.
>
> It would be great if environment developers could agree on a convention
> to signal this. I suggest something like an *environment* variable that
> would be bound to a string describing the program running the current
> instance. These strings would probably look something like a web
> browser's User-Agent string, containing the name and version. I'm not
> totally sold on the word "environment" as it also has some shell-centric
> connotations, so I'm open to other suggestions too.
>
> If it is not bound, you may assume it's either an old build of Clojure
> or it's running straight from the command line or perhaps inside a
> non-clojure-aware application server (like jetty or tomcat). The
> clojure.main/repl function could bind this, and we could get SLIME,
> VimClojure, and other editor/IDE systems to bind it as well.
>
> What do you think? Would that be helpful? I'd be willing to write
> patches for clojure.main/repl as well as SLIME.
>
> -Phil
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to