Don't throw when no *print-fn* is set

Description

Currently calling (enable-console-print!) causes a bunch of code to be retained in :advanced mode even if you never print.

While that is not ideal it doesn't cause runtime errors. Not calling it and trying to print however will throw an exception which will potentially break your app.

So we end up in a no-win situation for :advanced builds where a "forgotten" prn may break your app in production or "maybe" bloating your file size by retaining all the print-related things.

I think the no-print-fn condition should never throw, maybe just try to write a warning using console.log. Or just dropping the prn altogether.

Environment

None

Attachments

1

Activity

Show:

David Nolen July 14, 2017 at 4:06 AM

https://github.com/clojure/clojurescript/commit/797e247fbef676544060a57da995f058db061f37 partially addresses this issue. Keeping this open and moving to lower priority, we should revisit.

Mike Fikes July 14, 2017 at 3:01 AM

The attached CLJS-2002.patch moves the throw to string-print and using nil as the init for the two Vars solves CLJS-2231. But it doesn't address the ticket as written: Leaving an inadvertent prn in your code leads to a call to string-print which throws.

David Nolen July 14, 2017 at 2:29 AM

Let's move the old behavior to `string-print` only.

Details

Assignee

Reporter

Approval

Vetted

Fix versions

Affects versions

Priority

Created April 7, 2017 at 12:11 PM
Updated March 29, 2018 at 7:44 PM