why static array can be reassigned with new allocation?

Paul Backus snarwin at gmail.com
Sun Oct 16 17:26:05 UTC 2022


On Sunday, 16 October 2022 at 16:38:56 UTC, mw wrote:
> And, if we continue with your (value v.s reference type) 
> example, and do the equivalent in my OP example:
>
>      s1 = new S;
>
> You got:
> onlineapp.d(29): Error: cannot implicitly convert expression 
> `new S(0)` of type `S*` to `S`
>
> This error message is *exactly* what I wanted for my OP example 
> for arrays!

Yes, I agree that this should be an error for arrays too--you 
should not be able to mix pointer/reference types and value types 
in the same assignment.

But if both sides of the assignment are the *same* type, then 
there is no confusion, and no need to use a different syntax.


More information about the Digitalmars-d mailing list