Skip to content
This repository has been archived by the owner on Jan 28, 2019. It is now read-only.

Var value contracts #81

Open
arrdem opened this issue Mar 2, 2016 · 1 comment
Open

Var value contracts #81

arrdem opened this issue Mar 2, 2016 · 1 comment

Comments

@arrdem
Copy link
Collaborator

arrdem commented Mar 2, 2016

Right now *out* and *err* are required to be Writer instances, and *out* is further assumed by much of clojure/core.clj to be a PrintWriter but there is no internal support for ensuring this. Maybe it'd be appropriate for *out* and *err* to be anonymous extensions of the Var class which provide the PrintWriter contract by wrapping the dereference operation.

Maybe it makes sense to put bind/deref functions on Vars. A bind validator fn would allow *out* and *err* to validate that they are always bound to a Writer instance no matter what users may do, and a deref transform fn would allow RT/getErrPrintWriter to get rolled up into *err*.deref().

@arrdem
Copy link
Collaborator Author

arrdem commented Oct 11, 2016

Really this is more along the line of symbol macros than value contracts. Dynamically scoped vars are one thing, but to really have a value contract you need a pluggable accessor function.

Maybe one answer is that *out* and *err* should be private and that there should be functions for getting the out and error streams, but that's gonna get in the way of output binding like what CIDER does. Not that I have a particular problem with breaking the 90% case which is people who abuse *out* as a convenient place to stash a file handle they can print to.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant