octave-maintainers
[Top][All Lists]
Advanced

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

Re: Idea: Extension of function / return syntax.


From: Júlio Hoffimann
Subject: Re: Idea: Extension of function / return syntax.
Date: Sun, 6 Jan 2013 23:24:56 -0300


A slight variation of the proposal is that the last statement of the
function could be returned as the return value. This idea is inspired
by Perl. For example, a function could be written as:

function conserved_quantities(m,v)

    energy = 0.5 * m * v * v;
    momentum = m*v:

    [ energy , momentum ]

endfunction


The point is that now there is no need to make changes to the "return"
statement. This idea seems to work well in the Perl world, and it is
at least clean and simple.

What do you think?

Cheers,
Daniel.

I think you missed the main point in having a return statement: return from anywhere in the function body.

IMHO, this is a change that doesn't add major benefits. We want to improve the language, but we shouldn't forget nor misrepresent it's origins. Your mention to Perl is very appropriate, it evolved so much that became incompatible with older releases. Perl 6 is a complete redesign announced in 2000 and still under active development as of 2012.

Best,
Júlio.

reply via email to

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