`ref T` should be a type!!

ag0aep6g anonymous at example.com
Mon Apr 1 12:50:29 UTC 2019


On 01.04.19 05:38, David Bennett wrote:
> ---
> 
>      float[32]* myarray = magicFunction();
> 
>      foreach(el; myarray[0]){
> 
>      }
> ---

Aside: Is there are reason why you're writing `myarray[0]` instead of 
`*myarray`? Looks odd.

> But something like this would me much less prone to error (ie missing 
> the [0] above):
> 
> ---
> 
>      ref float[32] myarray = magicFunction();
> 
>      foreach(el; myarray){
> 
>      }
> ---

If you simply forget the `[0]` (or `*`), the code doesn't compile. So 
that specific mistake can't do any real damage. Doesn't seem like a good 
example to motivate making the language more complex.


More information about the Digitalmars-d mailing list