Skip to content

Commit 50ff1b5

Browse files
committed
private: add slide on limited
1 parent 4d66b12 commit 50ff1b5

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

courses/fundamentals_of_ada/110_private_types.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,35 @@ User View Formal Parameters
612612
Bounded_Stacks.Push (Local, The_Stack);
613613
end Get_Top;
614614
615+
-----------------
616+
Private Limited
617+
-----------------
618+
619+
* :ada:`limited` is itself a view
620+
621+
- Cannot perform assignment, copy, or equality
622+
623+
* :ada:`private limited` can restrain user's operation
624+
625+
- Actual type **does not** need to be :ada:`limited`
626+
627+
.. code:: Ada
628+
629+
package UART is
630+
type Instance is private limited;
631+
function Get_Next_Available return Instance;
632+
[...]
633+
634+
.. code:: Ada
635+
636+
declare
637+
A, B := UART.Get_Next_Available;
638+
begin
639+
if A = B -- Illegal
640+
then
641+
A := B; -- Illegal
642+
end if;
643+
615644
====================================
616645
When To Use or Avoid Private Types
617646
====================================

0 commit comments

Comments
 (0)