----- Original Message ----- From: Richard Jolly <[EMAIL PROTECTED]> Date: Wednesday, September 8, 2004 6:02 pm Subject: multiple languages clarification - newbie
> Hi, > > <newbie> > > Can someone provide clarification on what mixing languages will > look > like in practice, or point me to where its explained? I think you mean mixed language libraries/modules rather than mixed languages (to mix languages, you'd need to do a multi-arg eval like in Dan's example). Using another language's module, however, would not pay attention to the other language's syntax at all. You would C<use> the module in your code, and then interface with it just as if it were written in the language that you were writing in (and not in the language that the module was written in). So this: > #!/usr/bin/perl6 > > use __Python::sys; # whatever syntax > sys.stdout.write( 'hi there'); # perl6 syntax matches python > syntax > here, I think would become this: (Apologies, I don't know Python, well, at all, so I'll state what assumptions I make) #!/usr/bin/perl6 use __Python::sys; # I'm assuming that C<$stdout> is some sort of # global object in the C<sys> namespace. $*sys::stdout.write('hi there'); > And this: > > #!/usr/bin/ponie > > use __Python::sys; > use __Python::string; > > my $hi = __Python::string->upper( 'hi' ) > sys->stdout->write( $hi ); # HI > > > my $upper_func = __Python::string->upper # does this call the > # function with no args > (perlish) > # or return it (pythonish) #!/usr/bin/ponie use __Python::sys; use __Python::string; use UNIVERSAL qw(can); # here I'm assuming that C<$string> is a global # object in the C<__Python> namespace. my $hi = $__Python::string->upper('hi') # Hi; my $hi_func1 = \&__Python::string::upper; my $hi_func2 = can($__Python::string,'upper'); The idea is that after compilition, everything is just PMCs and PIR, and so everything (hopefully) plays nice together. - Joe