virtualization-lms-core icon indicating copy to clipboard operation
virtualization-lms-core copied to clipboard

Integrate JS-Scala work

Open TiarkRompf opened this issue 13 years ago • 8 comments

I'm mostly thinking about generic things like repProxy or class lifting but it would be good to discuss to which extent other stable pieces of js-scala can and should be integrated. cc: @namin,@julienrf

TiarkRompf avatar Sep 26 '12 15:09 TiarkRompf

One point to keep in mind about repProxy is that method calls to a proxied value are always considered to be effectful (which disables some possible optimizations when the method is actually side effect free). Maybe we need to let the developer describe the possible effects of each method call of a proxied value (but that would require more effort from the developer…).

julienrf avatar Sep 27 '12 08:09 julienrf

Good point. I see repProxy more as a stepping stone though, something to start out with because it's convenient, and later you can switch to custom IR nodes when and if you need better optimization. We could think about having annotations on methods (like @pure).

TiarkRompf avatar Sep 30 '12 13:09 TiarkRompf

Hi,

FYI, here are some features that are in js-scala and for which I’d like to have your feedback:

  • String interpolator for code generation (QuoteGen.scala). Allows to write things like q"$xs.mkString($sep)" instead of quote(xs) + ".mkString(" + quote(sep) + ")". But I think you introduced something like this, or even more evolved, in LMS, no?
  • Algebraic data types (Adts.scala). Staged ADTs, with support for smart constructors, field selection, structural equality, sum types, fold. This stuff is still really on a draft stage, I’m thinking of using macro annotations to reduce the boilerplate ;
  • Some additional methods on List ;
  • Option.

julienrf avatar Feb 11 '14 10:02 julienrf

Hi Julien, this sounds pretty cool.

@Lewix also implemented some string interpolation support (https://github.com/TiarkRompf/virtualization-lms-core/pull/69); it would be nice to compare.

For ADTs, I'm thinking this could be an alternative for explicit case class support in Scala-Virtualized. Could the constructor and member definition be auto-generated (i.e. remove the implicit def pointOps(p: Rep[Point]) = adtOps(p) line)? I guess this is where you would use macros annotations? Another option might be the 'poor mans type providers' based on Dynamic.

@kjbrown: do you think this ADT impl would be useful for Delite?

TiarkRompf avatar Feb 12 '14 12:02 TiarkRompf

Could the constructor and member definition be auto-generated (i.e. remove the implicit def pointOps(p: Rep[Point]) = adtOps(p) line)?

Yes, if I use a macro annotation instead of the current def macro we can get rid of both the implicit def pointOps and the val Point (the macro expansion would generate everything needed in the companion object).

julienrf avatar Feb 12 '14 12:02 julienrf

The string interpolation I wrote works in much the same way, by looking at the type of each argument. It has a few more bells and whistles like remapping manifests, emitting blocks and printing the string to the output stream. The code is here.

Lewix avatar Feb 12 '14 15:02 Lewix

Cool, so I think I will switch to your implementation :)

julienrf avatar Feb 12 '14 15:02 julienrf

Oh, I forgot but I tried to implement a kind of module generator (generated JavaScript code is here): instead of generating a program we generate an object exposing several methods (or sub-modules).

There are still things to improve: each exported function is generated independently of others, so they can not benefit from common subexpressions elimination between functions. The DSL-like API to define a module is a bit too much verbose.

I would be happy to get your feedback on this :)

julienrf avatar Feb 19 '14 22:02 julienrf