anmonteiro / lumo

Fast, cross-platform, standalone ClojureScript environment
Eclipse Public License 1.0
1.88k stars 85 forks source link

Expose *lumo-version* #174

Closed arichiardi closed 7 years ago

arichiardi commented 7 years ago

Hello Antonio!

So by working on inf-clojure I stumbled across an issue (https://github.com/clojure-emacs/inf-clojure/issues/79) where I'd a single-instruction, as less invasive as possible flag that signals that we are in a lumo repl. Bozhidar was suggesting something akin to *clojure-version*.

The problem is that (as per Slack conversation) at the moment I need to require lumo.core in order to achieve that:

cljs.user=> (do (require '[lumo.core :refer [*lumo-version*]]) *lumo-version*)
"1.5.0"

The above is fine, but deviates a bit from a normal clojure repl:

REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.9.0-alpha14
OpenJDK 64-Bit Server VM 1.8.0_131-8u131-b11-0ubuntu1.16.04.2-b11
        Exit: Control+D or (exit) or (quit)
    Commands: (user/help)
        Docs: (doc function-name-here)
              (find-doc "part-of-name-here")
Find by Name: (find-name "part-of-name-here")
      Source: (source function-name-here)
     Javadoc: (javadoc java-object-or-class-here)
    Examples from clojuredocs.org: [clojuredocs or cdoc]
              (user/clojuredocs name-here)
              (user/clojuredocs "ns-here" "name-here")
boot.user=> *clojure-version*
{:major 1, :minor 9, :incremental 0, :qualifier "alpha14"}

...where the var is exposed directly. In general it would be great if lumo could do the same, either moving *lumo-version* to lumo.repl or auto-referring it.

I am open to PR this one.

arichiardi commented 7 years ago

Yes I will need to add both to inf-clojure but it would be better not to have to require a namespace just for exposing one var.

The problem is that the form will be evaluated in a clj repl where the require will fail...I will need to parse the failed message as text, not fun.

Hence the need of this issue...If we can follow Clojure's convention that exposes it straight up at repl it is better and easier for inf-clojure.

What do you both folks think? Can we coordinate that?

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

anmonteiro commented 7 years ago

That doesn't seem like a strong enough argument to me. You'll also get an error for an inexistent var if we auto refer, so I see absolutely no difference

arichiardi commented 7 years ago

True, it seems there should be a common way for clj, Lumo and Planck to advertise their "type". Unrepl would have that. I need to find something in order to sminolve this problem. Maybe we could expose a *clojure-version* that adds a key to the current major, minor, patch?

anmonteiro commented 7 years ago

I don't understand what you mean. I strongly disagree with adding a *clojure-version* var to Lumo

mfikes commented 7 years ago

Related: mfikes/planck#466 and #111

arichiardi commented 7 years ago

Ok, fair. At this point it looks like it would be too much of an effort for me to drive this towards what inf-clojure needs. Probably patching inf-clojure would be easier, but I will try again.

What I need is basically a var, the name is not important here, that is present in all repls and describes the repl type.

Something so that I can do:

boot.user=> *repl-type*
"lumo"

The concept of a more generic :about is also present in unrepl, some sort of way to advertize what the repl is and what the capabilities are. Details here: https://github.com/cgrand/unrepl#unreplhello

anmonteiro commented 7 years ago

I'm not in a rush to find a solution. I'm sure we can come up with something that satisfies every use case

arichiardi commented 7 years ago

I am in a bit more of a rush because now inf-clojure fails badly :smile:

anmonteiro commented 7 years ago

@arichiardi sorry, but if you want an immediate solution I'd encourage you to go with (do (require '[lumo.core :refer [*lumo-version*]]) *lumo-version*).

Otherwise I'm going to close this issue and track the progress in #111 .

arichiardi commented 7 years ago

Yep this feels like not the right solution anyways.