Re: [m-users.] Calling pass-by-value with C FFI with raylib

Peter Wang <[email protected]>
Newsgroups gmane.comp.lang.mercury.general
Message-ID <[email protected]>
On Fri, 14 Jul 2023 07:29:10 +0100 "Sean Charles (emacstheviking)" <[email protected]> wrote:
> 
> The only real way I could find to model that in Mercury has been to literally
> re-invent the weel and create this union type and then some helpers:
> 
>     :- type p_color
>         --->    lightgray
>         ;       gray
>         ;       yellow
>         :
>         ;       raywhite. % FInal colour from header file palette
> 
>     :- type color
>         --->    rgb(uint8, uint8, uint8)
>         ;       rgba(uint8, uint8, uint8, uint8)
>         ;       c(p_color).

I expect you don't actually need color to be a Mercury d.u. type,
so you can define color as a uint32, and have predicates/functions
that convert between colors and color components.

Peter
_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.