Extended Type Design.

Bill Baxter dnewsgroup at billbaxter.com
Fri Mar 16 17:41:29 PDT 2007


Walter Bright wrote:
> kris wrote:
>> BTW, you've also mentioned changing "inout" to "ref" instead? That 
>> would probably break more code than a renaming of const; I know both 
>> Tango and Mango use inout quite a bit, but I'm happy to change those 
>> as necessary. Other people likely feel the same way.
> 
> Changing inout to ref would be a very long process in several stages:
> 
> 1) Adding ref as a keyword and documenting its usage
> 2) Recommending changing usage from 'inout' to 'ref'
> 3) Removing 'inout' from the documentation
> 4) Producing a warning on 'inout' with -w switch
> 5) Deprecating 'inout'
> 6) Removing 'inout' as keyword
> 
> Also, 'inout' is easily greppable, and very likely is unique enough that 
> using nothing more than a global search/replace will work.

Why not just stop at '1'?   Inout is very descriptive if what you're 
planning to do is modify the input in a way that the caller can see the 
changes.  Just make it a synonym for 'ref'.  And instead of telling 
people not to use it, tell them to use it only when inout behavior is 
the actual intent.  Otherwise use 'const ref'.  And make 'const inout' 
be an error.

But in terms of the syntax tree generated, both 'inout' and 'ref' will 
be 'ref's.

--bb



More information about the Digitalmars-d mailing list