refInt = ref int: how to achieve this? or is this a bug?

mw mingwu at gmail.com
Wed Jun 17 22:33:50 UTC 2020


On Wednesday, 17 June 2020 at 22:15:08 UTC, MoonlightSentinel 
wrote:
> On Wednesday, 17 June 2020 at 22:09:35 UTC, mw wrote:
>> and can you see the beauty of this symmetry?  :-)
>
> Try
>
> int main()
> {
>     typedef int* ptrInt;
>     ptrInt arr;
>
>     typedef int& refInt;
>     refInt[] arr2;
> }

That's the semantics of reference: you cannot define a ref 
variable out of air. The equivalent D code cannot be compiled 
either.

We are talking about pass either `ptr` or `ref` to other 
functions here.



More information about the Digitalmars-d mailing list