Skip to content

some symbols have inconsistent type and value #37

Closed
jafingerhut opened this Issue May 3, 2012 · 4 comments

2 participants

@jafingerhut
Collaborator

The one example I've seen is clojure.core/print-level

Its first line in the documentation panel when I choose "All" is:

clojure.core/print-length - Var => nil

The type/value section shows up as follows:

TYPE: class clojure.lang.Var

@TYPE:

VALUE:
#

The source code is this:

SOURCE:
(def ^:dynamic
^{:doc "print-length controls how many items of each collection the
printer will print. If it is bound to logical false, there is no
limit. Otherwise, it must be bound to an integer indicating the maximum
number of items of each collection to print. If a collection contains
more items, the printer will print items up to the limit followed by
'...' to represent the remaining items. The root binding is nil
indicating no limit."
:added "1.0"}
print-length nil)

Everything in the display is consistent with the initial value of nil, except the VALUE is shown as the integer value 32. I think what might be happening here is that print-level is dynamically bound using a 'binding' call somewhere in the REPL initialization code to 32, and somehow the browser code for printing the value is picking up that dynamic binding, but the browser code for printing the type is not. I haven't investigated yet to figure out why that would be, but it would be nice if they were consistent with each other.

It would be very nice if we could somehow show the different values that a dynamic var can have in different JVM threads, but that is a separate and probably much more difficult issue.

@franks42
Owner
@franks42
Owner
@jafingerhut
Collaborator

I'll try this out unless you beat me to it: In pprint-str, assign the value of v to another symbol using 'let' outside of the binding form, then use that other symbol when calling pprint.

@jafingerhut
Collaborator

My idea of using a "let" outside of the "binding" in pprint-str doesn't work, because pprint-str is passed the Var, not the value of the Var. Thus the let saves the Var, which the binding overrides the value of, and pprint still prints the value from the binding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.