November 09, 2011 Re: Type Qualifiers and Wild Cards | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Andrei Alexandrescu wrote:
> On 11/9/11 9:58 AM, Nick Treleaven wrote:
>> On 09/11/2011 15:29, deadalnix wrote:
>>> inout isn't reminding in any way of its functionnality. It is more readable than ##, for sure, but way less than any word from const/immutable lexical field.
>>
>> inout means transfer the input qualifier to the output, it is descriptive enough.
>
> Thank you. I was itching to write that but was hoping somebody else would.
>
> Andrei
it would be a good solution, if in and out didn't exists.
I was _very_ confused, when I first saw inout and thougth it would be a combination of in and out.
So I think it deserves a prominent place in the documentation next to in and out.
| |||
November 09, 2011 Re: Type Qualifiers and Wild Cards | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter:
> http://drdobbs.com/blogs/cpp/231902461
>
> Anyone want to do the reddit honors?
On Reddit I see the discussion is a bit about merging of templates that produce the same function code. This is already possible in D, compiling with the LDC1 (and maybe LDC2 too) compiler using the -mergefunc switch.
I think according to the C standard all functions must have different function pointers, and I presume D has the same rule (even if I don't remember reading it in the D specs). This problem is solved leaving a tiny stub that just contains a jump instruction for the removed duplicated functions. This jump is probably nearly always correctly "predicted" by the CPU, because it's hard-coded.
As far as I know this -mergefunc is not able to remove partially duplicated functions, this is left to future improvements of the LLVM back-end.
Bye,
bearophile
| |||
November 10, 2011 Re: Type Qualifiers and Wild Cards | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright Wrote:
> On 11/8/2011 11:10 AM, Martin Nowak wrote:
> > I personally find it much more astonishing that inout methods finally work.
>
> In retrospect, it seems like a fairly straightforward solution, but it took us many, many hours and gallons of coffee. And, as far as I know, this solution has not been seen before in any other language, though there is a crying need for it in C++.
I don't think so. `inout` is needed in D because you get const data from const object because of transitivity, you have nothing like this in C++ POD. One can try to emulate transitive const with corresponding accessors, but is it used in C++ widely?
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply