scope as storage class

bearophile bearophileHUGS at lycos.com
Thu Sep 27 04:58:26 PDT 2012


Namespace:

> int counter;
>
> void foo(scope int a) {
>     counter = a;
> }
>
> void main() {
>     int num = 42;
>     foo(num);
> }
>
> works fine but I think it should not. So can you explain me the 
> use of scope as a storage class?

Generally such enforcement is not (well) implemented in the dmd 
front-end still. And I think it's mostly meant for reference 
types (class references and raw pointers), so even when it's 
implemented I think it will not give an error in your case.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list