What is the current state of scope and member functions?

Dennis dkorpel at gmail.com
Sun Sep 10 22:15:48 UTC 2023


On Sunday, 10 September 2023 at 21:23:06 UTC, Jonathan M Davis 
wrote:
> in both cases, so this doesn't seem to be a problem with 
> std.traits or my usage of it. Rather, it seems to indicate that 
> not only is scope not being inferred for popFront, but it's 
> being outright ignored when it's used explicitly.

`scope` on a variable is implicitly removed when the variable's 
type has no pointers. This includes the `this` parameter, and 
your example struct has 0 members, so 0 pointers.

I removed this behavior a few months ago for regular parameters 
because checking if the type had pointers caused forward 
reference errors: https://github.com/dlang/dmd/pull/14561

The `this` parameter doesn't cause forward reference errors, but 
perhaps `scope` should also stay there for consistency and 
simplicity.


More information about the Digitalmars-d mailing list