octave-3.0.3 accepts 'function' without 'endfucntion' (or with redundant 'endfunction')
Sergei Steshenko
sergstesh at yahoo.com
Fri Jul 10 16:47:51 CDT 2009
--- On Fri, 7/10/09, David Grundberg <individ at acc.umu.se> wrote:
> From: David Grundberg <individ at acc.umu.se>
> Subject: Re: octave-3.0.3 accepts 'function' without 'endfucntion' (or with redundant 'endfunction')
> To: sergstesh at yahoo.com
> Cc: bug-octave at octave.org
> Date: Friday, July 10, 2009, 2:15 PM
> bug-octave-request at octave.org
> skrev:
> > Message: 2
> > Date: Fri, 10 Jul 2009 08:42:20 -0700 (PDT)
> > From: Sergei Steshenko <sergstesh at yahoo.com>
> >
> >
> > Hello,
> >
> > lately I've been dealing a lot with
> optim-1.0.4/leasqr.m.
> >
> > Looking into its source I came to the conclusion that
> 'endfunction' (or the
> > corresponding 'end') is missing. To be honest, I
> didn't check it very
> > thoroughly.
> >
> > Still, I simply added 'endfunction' and recompiled
> (even quitting/restarting 'octave') - the compilation went
> smooth (no warnings)
> > and the function works as before.
> >
> > Now, if the function indeed has missing
> 'endfunction'/'end', then my addition of it indicates that
> 'octave' parser accepts it, which I think it shouldn't.
> >
> > If 'end' is not missing, then 'octave' parser accepts
> redundant
> > 'endfunction', which I think it shouldn't either.
> >
> > Please note 'leasqr.m' is written in a strange'ish
> manner - lot of semicolons and colons I wouldn't put.
> >
> > Thanks,
> > Sergei.
> >
> Well,
>
> function myFunction()
> #body
>
> is a correct declaration of a function inside the file
> myFunction.m. It is accepted (not without warnings, I think)
> in Matlab, and Octave allows it.
'octave' issues no warnings in case of 'leasqr'.
>
> Other declarations are
>
> function myFunction()
> #body
> end
>
> and
>
> function myFunction()
> #body
> endfunction
>
> where the former in both Matlab and Octave while the latter
> only works in Octave.
>
> The declaration you are talking about
>
> function myFunction()
> #body
> end
> endfunction
>
> with unbalanced ends, is not correct.
>
> David
>
I think that missing 'end'/'endfunction' should always cause warnings.
Thanks,
Sergei.
More information about the Bug-octave
mailing list