"J. David Bryan" wrote:
On 20 Nov 2002 at 14:03, CBFalconer wrote:
.. snip ...
And the multiple ranges per variant, as pointed out by Emil, complicates that variant selector check, unless I am again confused.
No, it does indeed complicate the issue, as multiple (disjoint) checks need to be made.
But consider a "regular" (executable) CASE statement appearing in the body of a program. To decide whether a specific contained statement is to be executed, the same sequence of possibly disjoint checks must be made. The only difference between this and the variant access situation is the action taken after the check: a transfer of execution or an allowed field access. So the checking code already exists in GPC; it "simply" :-) needs to be emitted in association with a variant field access.
I don't know what GPC does, but most CASE executors will use a table, so that execution checks are limited to the overall range of that table. Missing entries will either point to error spawning code or to the otherwise case. It takes a very sparse and small (or alternatively very large) table to encourage simulation by if then elseif.
At any rate, I am not especially worried about checking correct variant tags, but I am worried about run time checks in general. I repeat - do the easy ones first.