3 ms·
> having a fat pointer decay to a regular pointer _implicitly_ feels like what I never want to happen D doesn't do that implicit decay, but I was thinking of t
by WalterBright 4y ago
> having a fat pointer decay to a regular pointer _implicitly_ feels like what I never want to happen
D doesn't do that implicit decay, but I was thinking of the kernel requirements of no API change. A simple way to convert a phat pointer to a pointer is:
&a[0]
which is used in D to interface with C code. Note that the syntax still works if `a` is a pointer!
Since the pointer <=> phat pointer conversions are trivial operations, one can easily go back and forth between them depending on what part of the code one wants the overflow checks on vs the legacy interfaces.
With a couple of C macros one could turn on/off declaring arrays as pointers or phat pointers, and turn on/off the slicing code. In this way it will still compile with old compilers.
- ndesaulniers 4y agoIs https://dlang.org/spec/arrays.html https://dlang.org/spec/arrays.html the best place to learn more?
- WalterBright 4y agoyes