Discussions related to Visual Prolog
Martin Meyer
VIP Member
Posts: 354
Joined: 14 Nov 2002 0:01

timeout presenter

Post by Martin Meyer »

Yes, I noticed what you wrote about sleep vs. yield. It would have been better if I had used yield in my test.

I have tried that now and replaced sleep with yield in the test. The argument of predicate yield/1 has type timeout. When I stepped through the code with the debugger, I observed that the presentation of timeout values looked a bit unusual. Below I tried to set up an alternative timeout presenter:

Code: Select all

    open core, presenter   domains     myTimeout = timeout [presenter(presenter_myTimeout)].   clauses     run() :-         %Timeout = infinite,         Timeout = timeoutAfter(hasDomain(durationValue, 1 * oneHour + 2 * oneMinute + 3 * oneSecond)),         %Timeout = timeoutAt(time::newGMT(2024, 11, 6, 1, 2, 3):gmtTimeValue),         %         MyTimeout = uncheckedConvert(myTimeout, Timeout),         stdIO::present(Timeout),         stdIO::nl(),         stdIO::present(MyTimeout),         stdIO::nl().   class predicates     presenter_myTimeout : presenter::presenter{myTimeout}. clauses     presenter_myTimeout(T) = P :-         T = infinite,         P = mkPresenter_fixed(fp_string("infinite"), presenter::mkFP_childOnly_term("Representation", uncheckedConvert(integer64, T)))         orelse         if T <= 0 then             P =                 enclose("after(", ")",                     mkPresenter_fixed(mkFP_pres("After", {  = presenter_durationValue(uncheckedConvert(core::durationValue, -T)) }),                         presenter::mkFP_childOnly_term("Representation", uncheckedConvert(integer64, T))))         else             P =                 enclose("at(", ")",                     mkPresenter_fixed(mkFP_pres("At", {  = presenter_gmtTimeValue(convert(core::gmtTimeValue, T)) }),                         presenter::mkFP_childOnly_term("Representation", uncheckedConvert(integer64, T))))         end if.
The picture shows fully expanded presentations of a timeout value with the alternative presenter and the original presenter:
presenter_timeout1.jpg
You do not have the required permissions to view the files attached to this post.
Regards Martin
User avatar
Thomas Linder Puls
VIP Member
Posts: 1469
Joined: 28 Feb 2000 0:01

Re: timeout presenter

Post by Thomas Linder Puls »

Yes, they can have better presenters we will look at it.
Regards Thomas Linder Puls
PDC