Atscc2clj

162 views
Skip to first unread message

gmhwxi

unread,
Jul 14, 2016, 5:15:35 PM7/14/16
to ats-lang-users

I am pleased to announce that
ATS code can now be compiled to Clojure (and then to JVM).

I include an example as follows.

Obviously, the generated Clojure code is not so-called idiomatic Clojure code.
But it is really a lot safer than manually written Clojure code because the source
of the code passes type-checking in ATS.

;;fun
(defn
 fact
[arg0]
(
with-local-vars
[
;;knd = 0
  tmpret0
nil
  tmp1
nil
  tmp2
nil
  tmp3
nil
;;var tmplab, tmplab_clj
] ;; with-local-vars
 
;; __patsflab_fact
 
(var-set tmp1 (ats2cljpre_gt_int0_int0 arg0 0))
 
(if @tmp1
   
(do
     
(var-set tmp3 (ats2cljpre_sub_int0_int0 arg0 1))
     
(var-set tmp2 (fact @tmp3))
     
(ats2cljpre_mul_int0_int0 arg0 @tmp2)
   
) ;; if-then
   
(do
     
1
   
) ;; if-else
 
)
) ;; end-of-with-local-vars
) ;; end-of-fun

Now I need to figure out how to write apps in Clojure :) After that, we should be able to write apps in ATS (via Clojure).

Cheers!

Brandon Barker

unread,
Jul 14, 2016, 5:19:03 PM7/14/16
to ats-lang-users
Very nice!
> --
> 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 https://groups.google.com/group/ats-lang-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ats-lang-users/401b2ea7-b5af-4805-8ba8-1d5b30b7c899%40googlegroups.com.



--
Brandon Barker
brandon...@gmail.com

gmhwxi

unread,
Jul 14, 2016, 5:23:49 PM7/14/16
to ats-lang-users
With all the Java classes being available, it is really really pleasant :)


On Thursday, July 14, 2016 at 5:19:03 PM UTC-4, Brandon Barker wrote:
Very nice!
> email to ats-lang-users+unsubscribe@googlegroups.com.
> To post to this group, send email to ats-lang-users@googlegroups.com.

gmhwxi

unread,
Jul 15, 2016, 10:59:26 AM7/15/16
to ats-lang-users
For the record, here is the directory for Atscc2clj:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atsccomp/CATS-atscc2clj

There is a Makefile for generating atscc2clj. Also, some of the running examples can be found at:

https://github.com/githwxi/ATS-Postiats-contrib/tree/master/projects/MEDIUM/CATS-atsccomp/CATS-atscc2clj/TEST

Clojure uses a rather peculiar way to support optimization of recursive tail-calls. So far, ATS can only properly handle tail-call
optimization if the call is located not inside the body of a pattern matching clause. Hopefully, this restriction can be removed
later...

gmhwxi

unread,
Jul 16, 2016, 9:37:15 PM7/16/16
to ats-lang-users

Brandon Barker

unread,
Mar 7, 2018, 7:48:53 PM3/7/18
to ats-lang-users
Is there an example of how to use JVM libraries from ATS?

I might try to rewrite the IntelliJ plugin in ATS if so, but I get the sense that getting  ATS up to speed in JVM tooling might be a bit of a task (though perhaps a worthwhile one). Otherwise I can stick to Scala, which has the advantage I can write as quickly in it as I can in anything at the moment ;-).

Hongwei Xi

unread,
Mar 7, 2018, 8:38:48 PM3/7/18
to ats-lan...@googlegroups.com
If you are familiar with Clojure or willing to get familiar with it, then
using atscc2clj allows you to write ATS code that can be compiled to
JVM.

Caveat: Clojure is big and slow (based on my own experience).

Otherwise, using Scala is probably the right idea. Some students in my
class really like Intellij; it is an easy sale. Also, the way to package ATS code
(to be distributed via npm) is fairly mature now. This can be readily integrated
into the Intellij plug-in for ATS.

######

Never got time to say "Welcome back!".

Hopefully, you will find a lot more fun in ATS this time :)

Cheers!

--Hongwei

--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
Visit this group at https://groups.google.com/group/ats-lang-users.
Reply all
Reply to author
Forward
0 new messages