clueless question

36 views
Skip to first unread message

Raoul Duke

unread,
Dec 8, 2014, 7:44:07 PM12/8/14
to ats-lang-users
So if there's ats2perl, ats2js, ats2whatever, is there an FFI for each
where one can use the 'native' libraries etc. from within ATS?

Hongwei Xi

unread,
Dec 8, 2014, 8:16:05 PM12/8/14
to ats-lan...@googlegroups.com
Yes. Say you use ats2perl. Then ATS may be seen as a fancy macro system for
producing Perl code. The idea is to do (high-level) designing in ATS and (low-level)
plumbing in Perl.


On Mon, Dec 8, 2014 at 7:44 PM, Raoul Duke <rao...@gmail.com> wrote:
So if there's ats2perl, ats2js, ats2whatever, is there an FFI for each
where one can use the 'native' libraries etc. from within ATS?

--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/CAJ7XQb5NwMc0Rx89STJtQRaB2k-odSQkLeg%3D73fuxbtuSwWtyQ%40mail.gmail.com.

Raoul Duke

unread,
Dec 8, 2014, 8:25:06 PM12/8/14
to ats-lang-users
I don't get get it, yet, apologies. Is there sample code of some ATS
code that inline calls a PHP/JavaScript/Perl/Whatever "native" method?
I think everything I've seen (not much, I'm still looking and
clueless) has e.g. a PHP engine importing and calling
PHP-generated-by-ATS. Sorta like a purely functional thing. Rather
than ATS being the one in control. And I wonder how callbacks would
work.

e.g. as a simple example to try to show what I mean, where each of
these would be in a hello.dats file:

implement main0 () = print("Hello, world!\n")
vs.
implement main0 () = System.console.writeline("Hello, world!") // ats2java
or
implement main0 () = console.trace("Hello, world!") // ats2js
or
implement main0 () = Echo("Hello, world!") // ats2php
or
etc.

gmhwxi

unread,
Dec 8, 2014, 9:17:20 PM12/8/14
to ats-lan...@googlegroups.com
You can use $extfcall to make external calls:

implement main0 () = $extfcall (void, "echo", "Hello, world!") // ats2php

Of course, type-checking is by passed if you do this.

Use $extmcall for method calls:

val console = $extval (some_type, "console")
implement main0 () = $extmcall (void, console, "trace", "Hello, world!")


If console.trace is already given a name, say 'console_trace'  in some SATS-file, then
just do

implement main0 () = console_trace ("Hello, world!") // this one does type-checking.

Raoul Duke

unread,
Dec 9, 2014, 12:07:43 PM12/9/14
to ats-lang-users
thanks.
Reply all
Reply to author
Forward
0 new messages