Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Could someone clarify how math functions work?



On 12/19/2014 12:34 AM, Bart Schaefer wrote:
>
> When you define add() with parens ( ) around the function body, you
> are running the function body in a subshell.  The "last arithmetical
> expression evaluated" IN THE CURRENT SHELL is the processing of the
> argument list of the call to add(), which is done left-to-right and
> is therefore "3" in the original example.
Ah, It was indeed obvious to me that it was due to the subshell function
definition. but i wasn't aware of processing the positional parameters
being an arithmetic evaluation, which left me lost as to why the last
argument was the returned value.

Thank you



Messages sorted by: Reverse Date, Date, Thread, Author