From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8749545ac52d7b9c X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Great Circle and Ada? Date: 1996/09/17 Message-ID: #1/1 X-Deja-AN: 181105413 references: organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-09-17T00:00:00+00:00 List-Id: In article , Lars Farm wrote: >What is virtual origin? This means you represent a pointer to array A as the address of A[0]. If the zeroth element doesn't exist, then use the address of where it "would" be. So, if A has bounds 1..10, the pointer to A is the address just before the array in memory. If A has bounds -10..10, the pointer is an address of the middle of A. If A has bounds 1_000_000..2_000_000, then the pointer is the address of some word very far from A. >... Somewhere there has to be a way to reach the block >from users code if one is to use it. The compiler knows it's doing this, and so can generate the right code. The address of the N'th element is simply (the pointer) + N*(size-of-component). The efficiency advantage is that you avoid subtracting off the lower bound (which would be necessary if you always used the address of A(A'First). The compiler needs to keep the bounds of the array "somewhere else", so it can do bounds checking. >... Is is a pointer into the interior of >an allocated block rather than to the start of the block? If so, at least >Boehms GC has no problems with it and Great Circle can probably handle >interior pointers too. It's quite possible to implement GC with virtual origins, but the GC has to know about it, and do the appropriate thing (just like the compiler-generated code does). This requires some cooperation between the compiler and the GC (which is a Good Thing anyway, IMHO, but is not the case with gcc/GNAT). - Bob