I'm obviously all for it...

On Jun 29, 5:53 pm, Rich Hickey <richhic...@gmail.com> wrote:
> On Mon, Jun 29, 2009 at 10:51 AM, Stephen C. Gilardi<squee...@mac.com> wrote:
>
> > On Jun 29, 2009, at 10:11 AM, Nicolas Oury wrote:
>
> >> I am not sure, but I believe it's due to *warn-on-reflection* being
> >> bound by the compiler/REPL before evaluating (set! *warn-on-reflection*
> >> true).
>
> >> When I looked, the REPL was called within a macro 'with-bindings repl'
> >> that expands to
> >> (binding [....
> >>          *warn-on-reflection* ....
> >>        ]
> >>        repl)
>
> >> allowing the execution of REPL to set! *war-on-reflection* and some
> >> other similar vars. (*ns*, *compile-files*, *compile-path*, etc...)
>
> >> I suppose the compiler does a similar thing, but I have never looked.
>
> > That's correct. You can see the vars that are set!-ale in the REPL in:
>
> > user=> (doc clojure.main/with-bindings)
> > -------------------------
> > clojure.main/with-bindings
> > ([& body])
> > Macro
> >  Executes body in the context of thread-local bindings for several vars
> >  that often need to be set!: *ns* *warn-on-reflection* *print-meta*
> >  *print-length* *print-level* *compile-path* *command-line-args* *1
> >  *2 *3 *e
> > nil
>
> > In your own REPL, you could make *math-context* set!-able by launching a new
> > repl wrapped in code that binds *math-context*:
>
> >  user=> (binding [*math-context* *math-context*] (clojure.main/repl))
> >  user=> (set! *math-context* (java.math.MathContext. 4))
> >  #<MathContext precision=4 roundingMode=HALF_UP>
> >  user=> (+ 3 1.55555555M)
> >  4.556M
> >  user=> (set! *math-context* (java.math.MathContext. 6))
> >  #<MathContext precision=6 roundingMode=HALF_UP>
> >  user=> (+ 3 1.55555555M)
> >  4.55556M
> >  user=>
>
> > It seems to me that clojure.main/with-bindings should be enhanced provide a
> > root binding for *math-context* so it's set!-able at the repl.
>
> > Does anyone have any objection to or support for that idea?
>
> Fine by me.
>
> 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
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