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: Benjamin Kowarsch
Subject: Re: Design philosophy - why use a VAR for a single return value?
Date: Sat, 23 Mar 2024 08:33:07 +0900



On Sat, 23 Mar 2024 at 08:20, Alice Osako wrote:
Unfortunately, neither PIM nor ISO provide pass by immutable reference.

We fixed this flaw in M2R10 by adding CONST for passing by immutable reference.

I see the point of this, sure, but I don't see how it is relevant in this instance.
The reason why you may want to use VAR is efficiency, since passing a pointer is faster than copying a larger data structure.

I understand that, yes. However, in this case all of the parameters were CARDINALs. That argument doesn't hold water for those.

I don't use VAR parameters in any of the functions.

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.

regards
benjamin

 

 

reply via email to

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