in; scope; scope ref; DIP1000; documentation

James Blachly james.blachly at gmail.com
Thu Aug 27 18:49:19 UTC 2020


Peeling off from Mathias Lang's thread in General about making 
'in' useful, for some novice questions:


1. The thread involves 'in' qualifier. Documentation 
(https://dlang.org/spec/function.html#param-storage) indicates 
that `in` is defined as `scope const` and should not be used as 
it is not implemented. **Is this [fact and recommendation] still 
true?**


2. Regarding scope:

On 8/5/20 3:27 AM, Fynn Schröder wrote:
> On Friday, 31 July 2020 at 21:49:25 UTC, Mathias LANG wrote:
>> I hope this will generate interest with people hitting the 
>> same problem.
> 
> I've literally yesterday written some new code with `const 
> scope ref` in almost every function to pass large, complex 
> structs. Occasionally, I had to store rvalues temporarily to 
> pass as lvalues (non-templated code). I would rather simply put 
> `in` on those parameters :-) It's a lot easier to grasp 
> function signatures only using `in` and `out` on parameters 
> (and their effect/purpose being immediately obvious to new D 
> programmers!)

Is "scope ref" documented somewhere specifically? I found 
https://dlang.org/spec/function.html#scope-parameters which 
discusses the use of `scope` with ref type parameters, but the 
example given is pointer-based. Is it correct that `scope ref T` 
behaves the same as `scope T*` ?

Regarding `scope` more generally, DIP1000 shows as "superseded" 
-- **can I still rely on this document for guidance?** We have a 
`-dip1000` flag but a superseded DIP. The discordance is 
extremely confusing.


I am glad D is iterating quickly and improving on safety, but I 
have found that documentation may not well recent changes in this 
area. Consequently I am reluctant to use (newer) features related 
to memory safety. If this is all comprehensively documented 
somewhere please let me know!



More information about the Digitalmars-d-learn mailing list