Support for overriding object printing

Description

There appears to be a regression introduced somewhere along the line that prevents overriding the printing of objects. (If you look in the code history you can see that this was previously possible.)

Whatever the root cause, we currently have a check for implements? in pr-writer-impl but not a check for satisfies? before the object? branch is taken, which prevents code like the following from working:

In Clojure, you can override the printing of objects with code like

Any associated tests should go in the cljs.extend-to-object-test namespace.

Environment

None

Attachments

1

Activity

Show:

Mike Fikes July 9, 2018 at 7:38 PM

The production change in attached patch simply switches from using implements? to satisfies?.

A couple of negatives associated with this is that

  1. It would slow down printing a little relative to perhaps a targeted check for satisfies? placed in the object? branch.

  2. It broadens the scope of this ticket from the focus of "extend to object" to essentially "extend to native"

Conversely, in Clojure you can evidently override the printing of numbers and the like, so perhaps this patch would meet any needs along these lines, so long as perf is acceptable.

If desired, I could make a variant patch that puts the satisfies? check in the object? branch.

Completed

Details

Assignee

Reporter

Approval

Accepted

Patch

Code and Test

Priority

Created July 9, 2018 at 6:29 PM
Updated July 10, 2018 at 1:56 AM
Resolved July 10, 2018 at 1:56 AM