Pointer semantics in CTFE

Michel Fortin michel.fortin at michelf.com
Tue May 29 10:35:12 PDT 2012


On 2012-05-29 15:09:00 +0000, Artur Skawina <art.08.09 at gmail.com> 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
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list