Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate JS-Scala work #26

Open
TiarkRompf opened this issue Sep 26, 2012 · 8 comments
Open

Integrate JS-Scala work #26

TiarkRompf opened this issue Sep 26, 2012 · 8 comments
Labels

Comments

@TiarkRompf
Copy link
Owner

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

@ghost ghost assigned namin Sep 26, 2012
@julienrf
Copy link
Contributor

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…).

@TiarkRompf
Copy link
Owner Author

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).

@julienrf
Copy link
Contributor

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.

@TiarkRompf
Copy link
Owner Author

Hi Julien, this sounds pretty cool.

@Lewix also implemented some string interpolation support (#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?

@julienrf
Copy link
Contributor

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).

@Lewix
Copy link
Contributor

Lewix commented Feb 12, 2014

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.

@julienrf
Copy link
Contributor

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

@julienrf
Copy link
Contributor

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 :)

@TiarkRompf TiarkRompf removed this from the 0.8.0 milestone Aug 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants