gm2
[Top][All Lists]
Advanced

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

Re: Design philosophy - why use a VAR for a single return value?


From: Eric Streit
Subject: Re: Design philosophy - why use a VAR for a single return value?
Date: Tue, 26 Mar 2024 08:00:21 +0100
User-agent: Thunderbird Daily

hi,

I completely agree with Benjamin here : the VAR return parameter is super important : it modifies the value "in place" ; no need for a new variable. (no copy, no waste of memory, few processor cycles). And if possible, it would be an "atomic" operation. (multithreading)

And no confusion between the original one and the new you create if you don't use VAR; they will have different values; and there is no way to know which one is "the one".

Best regards

Eric

On 25/03/2024 23:32, Benjamin Kowarsch wrote:


On Tue, 26 Mar 2024 at 04:08, Tony Wallace wrote:

    I totally support this move.  As a functional programmer this makes
    sense.  If a bit set operation updates variable for example, this can
    be achieved with an assignment to the return value of the function.


You also "totally" ignored my response.

        I used VAR parameters in the set bit and clear bit procedures.
        They are supposed to be destructive.

        And yes, that is for efficiency, because if you use a function
        and then assign the result to the original operand, this would
        result in an additional unnecessary copy operation. If you use
        low-level operations like setting and clearing individual bits,
        there may be quite a lot of bit operations in an inner loop and
        then the copying will add up. And the uses cases for such
        operations are mostly destructive anyway.


I trust this clarifies.
benjamin




reply via email to

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