MODULE int_pointer EXPORTS Main; IMPORT IO, Fmt; TYPE int_ref = REF INTEGER; VAR int_ptr : int_ref; int_ptr2 : int_ref; BEGIN int_ptr := NEW(int_ref); (* speicher fuer integer reservieren *) IO.Put("int_ref enthaelt jetzt : " & Fmt.Int(int_ptr^) & " - vorsicht, wert ist unbestimmt !!!\n"); int_ptr^ := 5; (* wertzuweisung -> zugriff auf speicher *) IO.Put("int_ref nach zuweisung : " & Fmt.Int(int_ptr^) & " - in ordnung, ist so gewollt =)\n\n"); IO.Put("kopiere die Adresse von int_ptr in int_ptr2 :: int_ptr2 := int_ptr" & "\n"); int_ptr2 := int_ptr; (* kopie der adresse von int_ptr *) IO.Put("beide Zeiger zeigen jetzt auf die gleiche Speicherstelle!\n\n"); IO.Put("Weise int_ptr den wert 500 zu ... \n"); int_ptr^ := 500; IO.Put("int_ptr = " & Fmt.Int(int_ptr^ ) & "\n"); IO.Put("int_ptr2 = " & Fmt.Int(int_ptr2^) & "\n\n"); IO.Put("Weise int_ptr2 den wert 111 zu ... \n"); int_ptr2^ := 111; IO.Put("int_ptr = " & Fmt.Int(int_ptr^ ) & "\n"); IO.Put("int_ptr2 = " & Fmt.Int(int_ptr2^) & "\n\n"); IO.Put("Die Manipulation der selben Speicherstelle kann nun ueber 2 Schluessel erfolgen. \n"); IO.Put("Achtung!!! Laesst man beide Zeiger auf eine andere Speicherstelle zeigen, so ist der \n"); IO.Put("Zugriff auf diese nicht mehr moeglich. Der Speicherplatz ist verloren ... \n"); END int_pointer.