Comments (6)
This is by design. Squid's normal mode of operation is to manipulate trees that are fully resolved: fully typed and fully applied (including implicits), so the fact that a local value be implicit has no incidence on the program after type checking.
That said, I assume you have a good use case for it. Perhaps you want to insert some code within the body of that let binding where some implicits are not resolved yet? If that's a necessity for you, I think we can keep track of the implicit
modifier and generate code that reapply it (this would likely be done staring from there).
Let me know what's your stance on it. What is your use case?
from squid.
Oh, I see!
Unfortunately, we need to keep the implicits unresolved in most parts of Emma's pipeline, and resolve them only at the end. (This is because some Flink implicits resolve to scary stuff that we can't handle at the moment, for example anonymous classes like new Foo {...}
)
So it would be good if Squid kept the implicit modifiers on the ValDefs, because then we could still resolve them at the end.
from squid.
Okay, that makes some sense. However, you're probably going to have troubles if you try to handle these Flink functions in quasiquotes. Remember that Squid quasiquotes are type-checked and will require the implicit arguments to be inferred or provided.
A way around this (if you do need to manipulate these constructs explicitly) would be to define a mirror of each construct but without the implicit parameters, and only at the end of the day, when generating code, you change them back to the actual Flink functions. (The mirror definitions could actually be macros that expand into the Flink functions automatically on compiling the program using scalac.)
I'll look into the implicit val thing. Note that a workaround could be to encode implicit val a = t; ...
as withImplicit(t) { a => ... }
and either manually convert them back during code gen or use the macro trick mentioned above.
from squid.
Thanks for looking into this! I'm thinking of an other workaround now, which avoids having to define the mirrors:
Let's say that the user's code is calling some Flink method:
x.flinkMethod
which has some problematic implicit parameter that, say, looks like this after resolution (before Emma's pipeline):
x.flinkMethod(new Foo{})
Instead of completely removing this implicit argument at the start of Emma's pipeline, maybe I could just replace it with a dummy argument like this:
x.flinkMethod((???): Foo)
And then Emma would pass such trees to Squid somewhere in the middle of our pipeline.
And later at the end of our pipeline Emma would remove these dummies and re-resolve them.
Do you think this could work?
Note that this workaround would still need Squid to keep the implicit modifiers on the ValDefs, so that we can resolve at the end of our pipeline.
from squid.
@ggevay Sure, that should work fine. You can name the dummy method:
def inferLater[A](): A = ???
and later transform its applications to:
def inferNow[A](implicit a: A): A = a
from squid.
Good idea, thanks!
from squid.
Related Issues (20)
- Remove special handling of AnyCode
- Vararg support in embedded Defs HOT 1
- Move away from the current `rewrite` macro implementation
- Support cross-quotation references in quasicode HOT 1
- Improve the Base interface
- Fix SchedulingANF
- Code pattern matching should ignore difference between overriding and overridden symbols HOT 1
- Make `Const` safer with a type class HOT 1
- Make syntax of variable function insertion more regular
- Generic arguments of inner classes disappear HOT 2
- Path-dependent types turn into type projections HOT 4
- Virtualize `def` and `lazy val` in embedded code
- Support Java varargs
- Investigate and fix remaining Squid issues raised during Emma experimentation
- Make non-contextual Code the default
- Make a release for Pilatus HOT 1
- Failed to generate semanticdb: repeated argument not allowed HOT 1
- Support for default values in class's methods
- Project Status? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from squid.