<< Back to previous view

[CLJ-286] *out* being used as java.io.PrintWriter Created: 29/Mar/10  Updated: 14/Oct/10  Resolved: 14/Oct/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.3

Type: Defect
Reporter: Anonymous Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

Approval: Ok

 Description   

There seem to be several places in clojure/contrib where out is being used as a java.io.PrintWriter, despite being documented as of type java.io.Writer
Examples are:

  • The reflection warnings from the compiler
  • Exception printouts from contrib.sql

This causes very confusing errors, when out isn't actually a PrintWriter, for example in a swank repl where it is a StringWriter.

I've created a patch for the reflection warnings, but can't submit it here because of political issues.



 Comments   
Comment by Assembla Importer [ 14/Oct/10 2:27 PM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/286
Attachments:
0001-fix-clojure.main-to-not-assume-that-err-is-a-PrintWr.patch - https://www.assembla.com/spaces/clojure/documents/cEQbXEuiar367beJe5d-aX/download/cEQbXEuiar367beJe5d-aX
0286-out-writer-and-better-pst.patch - https://www.assembla.com/spaces/clojure/documents/b4nAPA16Gr34ZzeJe5cbLA/download/b4nAPA16Gr34ZzeJe5cbLA

Comment by Assembla Importer [ 14/Oct/10 2:27 PM ]

rnewman said: See

https://www.assembla.com/spaces/clojure-contrib/tickets/55-clojure-contrib-sql-expects-*err*-to-be-a-printwriter

and the associated discussion on the group.

Clojure's out is actually intended to be a PrintWriter; it's a documentation issue.

Comment by Assembla Importer [ 14/Oct/10 2:27 PM ]

djpowell said: [file:cEQbXEuiar367beJe5d-aX]: Fix for related printwriter issue

Comment by Assembla Importer [ 14/Oct/10 2:27 PM ]

djpowell said: There was also some discussion that out should not be assumed to be a PrintWriter:

http://groups.google.co.uk/group/clojure-dev/browse_thread/thread/99aa2b3263a0b374?hl=en

I've attached a patch for the related issue of err being assumed to be a PrintWriter. I think this is the only place in clojure itself, although there are other places in contrib.

Comment by Assembla Importer [ 14/Oct/10 2:27 PM ]

stu said: [file:b4nAPA16Gr34ZzeJe5cbLA]

Comment by Assembla Importer [ 14/Oct/10 2:27 PM ]

stu said: Second patch subsumes first, plus two additions

  • applies the same fix to the new pst function
  • improves usability of pst. pst's defaulting for the single-arity case was the opposite of what I expected, and the resulting error message is spectacularly confusing. Since the defaulting could trivially be extended to meet my expectations (pass an exception) without breaking the existing (pass a depth), I made it support both.

I don't like binding out to err, but the entire print plumbing drives you in this direction.

Comment by Assembla Importer [ 14/Oct/10 2:27 PM ]

stu said: Updating tickets (#182, #286)

Generated at Thu Oct 30 12:56:43 CDT 2014 using JIRA 4.4#649-r158309.