r-lib / R6

Encapsulated object-oriented programming for R
https://R6.r-lib.org
Other
412 stars 57 forks source link

print/show method #5

Closed gaborcsardi closed 10 years ago

gaborcsardi commented 10 years ago

Is it omitted by design or it will be added later? I realize that I can define an S3 print method, but that is against the encapsulation.

wch commented 10 years ago

By default print.R6(obj) will simply print out the fields and methods. But I suppose it would be nice to first check for a obj$print method, and use that first, then fall back to the current output. Is that what you had in mind?

gaborcsardi commented 10 years ago

Yes, that's exactly what I meant.

Btw. maybe you can introduce a special prefix for these special methods, e.g. and underscore or a dot. So instead ob obj$print it would be obj$_print, and the namespace of methods is not polluted. Just an idea, not particularly important imo.

wch commented 10 years ago

Implemented in #6.