pyret-lang icon indicating copy to clipboard operation
pyret-lang copied to clipboard

Print more useful info when evaluating a function name (doc strings and annotations)

Open shriram opened this issue 9 years ago • 7 comments

Can we have it so that doc strings and annotations are presented by the REPL? E.g.

> foo
foo :: String * Number -> Tree
consumes a string and number and produces a balanced binary tree of that size and content
<function>

In particular, it is impossible right now to figure out how to use a library function, especially if the documentation isn't accessible (for Horizon items), even though it may very well be sitting right there in the definition.

In other words, right now we're gathering information and gratuitously throwing it away right now. You can find out what the annotations are by misusing the function but, perversely, not without doing so. You can't find out the doc string at all, at least not in any intuitive way.

shriram avatar Dec 24 '15 13:12 shriram

Something more useful should certainly print. Doc strings are a little annoying since they are just strings, with no markup, etc. We could keep annotations around; we'll quickly want very rich rendering of the annotations, especially if they refer to types that aren't in the current module (so that they can be clickable to get more information). But maybe those are reasonable limitations; clearly what you're suggesting is is probably better than what we do now.

We actually used to print the doc string; it was removed in part because of overzealous attempts to remove observations on functions.

It might be nice if things with documentation rendered in a way that we could get to the documentation from them, either inline or linked.

Related: https://github.com/brownplt/pyret-lang/issues/526

jpolitz avatar Dec 24 '15 14:12 jpolitz

Not just overzealous attempts to make functions less observable: it had had measurable consequences for memory usage when every single function stored a copy of its docstring, especially nested closures etc that got created more than O(1) times. This seems like another candidate for stuff that belongs in the metadata for a module, and not in the compiled code of it.

blerner avatar Dec 24 '15 14:12 blerner

Related: #258

schanzer avatar Apr 13 '16 18:04 schanzer

Poking - is this still something we want to track?

schanzer avatar Mar 17 '20 14:03 schanzer

Yes! And I would hope that the new module system may make it easier to do this? @jpolitz @blerner

shriram avatar Mar 17 '20 16:03 shriram

@jpolitz @blerner following up now that modules has landed. Has this become more doable?

schanzer avatar Aug 12 '20 18:08 schanzer

Hmm. Printing annotations might be possible, though still harder than I'd like in all cases (e.g. refinements or other fancy types). We still don't track docstrings through compilation yet. It's not technologically impossible, but it will be fiddly.

blerner avatar Aug 12 '20 18:08 blerner