[m-rev.] Xlib interface for extras

Ian MacLarty maclarty at cs.mu.OZ.AU
Thu Sep 23 16:39:02 AEST 2004

> Umm, I think I'll stick to radians.  pi/4.0 isn't that bad and radians
> will interface better with any geometric code the user writes.
> Converting between degrees is a royal pain.

Okay.  Just thought degrees might be simpler for the average user.

>>>    % One must open a display in order to create a window.
>>>    %
>>> :- type display == xlib.display_ptr.
>> Why is this not an abstract type?
> It isn't any more.

Posted this before I saw Julien's comments.

>>>    % The left hand mouse button is usually number 1.
>>>    %
>>> :- type button == int.
>> What about making this button1 ; button2 ; button3  or even left ;
>> middle ; right?  This might be useful when constructing switches on
>> which button was pressed.  Also a button variable having the value 999
>> is pretty meaningless.
> Well, at least five mouse buttons are supported and IIRC X is 
> completely
> agnostic about the number of buttons a mouse can have.


>>> :- impure func open_display = (display_ptr::out) is semidet.
>>> :- impure func open_display(string::in) = (display_ptr::out) is
>>> semidet.
>>> :- impure pred flush(display_ptr::in) is det.
>>> :- impure pred sync(display_ptr::in) is det.
>> Why don't you make these pure and thread the IO state?  The semidet
>> ones you can make det by getting them to return a bool, so you can 
>> then
>> thread the IO state.  Same applies to all the other impure preds in
>> this module.
> That would be a pain.  The xlib module is supposed to be as simple as
> possible.

The extras are one of the first places a new Mercury user will look to 
see how best to implement something, so I think we should be setting a 
good example with the code we put in extras.  I don't think that making 
things that do IO impure to hide the IO state threading is the best way 
to do things.  Nor do I think it makes the code any more readable or 
writable.  In fact threading IO state through calls requires less 
typing that making an impure call.


mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe

More information about the reviews mailing list