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

Multiple arguments vs Tupled Functions #22

Open
tzbob opened this issue Oct 6, 2014 · 4 comments
Open

Multiple arguments vs Tupled Functions #22

tzbob opened this issue Oct 6, 2014 · 4 comments

Comments

@tzbob
Copy link

tzbob commented Oct 6, 2014

I'm running into some kind of a problem here.

LMS defines the TupledFunctions as a way to work with lambda's with multiple arguments. So the lambda conversion is done by packing the arguments into a tuple at language level and then unpacking them in the corresponding generators..

This removes the ability to reason about lambdas with multiple arguments and lambdas with 1 tuple argument separately which might be okay for small DSLs but I'm not sure if this would be intended behavior for a DSL that aims to provide most of Javascript's functionality.

So, is this a bug or intended behavior? If so how do we fix it (I'm perfectly willing to look for a solution with you), if not, what is the intended work-around? Seeing as Javascript doesn't have tuples maybe removing the tuple functionality and strictly working with Structs or Adts is sufficient?

Thanks!

@julienrf
Copy link
Member

julienrf commented Oct 6, 2014

This removes the ability to reason about lambdas with multiple arguments and lambdas with 1 tuple argument separately

Why do you need this?

@tzbob
Copy link
Author

tzbob commented Oct 6, 2014

I'm trying to find an example in the JS-Scala library but the section I could find is CPS, for example Cell's get method:

trait Cell[A] {
    def get(k: Rep[A => Unit]): Rep[Unit]
    def set(v: Rep[A]): Rep[Unit]
}

If this were a Cell of type (A, B) the lambda that would eventually be passed to get would be compiled as a function with 2 arguments instead of a function with 1 tuple argument wouldn't it? If that's not true then my argument is invalid and all is well ^^.

Something like this can come up more often when wrapping existing polymorphic Javascript libraries, anytime a tuple is used the lambda would be compiled into the wrong format.

@julienrf
Copy link
Member

julienrf commented Oct 6, 2014

If this were a Cell of type (A, B) the lambda that would eventually be passed to get would be compiled as a function with 2 arguments instead of a function with 1 tuple argument wouldn't it?

I think you are right. Please raise an issue on the LMS repository.

@tzbob
Copy link
Author

tzbob commented Oct 7, 2014

Will do, as soon as I have an contained example of the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants