Extended Type Design.

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Fri Mar 16 17:47:20 PDT 2007


Bill Baxter wrote:
> 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.

That's very awkward. Exact synonyms fare real bad in all languages I 
know. It's chaff without any nutritional benefit. Everybody would have 
preferred that "=>" in Perl is something different from ",", or that 
template<typename T> and template<class T> would be different things in C++.


Andrei



More information about the Digitalmars-d mailing list