----- Original Message -----
From: mAsterdam <[EMAIL PROTECTED]>
Date: Wednesday, September 8, 2004 8:31 pm
Subject: Re: multiple languages clarification - newbie

> Joseph Ryan wrote:
> 
> >>Can someone provide clarification on what mixing languages will 
> >>look like in practice, or point me to where its explained?
> 
> <delurk> Warning. This is perl 7 and a half:
> 
> #!/usr/bin/perl -w
> use prolog;
> 
> prolog:       # prolog tells us:
> 
> needs_support_of(Db, Da):-
>     designer(A, Da),
>     designer(B, Db),
>     needs(A, B).
> 
> designer(perl, larry).
> designer(parrot, dan).
> needs(perl, parrot).
> 
> prolog. ;    # or some other end-quote
> 
> for needs_support_of {
>     print;   # prints 1st in the signature of the unification,
>              # predicate, 2nd .. nth in the signature of the
>              # match (for one member of the result).
>     }
> 
> __END__
> 
> </delurk>

You could do that in Perl6 (or any Parrot based language) as:

    eval "
        needs_support_of(Db, Da):-
            designer(A, Da),
            designer(B, Db),
            needs(A, B).
        
        designer(perl, larry).
        designer(parrot, dan).
        needs(perl, parrot).
    ", "prolog";

    for needs_support_of() {
        print;   # prints 1st in the signature of the unification,
                 # predicate, 2nd .. nth in the signature of the
                 # match (for one member of the result).
    }

Assuming, of course, that there exists a prolog->parrot compiler.

You could even have your syntax if you use a macro:

    macro prolog is parsed(/
       \: ([
             <[^p]>+ ::
           | <!before ^^prolog\.\s*$$> p 
       ]+)
    /) {
        eval($_, "prolog");
    }

- Joe

Reply via email to