Some questions, esp.:Roy compiler on Rhino?

61 views
Skip to first unread message

Dirk Detering

unread,
Jun 9, 2012, 1:36:37 PM6/9/12
to roy...@googlegroups.com

Hello all,
I am very new to Roy and I like what I see very much.
Now I would like to know how tightly Roy (the compiler) is bound to node.js, or if it can run in other environment (I seem to remember in-browser compilation?).
I would be especially interested in running Roy on Rhino.
Is that possible?

Beside that, I detected two issues:
1. The REPL doesn't work over multilines, so e.g. trying to input a typeclass definition seems not to work?
2. The online console on roy.brianmckenna.org states 0.1.5 on the page, but this doesn't seem to understand typeclasses either, at least I get a GENERIC error with
'typeclass Hello #a {'

And at least, is there any solution for creating JS objects with an arbitrary string as key (there exist an issue in the github tracker IIRC)?
This would help with some node APIs it seems.

TIA
Det

Brian McKenna

unread,
Jun 12, 2012, 1:14:38 AM6/12/12
to roy...@googlegroups.com
On 10 June 2012 03:36, Dirk Detering <mail...@googlemail.com> wrote:
> Hello all,
> I am very new to Roy and I like what I see very much.

Thanks for taking a look!

> Now I would like to know how tightly Roy (the compiler) is bound to node.js,
> or if it can run in other environment (I seem to remember in-browser
> compilation?).
> I would be especially interested in running Roy on Rhino.
> Is that possible?

That's what I've done for Play 2.0's Roy compiler:

https://github.com/pufuwozu/ray/blob/master/src/main/scala/RoyBuild.scala

I've written Roy's compiler in a way to degrade back to pure
JavaScript. If it doesn't detect node, it will just provide a JSON API
for compilation.

>
> Beside that, I detected two issues:
> 1. The REPL doesn't work over multilines, so e.g. trying to input a
> typeclass definition seems not to work?

Something I'm going to do eventually - shouldn't be too tricky.

> 2. The online console on roy.brianmckenna.org states 0.1.5 on the page, but
> this doesn't seem to understand typeclasses either, at least I get a GENERIC
> error with
> 'typeclass Hello #a {'

I haven't released a version with type-classes yet. They're not quite
finished. Hopefully soon.

>
> And at least, is there any solution for creating JS objects with an
> arbitrary string as key (there exist an issue in the github tracker IIRC)?
> This would help with some node APIs it seems.

Again, TODO :(

>
> TIA
> Det

Dirk Detering

unread,
Jul 12, 2012, 3:15:54 PM7/12/12
to roy...@googlegroups.com
Hello Brian,

thanks for the answer (even if that thanks come late ;-) ).
Just for a quick note: 
I am playing now with Roy on Android per SL4A/Rhino and was able to compile
two simple roy scripts to javascript and execute them.
This is a bootstrap, as the two roy scripts are compile.roy and eval.roy. 
The first reads a .roy file, compiles its content and writes the output to a .js file.
The second executes the compiled JS via an eval() call.

Works fine so far, now I am into learning the Android API to call it from Roy.

BTW: I could not manage to express 
  var fw = new java.io.FileWriter(); 
in Roy and had to extract that into a js helper function. 
Works fine, but is there any way in Roy to express this statement directly?

Keep the good work on Roy.

KR
Det

2012/6/12 Brian McKenna <br...@brianmckenna.org>

Brian McKenna

unread,
Jul 14, 2012, 7:38:47 AM7/14/12
to roy...@googlegroups.com
Theoretically you should be able to do this:

let fw = (new java.io.FileWriter) ()

It's ugly. Maybe we should just add the new keyword to Roy.

Dirk Detering

unread,
Jul 14, 2012, 11:49:49 AM7/14/12
to roy...@googlegroups.com

Am 14.07.2012 13:38 schrieb "Brian McKenna" <br...@brianmckenna.org>:
>
> Theoretically you should be able to do this:
>
>     let fw = (new java.io.FileWriter) ()

Hmm. Yes, you're right. I tried different things, but not that, it seems.

> It's ugly. Maybe we should just add the new keyword to Roy.

Maybe. For me first prio is that things ARE expressible, beauty is a next step.

Thanks
Det

Reply all
Reply to author
Forward
0 new messages