:-object clock.

        var time = 0.

        get_clock(T) :- T := time.

        set_clock(T) :- time := T.

:-end_object clock.


:-object pulse.

        pulse :-
                repeat,
                        sleep(1000),
                        clock <- get_clock(T),
                        T1 is T + 1,
                        clock <- set_clock(T1),
                T1 > 10,
                !.

:-end_object pulse.


:-object hello4.

        hello4(Text) :-
                repeat,
                        clock <- get_clock(Time),
                        format('~w ~w~n', [Text, Time]),
                        sleep(500),
                Time >= 10,
                !.

:-end_object hello4.


:-object hello_world4.

        main :-
                _C := new(pulse),
                _H := new(hello4(hello)),
                _W := new(hello4(world)).

:-end_object hello_world4.

