help-octave
[Top][All Lists]
Advanced

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

Re: Synonym


From: Markus Mützel
Subject: Re: Synonym
Date: Wed, 8 Apr 2020 17:46:19 +0200

Am 08. April 2020 um 15:26 Uhr schrieb "Ian McCallion":
> On Wed, 8 Apr 2020 at 14:20, John W. Eaton 
> <address@hidden[mailto:address@hidden]> wrote:
> > On 4/8/20 7:35 AM, Ian McCallion wrote:
> > > What is the right syntax for providing a function which does nothing
> > > except call another function with the same parameters and returns the
> > > same values back.
> > >
> > > The function below passes the parameters through, but getting returned
> > > values back does not work. I've tried various incantations without success
> > >
> > >     function [varargout] = short(varargin)
> > >         varargout = verylongame(varargin){:})
> > >      endfunction
> >
> > Try
> > 
> >    function varargout = short (varargin)
> >     varargout = cell (nargout, 1);
> >      [varargout{:}] = verylongname (varargin{:});
> >    endfunction
> > 
> > Then verylongname will see the same value for nargout that short does
> > when it is called.  There are some forwarding functions like this in
> > Octave.  For example, bar.m and barh.m both forward to an internal
> > function private/__bar__.m.
> 
> Magic, thank you!!  I KNEW there should have been an appropriate syntax, but 
> it had not occurred to me to initialise varargout to an appropriate sized 
> cell array first.

I don't think it is necessary to initialize varargout. It should be initialized 
to the correct length. [1]
This should be enough:

function varargout = short (varargin)
  [varargout{:}] = verylongname (varargin{:});
endfunction


If it isn't, please report an incompatibility bug.

Markus

[1]: https://de.mathworks.com/help/matlab/ref/varargout.html
 



reply via email to

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