[mercury-users] Leveraging Perl

Tyson Dowd trd at cs.mu.OZ.AU
Thu Apr 26 21:54:56 AEST 2001


On 26-Apr-2001, Ralph Becket <rbeck at microsoft.com> wrote:
> [Disclaimer: people on this mailing list know my opinion of Perl.]
> 
> > The amount of free modules available from the Perl community is
> > staggering. I have often longed to simply drop Perl and become a
> > Mercury expert, but for pragmatic reasons it may be better to marry
> > the two. What would be the best way to take advantage of Perl
> > functionality within Mercury?
> 
> A big sign saying "Noooooooooooooooooooooo!" :)
> 
> Well, you can call Mercury binaries from Perl scripts and probably
> vice versa.
> 
> > The two general approaches would be a Perl-to-Mercury compiler or
> > some sort of C interface to the Perl interpreter.
> > 
> > The problem with a compiler is that Perl code is by-and-large
> > less-typed than Mercury code.
> 
> One of the key motivations behind the Mercury design is to provide a
> safe, declaratively pure programming tool suitable for programming in
> the large.  This is diametrically opposed to the Perl philosophy.  I
> suspect that any attempt to marry the two would end in tears.  For me,
> the real question is what is it that you can do in Perl that you
> cannot currently do in Mercury?  If the main argument is a desire to
> exploit the Perl libraries out there from Mercury then the new .NET
> stuff may well make this possible.
> 
> Quite how Mercury would talk to Perl is not clear, what with Perl's
> "is it a list?  Is it a hash table?  Is it a scalar?  What number 
> were you thinking of first?" approach to object behaviour.

The deficiencies of Perl aside, there are lots and lots of Perl
libraries that are good for interfacing with other systems.

You could do something like the extras/graphics/mercury_tcltk
interface which interfaces to TCL using the kind of C code you might
use for interfacing to TCL from C, plus some more smart stuff to do
callbacks via Mercury closures.

But in TCL everything is a string, so this is reasonably easy to handle.
If you wanted to expose Perl data structures to Mercury you would
probably have to try a bit harder to expose them in a clear way.

Note that the other problem is that these kind of interfaces can be quite
fragile -- particularly if you end up relying on any kind of internal
representations or interfaces that are likely to change.


-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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