scope parameter has effect only on pointers?

Dom DiSc dominikus at scherkl.de
Mon Jun 23 10:37:58 UTC 2025


On Sunday, 22 June 2025 at 15:53:45 UTC, Richard (Rikki) Andrew 
Cattermole wrote:
> An int is a basic type, by itself it can live in a register and 
> does not have a unique memory address.
>
> The location its in on the stack is irrelevant unless you take 
> a pointer to it. In essence its a implementation detail.
>
> It'll move between locations freely, this is why scope doesn't 
> affect it. Because there is no resource to protect.

I think scope should not be allowed on basic types, as it has no 
effect and is only confusing.
I know, it would be needed to enable generic programming, but I 
find a function that can take both an int and an int* suspect 
anyway - this is kind of too generic for my taste.


More information about the Digitalmars-d-learn mailing list