help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: override display() for class


From: bpabbott
Subject: Re: override display() for class
Date: Mon, 13 Dec 2010 18:46:34 +0000 (GMT)

On Dec 13, 2010, at 11:37 AM, "John W. Eaton" <address@hidden> wrote:

On 13-Dec-2010, Ben Abbott wrote:

| On Dec 13, 2010, at 5:01 AM, CdeMills wrote:
|
| >
| > Jaroslav Hajek-2 wrote:
| >>
| >>
| >> What you need is possible using "argn". Check out the dict class from
| >> the general package to find out how to do this.
| >>
| >>
| > argn is not documented. Is it the same as inputname(1) ?
| >
| > Regards
| >
| > Pascal
|
| I've been following along. For ...
|
| a = fun (30, b, c);
|
| argn () can be used to obtain the character representations for the inputs.
|
| argn(1,:) -> "30"
| argn(2,:) -> "b "
| argn(3,:) -> "c "
|
| If you edit inputname.m, you'll see that it relies upon argn.
|
| I'd also noticed that argn is not documented. A good place for that
| could be with similar features, such as varargout, nargin, & nargout
| ... and/or as part of the OOP.

I think argn should probably be left undocumented.

Also, although the current situation is that Octave does not print the
variable name for object assignments, perhaps it should. Also, I see
here:

http://www.mathworks.com/help/techdoc/matlab_oop/f3-28024.html

that the most recent version of Matlab may have also changed this
behavior. However, it also looks like that may be describing the
newer style of value classes defined with classdef, not the older kind
that Octave supports.

So, hmm. If we change this behavior then people will probably
complain that Octave is incompatible with Matlab for value objects
defined using the old-style of @CLASSNAME with one function per file.
I guess for that, you are stuck using inputname. You might want to
consider checking to see whether inputname returns an empty string,
and if it does, print "ans =" instead.

jwe

Matlab's old OOP seems to behave the same as Octave. Meaning it does not print the variable name when display is called.

I wrote a simple class with display() overloaded. Both Octave and Matlab return "ans" for  inputname(1) if there is no RHS variable.

Ben.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]