lilypond-user
[Top][All Lists]
Advanced

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

Re: "procedure" vs. "function"


From: Wols Lists
Subject: Re: "procedure" vs. "function"
Date: Sat, 18 Apr 2015 21:36:08 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0

On 18/04/15 19:56, PMA wrote:
> AFAIK, of our major ancestor languages, only Pascal insisted on a
> literal working
> function-vs-procedure distinction. Did Wirth ever defend this insistence
> (as more
> than a track-keeping enforcer re value-outputting vs
> non-value-outputting code)?

Actually, so did Fortran, I believe.

Note my earlier comment that a function was defined as having a return
value with no side effects. That then permits aggressive compiler
optimisation - if a function is repeatedly called with the same
argument, the compiler can stash the result of the first call away, and
replace subsequent calls with a lookup table. (And given that Fortran
was meant to be fast and maths-like, that behaviour was actually very
sensible ... :-)

But because programmers were bad at writing "proper" functions, this
caused too many bugs and I think it just became accepted that functions
have side effects and such optimisation was not a good idea.

Cheers,
Wol



reply via email to

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