Roy modules and a Play 2.0 plugin

143 views
Skip to first unread message

Brian McKenna

unread,
Mar 19, 2012, 5:13:12 AM3/19/12
to roy...@googlegroups.com
Hey everyone,

I've been making some progress with Roy in the past few weeks. The
first big thing is support for modules.

Compiling a .roy file on the command-line will generate a .roym file
which contains exported type information:

numberToBinaryString: Function(Number, String)

Roy will then load those types in an `import` and use them for type
checking. If you use the Roy compiler in the browser, it will generate
an Immediately-Invoked Function Expression (IIFE) and some global var
statements. If you use the Roy compiler with node.js it will generate
CommonJS 1.0 `require` and `export` calls.

One interesting point is that you can manually write the .roym
descriptor and provide JavaScript implementations in a .js file:

exports.numberToBinaryString = function(x) {
return x.toString(2);
};

This will hopefully help with interoperability while I work on a good
standard library.

The second thing I'm getting excited about is Play 2.0 integration. If
you have a Play 2.0 app, you can just depend on the `Ray` plugin to
automatically compile .roy files to .js:

https://github.com/pufuwozu/ray

Let me know what you think.

- Brian McKenna

Alexander Solovyov

unread,
Mar 19, 2012, 5:56:48 AM3/19/12
to roy...@googlegroups.com
On Mon, Mar 19, 2012 at 11:13, Brian McKenna <br...@brianmckenna.org> wrote:
> Roy will then load those types in an `import` and use them for type
> checking. If you use the Roy compiler in the browser, it will generate
> an Immediately-Invoked Function Expression (IIFE) and some global var
> statements. If you use the Roy compiler with node.js it will generate
> CommonJS 1.0 `require` and `export` calls.

Hm, so right now if I want to precompile modules for browser, I'll
need to use browser for that?

--
Alexander

Brian McKenna

unread,
Mar 19, 2012, 6:02:36 AM3/19/12
to roy...@googlegroups.com
At the moment, yes.

I'm definitely planning to make it a compile flag so you'll be able to
do it from node.js - I'll make that happen soon.

Reply all
Reply to author
Forward
0 new messages