| Thread overview | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
November 08, 2011 Type Qualifiers and Wild Cards | ||||
|---|---|---|---|---|
| ||||
http://drdobbs.com/blogs/cpp/231902461 Anyone want to do the reddit honors? | ||||
November 08, 2011 Re: Type Qualifiers and Wild Cards | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter:
> http://drdobbs.com/blogs/cpp/231902461
It's a nice explanation, quite simple to understand, despite it lacks some details.
Bye,
bearophile
| |||
November 08, 2011 Re: Type Qualifiers and Wild Cards | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Mon, 07 Nov 2011 20:08:27 -0500, Walter Bright <newshound2@digitalmars.com> wrote: > http://drdobbs.com/blogs/cpp/231902461 > > Anyone want to do the reddit honors? http://www.reddit.com/r/programming/comments/m497s/type_qualifiers_and_wild_cards_in_the_d/ -Steve | |||
November 08, 2011 Re: Type Qualifiers and Wild Cards | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 11/08/2011 02:08 AM, Walter Bright wrote:
> http://drdobbs.com/blogs/cpp/231902461
>
> Anyone want to do the reddit honors?
Nice article!
> It isn't a template, and inout can only be used on function parameters and the return value.
What about local variables?
| |||
November 08, 2011 Re: Type Qualifiers and Wild Cards | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | On 11/8/2011 12:16 AM, Timon Gehr wrote: > Nice article! Thanks! > > It isn't a template, and inout can only be used on function parameters and > the return value. > > What about local variables? Just use const for them. | |||
November 08, 2011 Re: Type Qualifiers and Wild Cards | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 08.11.2011 09:33, Walter Bright wrote:
> On 11/8/2011 12:16 AM, Timon Gehr wrote:
>> Nice article!
>
> Thanks!
>
>
>> > It isn't a template, and inout can only be used on function
>> parameters and
>> the return value.
>>
>> What about local variables?
>
> Just use const for them.
This compiles:
inout(int *) foo(inout(int *) a)
{
inout x = a;
return x;
}
and it doesn't compile if you replace 'inout x' with 'const x'.
| |||
November 08, 2011 Re: Type Qualifiers and Wild Cards | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Don | On 11/8/2011 12:44 AM, Don wrote:
> This compiles:
>
> inout(int *) foo(inout(int *) a)
> {
> inout x = a;
> return x;
> }
>
> and it doesn't compile if you replace 'inout x' with 'const x'.
>
inout can implicitly convert to const, but const cannot implicitly convert to inout, hence the error on the return x;
But you're right, use inout in the body, and it is treated much like const.
| |||
November 08, 2011 Re: Type Qualifiers and Wild Cards | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Le 08/11/2011 02:08, Walter Bright a écrit : > http://drdobbs.com/blogs/cpp/231902461 > > Anyone want to do the reddit honors? Great article. The only point I would raise is the choice of inout as a keyword for this. This make no sens whatsoever. Here is why : - inout did exist in D1 and is different. - in and out qualifier already exists and have nothing to do with inout. - in and out are used for contracts and have nothing to do with inout. - the inout term has nothing to do with const/immutable/mutable. This is in a totally different lexical field. Another keyword should be choosen. vconst, as suggested here : http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP2 is way more appropriate. On external details, but still important, I face the need of inout few days ago and did knew about it. The documentation on const/immutable ( http://www.d-programming-language.org/const3.html ) doesn't mention it. The page on fucntion mention it, but it would be nice to have at least a link on the const/immutable page. | |||
November 08, 2011 Re: Type Qualifiers and Wild Cards | ||||
|---|---|---|---|---|
| ||||
Posted in reply to deadalnix | I agree with _inout_ being a bad choice.
I'd rather use something involving _auto_, because this kind of use of
_auto_ is already employed in _auto ref_ parameters and is visually
unambiguous.
Probably _auto const_ would do the trick.
The actual _inout_ keyword could be flagged as deprecated and removed during the next breaking change in D (along with all other wonderful breaking changes that were proposed).
On Tue, Nov 8, 2011 at 5:08 PM, deadalnix <deadalnix@gmail.com> wrote:
> Le 08/11/2011 02:08, Walter Bright a écrit :
>>
>> http://drdobbs.com/blogs/cpp/231902461
>>
>> Anyone want to do the reddit honors?
>
> Great article. The only point I would raise is the choice of inout as a keyword for this.
>
> This make no sens whatsoever. Here is why :
> - inout did exist in D1 and is different.
> - in and out qualifier already exists and have nothing to do with inout.
> - in and out are used for contracts and have nothing to do with inout.
> - the inout term has nothing to do with const/immutable/mutable. This is in
> a totally different lexical field.
>
> Another keyword should be choosen. vconst, as suggested here : http://prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP2 is way more appropriate.
>
> On external details, but still important, I face the need of inout few days ago and did knew about it. The documentation on const/immutable ( http://www.d-programming-language.org/const3.html ) doesn't mention it. The page on fucntion mention it, but it would be nice to have at least a link on the const/immutable page.
>
| |||
November 08, 2011 Re: Type Qualifiers and Wild Cards | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Gor Gyolchanyan | Le 08/11/2011 14:36, Gor Gyolchanyan a écrit :
> I agree with _inout_ being a bad choice.
> I'd rather use something involving _auto_, because this kind of use of
> _auto_ is already employed in _auto ref_ parameters and is visually
> unambiguous.
> Probably _auto const_ would do the trick.
>
> The actual _inout_ keyword could be flagged as deprecated and removed
> during the next breaking change in D (along with all other wonderful
> breaking changes that were proposed).
>
Well use of auto can be ambiguous here I think.
What about auto const ref ?
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply