--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Basically, I'm trying to build a simplified async block similar to what is explained in:
http://docs.scala-lang.org/sips/pending/async.html
That block is based on a macro that builds a state machine class. The class that I have to build has the following skeleton:
class MyStateMachine extends AnyRef {
var result$async : scala.concurrent.Promise[Boolean] = scala.concurrent.Promise.apply[Boolean]();
def resume$async : Unit = try {
};
def apply(tr: scala.util.Try[Boolean]) {
...
}
def apply(): Unit = resume$async
}
What I'm trying to build apart is the method "apply(tr:scala.util.Try)". This method can call the promise "result$async" to give the result of the computation of the async block.
I'd like to be able to build that method outside of the construction of the state machine class to then add it to the class and make sure that the "result$async" variable refers to the field of the class.
--
--
To unsubscribe from this group and stop receiving emails from it, send an email to scala-internals+unsubscribe@googlegroups.com.
case class SymLookup(stateMachineClass: Symbol, applyTrParam: Symbol) {def stateMachineMember(name: TermName): Symbol =stateMachineClass.info.member(name)def memberRef(name: TermName): Tree =gen.mkAttributedRef(stateMachineMember(name))}That is used in async to get a symbol and generate a reference for a term name. However this is used by doing quite a complex setup based on Global that seems like a global context for doing transformations. Is there a nicer way to do this or should I resort to the set up that the guys in async have used?
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
Hello,
I've tried printing symbols and types but I don't see anything weird.The error appears when I generate a call to:I generate a class with an apply with the following type (scala.util.Try[Boolean]) => Unitthen inside the class I make the following call:myFuture.onComplete(this)(myExecContext)What gets transformed into:myFuture.onComplete((result : Try[Boolean]) => MyStateMachine.this.apply(result))(myExecContext)What seems to make sense.However when I compile after the expansion of the macro I get the TypeError. And when debugging the compilation I see that the problem is launched with the following term:$anonfun.this.$outer.$outer().$outer().<none> of type ApplyWhat do the $outer field contains and why could my anonymous function try to access it?
Hello Jason,This is the really small example that I've prepared for testing:
My bad, I misunderstood. The project I'm working on is a project that I'm developing for a course on Conception of Languages that is available at:As you'll see I've tried to create a simplified version of scala/async using some pieces of your code so I guess that'll make it easy for you to understand what's going on in the code. This being my first project with macros and due to my lack of understanding of the compiler the project is full of code for debugging, and rests of tests that I've done to try to figure out what was going on so I apologize in advance for the crap that you'll find inside : ).
Hello,I'm having problems again and I think it's again a problem with the owner of my symbol, event though I've tried all possible ways to assign it the right owner. Basically I'm creating a field for my class by creating the valdef and then adding it to the template of my class. Finally I change the owner of my valdef to the class symbol but even after typechecking the symbol table of my class doesn't contain any reference to the field what makes compilation fail in a phase that generates intermediate code.Am I missing any step in the creation of a field inside a class?