[m-rev.] Xlib interface for extras

Ralph Becket rafe at cs.mu.OZ.AU
Thu Sep 23 16:18:55 AEST 2004


Ian MacLarty, Thursday, 23 September 2004:
> This looks neat.  It also seems to work fine on Max OS X (I tested it).

Excellent - thanks for testing that.

> >% Angles, where used, are measured in radians.
> 
> Personally I'd find degrees easier to use.  I find 45.0 is easier to  
> read than math.pi/4.0 - especially for this type of simple library.

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.

> >    % 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.

> >    % create_window(Display, Title, Width, Height, Orientation,  
> >Window, !IO)
> >    % Create Window on Display, with the given Title, Width, Height and
> >    % Orientation.
> >    %
> >:- pred create_window(display::in, string::in, int::in, int::in,
> >            window::out, io::di, io::uo) is det.
> >
> 
> The orientation argument seems to have been left out here.

Ah yes, I decided that was a dumb idea, but forgot to update the
documentation.  Fixed.

> Couldn't font be an abstract type?

Fixed.

> >:- type colour == xlib.color_ptr.
> 
> Again couldn't this be abstract?

Fixed.

> >    % 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.

Thanks for the review comments,
-- Ralph
--------------------------------------------------------------------------
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