From bug-octave-request at bevo dot che dot wisc dot edu Thu Jan 22 20:43:35 2004 Subject: unintended consequences of nargin changes From: "John W. Eaton" To: Quentin Spencer Cc: bug-octave at bevo dot che dot wisc dot edu Date: Thu, 22 Jan 2004 20:42:37 -0600 On 22-Jan-2004, Quentin Spencer wrote: | The recent changes to nargin in CVS broke code in the octave-forge | legend function that uses the syntax: | nargin-- | This now gives the following result: | error: evaluating postfix operator `--' near line 137, column 11 | | Replacing this statement with "nargin = nargin-1" works, but if this | syntax is used anywhere else, it will break. Ugh. I see that the Octave manual has some example code that uses --nargin and nargin--, and nargin-- is used in three of Octave's plotting functions. To implement the new nargin and nargout functions, I introduced new automatic variables, __nargin__ and __nargout__, so you could write __nargin__--; Or, you could also write nargin = nargin (); before anything else and then use nargin--; but that is somewhat ugly as well (perhaps using a name different from nargin for the variable would make it look better). I don't think it will work to leave the old automatic variable names in place, because then it won't work to write function foo () nargin ('some_fun') endfunction because if the automatic variables named nargin and nargout are installed in the function symbol table, they will be found instead of the nargin and nargout functions. I'd be willing to undo this change, but then we will probably have other people complaining about the incompatibility later. Suggestions? jwe ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------