Editions Ideas

Walter Bright newshound2 at digitalmars.com
Thu Dec 18 05:56:11 UTC 2025


A difference between slices and pointers - a pointer can have any offset, while 
a slice is bounds checked.

I know that is not the thrust of your argument, just thought I would point that out.

As far as safety goes, taking a slice of a stack array is the same as taking a 
pointer to a stack variable, and you are correct about that.

We could, perhaps, do something like:

```
int[10] array = ...;
ref int[] slice = array[4 .. 5];
```
and then the `ref` semantics would apply. It may be something worth exploring.

In the meantime, taking a slice to a stack array would attach `scope` to its 
lvalue. If that cannot be done (if the lvalue is not a symbol), then it would be 
an error.




More information about the Digitalmars-d mailing list