Mercurial > octave
diff libinterp/corefcn/pr-output.cc @ 23410:705361dfe353
doc: disp rather than display should be overloaded (bug #50640, bug #50729).
* doc/interpreter/oop.txi: overhaul sections about object display.
* libinterp/corefcn/pr-output.cc(display): overhaul docstring to emphasize disp
should preferably be overloaded.
author | Kai T. Ohlhus <k.ohlhus@gmail.com> |
---|---|
date | Wed, 19 Apr 2017 01:28:07 +0200 |
parents | d4ef04757ead |
children | e35a5c1233d0 |
line wrap: on
line diff
--- a/libinterp/corefcn/pr-output.cc Wed Apr 19 01:22:23 2017 +0200 +++ b/libinterp/corefcn/pr-output.cc Wed Apr 19 01:28:07 2017 +0200 @@ -3591,18 +3591,23 @@ myobj = myclass (@dots{}) @end example -User-defined classes should overload the @code{display} method and use -@code{inputname} to access the name of the object. Otherwise, Octave -will report only that the object is an instance of its class. +In general, user-defined classes should overload the @code{disp} method to +avoid the default output: @example @group myobj = myclass (@dots{}) - @result{} myobj = <class myclass> + @result{} myobj = + + <class myclass> @end group @end example -@seealso{class, subsref, subsasgn} +When overloading the @code{display} method instead, one has to take care +of properly displaying the object's name. This can be done by using the +@code{inputname} function. + +@seealso{disp, class, subsref, subsasgn} @end deftypefn */) { int nargin = args.length ();