On 2012-05-29 15:09:00 +0000, Artur Skawina <[email protected]> said:

   int a[1024];
   int[] da = a[0..1024];

   if (whatever)
      da = da[3..14];
   if (something_else)
      da = [42] ~ da;
   // etc

   if (da_is_a_slice_of_a())
      still_inside_a();

How do you implement da_is_a_slice_of_a()?

Indeed, for that to work you'd still need to handle this case specially. My bad for not catching that.

Personally, I think it'd be much cleaner to go with some kind of magic function than trying to match the condition against a predefined pattern. Something like da.isSliceOf(a), which could do the usual pointer thing at runtime and call some sort of CTFE intrinsic at compile-time.

--
Michel Fortin
[email protected]
http://michelf.com/

Reply via email to