[m-users.] Mercury style for OO style interfaces
Sean Charles (emacstheviking)
objitsu at gmail.com
Tue Sep 7 06:10:08 AEST 2021
Hi,
I am wondering what the most appropriate technique is to emulate the concept of an interface that fronts a selected concrete representation of a translation process? Each translation process will have a common set of predicates to transform my AST into a different output form according to command line switches.
I have worked through several options but eventually they all feel cumbersome and clumsy. For example :-
:- import_module form_a. % renders ‘a’ code from AST
:- import_module form_c. % etc.
:- import_module form_b.
( if option = “form a” then
renderer = form_a.render
else if option = “form b” then
renderer = form_b.render
then later where I need to call the render functions…
renderer( … )
:
I hope my question is clear enough to elicit meaningful response. I have not had too much success using currying in Mercury, the above is about as brave as I have been but that’s only one possible solution. I guess I am just trying to make that leap from thinking about things in OO to more of a Mercury paradigm.
Thanks
Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20210906/78de5b42/attachment.html>
More information about the users
mailing list