-- Demostration program for generic set handling package. WITH text_io ; USE text_io ; -- make text I/O package available WITH set_handler ; -- make generic set handling package available PROCEDURE setdemo IS -- Global Types : TYPE colour IS ( violet, blue, white, green, yellow, orange, red ) ; -- Generic Package Instantiation : PACKAGE colset IS NEW set_handler ( colour ) ; USE colset ; -- Global Variables : colour_set : set := full_set ; -- full set of colours colour_choice : set ; leftovers : set ; one_colour : colour ; BEGIN -- setdemo -- set up colour_choice colour_choice := new_set ( ( red, white, blue ) ) ; -- set up leftovers leftovers := colour_set - colour_choice ; -- perform a couple of trivial tests IF leftovers <= colour_set THEN PUT ( "leftovers is a sub-set of colour_set" ) ; NEW_LINE ; END IF ; IF NOT set_is_empty ( colour_choice ) THEN PUT ( "colour_choice is not empty" ) ; NEW_LINE ; END IF ; one_colour := yellow ; IF one_colour <= new_set ( ( blue, yellow, white, orange ) ) THEN PUT ( "One colour test succeeds." ) ; NEW_LINE ; END IF ; -- try to assign values directly to a set -- this should generate an error at compile time leftovers := ( OTHERS => TRUE ) ; END setdemo ; ------------------------------------------------------