[mercury-users] Meta programming in Mercury

Ralph Becket rwab1 at cam.sri.com
Wed May 19 19:04:01 AEST 1999


Luke Evans wrote on 18 May:
> Is there any way to submit new code to the Mercury compiler at runtime?  I'm
> guessing that the answer is no, given that there's currently no interpreter
> to handle any bytecode this process might generate.  If this is the case,
> are there any plans which would permit meta-programming in the future, or is
> the whole concept considered anathema! 
> 
> I'm not sure if I even need this yet, but a new project will probably
> involve describing fuzzy relationships which are discovered at runtime.
> Obviously I could describe these in my own high level representation (as one
> would have to do in an imperative language), but in Prolog I would have the
> option of representing the logic as a part of the program itself.

What you're doing here is introducing new names to the namespace at
runtime which, as Fergus has pointed out, you can do using the
relatively heavyweight method of bailing out to the Mercury compiler.

Have you considered using higher order functions instead?  While the
compiler may not be able to optimise them as well as first order code,
you don't have to pay the hit of stopping to run the compiler before
you can use the results.  And HO code really doesn't cost that much.

Cheers,

Ralph

-- 
Ralph Becket  |  rwab1 at cam.sri.com  |  http://www.cam.sri.com/people/becket.html
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list