r-lib / R6

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

Print method for displaying instances on the screen #6

Closed gaborcsardi closed 10 years ago

gaborcsardi commented 10 years ago

The public print() method of an instance is called, if present, from print.R6, the generic R6 print method. This way classes can define how they want their instances printed.

This is for #5. If you think it is OK this way, then I can also add this feature to the manual and the README.

wch commented 10 years ago

Looks pretty good. It would probably be best to add this to the intro - maybe add a new section for topics like this that are not super basic?

I don't think this needs anything in the README, but it would be good to have something in the help for R6Class. An entry in NEWS would also be good.

gaborcsardi commented 10 years ago

Yes, sorry, I meant the Intro, not the README. So I'll

So the name print without any prefix is fine, I suppose? After all the other special function initialize does not have a special prefix either.

wch commented 10 years ago

Great, thanks. I think using just print is good -- it keeps things simple, and the problem that is solved by adding an underscore (a name clash) is pretty uncommon and easy to work around.

gaborcsardi commented 10 years ago

OK, all done. Maybe you want to add #7 and #8 first, and then I can rebase this PR.

gaborcsardi commented 10 years ago

OK, I'll rebase in a minute.

wch commented 10 years ago

No worries, I actually fixed it up myself.

gaborcsardi commented 10 years ago

OK, thanks!