Skip to content

Commit 8cbf49e

Browse files
authored
Update rfc-structural-generic-instantiation.md
1 parent 6d328c1 commit 8cbf49e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

considered/rfc-structural-generic-instantiation.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ subprograms that need to refer to it. This defers the elaboration check for
492492
the generic body until an instantiating subprogram is called. So instead of
493493
version #1,
494494

495-
```
495+
```ada
496496
package Pkg is
497497
procedure Foo;
498498
procedure Bar;
@@ -514,7 +514,7 @@ version #1,
514514

515515
we might see version #2,
516516

517-
```
517+
```ada
518518
package Pkg is
519519
procedure Foo;
520520
procedure Bar;
@@ -538,7 +538,7 @@ we might see version #2,
538538
Now consider this case with the added wrinkle that the instance is
539539
implicitly declared in version #3:
540540

541-
```
541+
```ada
542542
with G;
543543
package body Pkg is
544544
procedure Foo is
@@ -571,6 +571,7 @@ an implicit instance is declared should be well-defined.
571571

572572
First, a static example:
573573

574+
```ada
574575
generic
575576
package G1 is
576577
Int : aliased Integer;
@@ -587,6 +588,7 @@ First, a static example:
587588
Ref := I1.Int'Access; -- legal
588589
Ref := I2.Int'Access; -- illegal
589590
end Foo;
591+
```
590592

591593
One might argue that this is not a problem since we do not plan to allow
592594
implicit instances of generic packages that declare variables. But the
@@ -596,6 +598,7 @@ entity declared in the generic have been a constant or even a subprogram
596598
Next, a dynamic example, referencing the same G1, Int_Ref, Ref, and I1
597599
declarations:
598600

601+
```ada
599602
procedure Bar is
600603
package I2 is new G1;
601604
procedure Update_Ref (Value : access Integer) is
@@ -606,6 +609,7 @@ declarations:
606609
Update_Ref (I1.Int'Access); -- succeeds
607610
Update_Ref (I2.Int'Access); -- raises Program_Error
608611
end;
612+
```
609613

610614
Accessibility levels can also impact the results of membership tests
611615
and the point at which finalization takes place. We presumably want all
@@ -618,12 +622,14 @@ parameter of an instance, then we can't hoist the implicit declaration
618622
to some point outside of the subprogram. But what does "outermost possible"
619623
mean in the case of renamings and subtype declarations? In a case like
620624

625+
```ada
621626
procedure Foo (N : Natural) is
622627
subtype S is String;
623628
function Eq (X, Y : S) return Boolean renames "=";
624629
begin
625630
Some_Generic (S, Eq).Some_Procedure;
626631
end;
632+
```
627633

628634
can we hoist the implicit instance declaration outside of Foo?
629635
What if we add a static constraint to the subtype declaration, as in

0 commit comments

Comments
 (0)