On 07/29/2012 06:32 PM, Alex Rønne Petersen wrote:
On 29-07-2012 17:36, bearophile wrote:
Alex Rønne Petersen:

.NET is too limited to represent the language,

Can you tell us why?

Bye,
bearophile

Array slices. The .NET type system has no way to represent them because
it's designed for precise GC, and array slices allow interior pointers
in the heap (as opposed to the stack when passing a field of an object
by reference to a function, or whatever).


I think all of CTFE-D should map to .NET without much hassle.

struct ArraySlice<T>{
    private T[] storage;
    private ulong start;
    private ulong len;

    public ArraySlice<T> slice(ulong a, ulong b){
        if(a>b||b>len) throw new BoundsError("...");
        return new ArraySlice<T>(storage, start+a, b-a);
    }

    public ulong length(){ return len; }
    public Pointer<T> ptr(){ return new Pointer<T>(storage, start); }
    // ...
}

Performance will suffer of course.

Reply via email to