`ref T` should be a type!!

David Bennett davidbennett at bravevision.com
Mon Apr 1 03:38:21 UTC 2019


On Friday, 29 March 2019 at 16:06:09 UTC, Victor Porton wrote:
>
> Can the language be changed to resolve this problem?

Currently working on a project that works with a lot on pointers 
to fixed length arrays and its currently very easy to forget to 
de-refrence the pointer because the pointer and array syntax is 
the same.

For example I have code that looks something like this:

---

     float[32]* myarray = magicFunction();

     foreach(el; myarray[0]){

     }
---

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 i convert the above code to use slices I loose the 
compile-time bounds check.


More information about the Digitalmars-d mailing list