--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
With macro annotations it is possible to create members in a companion object. Probably you could try to annotate them with STATIC, and probably that might work - didn't have time to check myself though.
Speaking of syntactic options, what exactly are you interested in?
class Days extends Enum(Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday)
Finally I didn't get the question about untyped macros. Could you elaborate?
Trees that get into a macro annotation expansion don't get typechecked, so you can write whatever you want inside the definition of the class and, as long as it's syntactically valid, you'll get a chance to read that whatever, analyzer it and emit whatever you want instead. Would that bring enough flexibility to support your use case?
It would work if it were valid Scala syntax :)
It would work if it were valid Scala syntax :)
Ok ... maybe I'm not getting then what untyped macros are about.
From my POV, being able to pass arbitrary trees to the macro is the important part of untyped macros ... without it, what's left?
--
--
The arbitrary trees still need to be constructed somehow. The scalac parser cannot construct trees for things that there aren't production rules for.
@Enum
class Days(val inGerman: String) extends HasName {
Monday("Montag")
Tuesday("Dienstag")
Wednesday("Mittwoch")
Thursday("Donnerstag")
Friday("Freitag")
Saturday("Samstag") { override def workingDay: Boolean = false }
Sunday("Sonntag") { override def workingDay: Boolean = false }
def abbreviation = name take 3
def workingDay: Boolean = true
}
trait HasName { def name: String }
--
Currently you cannot mix macro annotations and untyped macros. What would be your use case? Looks like for enums macro annotations alone should be enough.
On Tue, Aug 6, 2013 at 6:51 PM, Simon Ochsenreither <simon.och...@gmail.com> wrote:
Currently you cannot mix macro annotations and untyped macros. What would be your use case? Looks like for enums macro annotations alone should be enough.
So I can basically put arbitrary trees into the body of a class annotated with a macro as long as it can be parsed, without needing untyped macros?
--
Yes
It's also possible.
Macro annotations get the entire tree that represents an annottee. In our case that would be a ClassDef, and ClassDef contains a list of parents that you can freely change.
--
I think one could get away by emitting a companion object and profit from the fact scalac emits static forwarders for it in the companion class by default already.
What's the best way to define the class and get the object for free? I have looked into the Context API but didn't find an appropriate introduce??? method. Looks like this is 2.11 only.
--
--
Why are you not using quasiquotes?
We don't have introduceXXX anymore, and introduceTopLevel will be removed before the 2.11 release. The only way to emit a companion object is to put an annotation on a class, as described here: http://docs.scala-lang.org/overviews/macros/annotations.html.
We don't have introduceXXX anymore, and introduceTopLevel will be removed before the 2.11 release. The only way to emit a companion object is to put an annotation on a class, as described here: http://docs.scala-lang.org/overviews/macros/annotations.html.
Mhhh, maybe I'm misunderstanding the docs, but it reads like I would need to have the companion object already declared in the code to be able to emit members for that object. Is that correct?
--
--
What do you think?
--
Doesn't look like we in scalac emit this flag at all. Probably you'll need to do it in a compiler plugin that injects into backend. Miguel, Greg, could you comment?
Oh wow, looks like we're just one step from having enums just like you wanted, Simon.
I would probably not have time to implement that myself, but if you can give it a try, it would be very cool.
I believe code freeze for 2.11 is just a month away, but on the other hand it's the entire month away!
... in addition to implementing @Enum (which includes writing tests, updating the SIP, getting it accepted, deprecating scala.Enumeration and documenting the migration) which I all want to ship/fix/implement for 2.11.
Some of those might be close to the finish line, but estimating the amount of time it takes for the politics associated with it hasn't been really reliable in the past.
The ENUM is not set by Scala compiler anywhere (it's only used to represent types coming from Java) so backend doesn't support it in any way.I wouldn't be very against adding support for it but one would have to figure out exact semantics. For the start:
- should ENUM flag be pickled? (probably yes)
- would class file parser be confused by the fact that there's a scala class that has an enum flag?
- would referring to enums synthesized from scala files work?
I believe code freeze for 2.11 is just a month away, but on the other hand it's the entire month away!
Ouch ... that probably means I should start to prioritize things now. Off the top of my head, I come up with ...
- Avian support
- JavaScript backend
- Being able to recognize a value type at runtime
- Deprecating procedures
- Deprecating dangerous implicit widening conversions
- Deprecating “warning: Adapting argument list by inserting (): this is unlikely to be what you want.”
- Trying to get a reliable definition of what's in the default scope (instead of the current “whatever version of Java you might run” free-for-all)
- SI-5722 - classOf[T] support with Tags
- SI-6634 - Fix and specify Collection's remove method
- SI-6747 - Fix Range
- SI-6632 - Fix ListBuffer
- SI-7379 - Fix Option(null.asInstanceOf[Boolean])
... in addition to implementing @Enum (which includes writing tests, updating the SIP, getting it accepted, deprecating scala.Enumeration and documenting the migration) which I all want to ship/fix/implement for 2.11.
Hey guys,
want do you think of this? :D
Enum declaration:Saturday
@Enum
class Day {
Monday
Tuesday
Wednesday
Thursday
Friday
Sunday
}
I like the brevity, but I don't like rewriting expressions in the constructor as members.
For example, you have to know about the @Enum annotation to know that this method isn't called:def Monday = println("!"); @Enum class Day { Monday }
> The only limitation I found is that switch/case doesn't work in Java,
> because
>
> an enum switch case label must be the unqualified name of an enumeration
> constant
> case Day.Monday():
> ^
In case it is from Java, the Day. part is part of the problem. You are
not allowed to put in a case statement. (And it is usually not a method....)
"Not found: value Day" means that you need to have a symbol with term name Day in scope. Since you're no longer generating a companion, you no longer have such a symbol.
--
Scalac sneakily converts symbols from java class files into class+module combos, pushing static parts to modules.
Scalac sneakily converts symbols from java class files into class+module combos, pushing static parts to modules.
Thanks for the hint ... is there a way this mechanism can be leveraged for our use-case here? This way I might even get public fields to work, because they have to be represented somehow as symbols in the Scala AST.
--
Here's a pretty minimal reproduction: https://github.com/tpunder/sbt-example-paradise/commit/588a1aa1ff56feb43e2c28499d7610d7631ac6aaIf you comment out the macro paradise plugin it compiles fine. Also if you comment out the @BeanInfo annotation on the Bar object in Bar.scala it compiles fine.Let me know if I can do anything else to help.-Tim
On Tuesday, August 6, 2013 9:22:21 AM UTC-7, Eugene Burmako wrote:Thanks a lot for the crash report! It would be great if you could minimize the reproduction. I will gladly take a look.On 6 August 2013 17:46, Tim Underwood <timund...@gmail.com> wrote:
Hi Eugene,I tried adding the compiler plugin to my existing project so I could play with the new macro features but I get a compiler AssertionError (stack trace below). I haven't tried using any of the new macro features yet and the code compiles fine using Scala 2.10.2 without the macro paradise plugin.I'm trying to minimize the code that causes the error but haven't been successful so far. Does the stack trace give you any hints as to what the problem might be?Thanks,-TimStack Trace:at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1210)at scala.reflect.internal.Symbols$ModuleClassSymbol.implicitMembers(Symbols.scala:3095)at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.getClassParts$1(Implicits.scala:1073)at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.scala$tools$nsc$typechecker$Implicits$ImplicitSearch$$getParts$1(Implicits.scala:1113)at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.scala$tools$nsc$typechecker$Implicits$ImplicitSearch$$getParts$1(Implicits.scala:1120)at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.scala$tools$nsc$typechecker$Implicits$ImplicitSearch$$getParts$1(Implicits.scala:1120)at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.companionImplicitMap(Implicits.scala:1147)at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.scala$tools$nsc$typechecker$Implicits$ImplicitSearch$$implicitsOfExpectedType(Implicits.scala:1167)at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.bestImplicit(Implicits.scala:1427)at scala.tools.nsc.typechecker.Implicits$class.inferImplicit(Implicits.scala:82)at org.scalalang.macroparadise.Plugin$$anon$1.inferImplicit(Plugin.scala:25)at scala.tools.nsc.typechecker.Implicits$class.inferImplicit(Implicits.scala:40)at org.scalalang.macroparadise.Plugin$$anon$1.inferImplicit(Plugin.scala:25)at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$wrapImplicit$1(Typers.scala:202)at scala.tools.nsc.typechecker.Typers$Typer.inferView(Typers.scala:209)at scala.tools.nsc.typechecker.Typers$Typer.inferView(Typers.scala:180)at scala.tools.nsc.typechecker.Typers$Typer$$anon$2$$anonfun$isCoercible$1.apply$mcZ$sp(Typers.scala:105)at scala.tools.nsc.typechecker.Typers$Typer$$anon$2$$anonfun$isCoercible$1.apply(Typers.scala:103)at scala.tools.nsc.typechecker.Typers$Typer$$anon$2$$anonfun$isCoercible$1.apply(Typers.scala:103)at scala.reflect.internal.Types$UndoLog.undo(Types.scala:186)at scala.tools.nsc.typechecker.Typers$Typer$$anon$2.isCoercible(Typers.scala:102)at scala.tools.nsc.typechecker.Infer$Inferencer.scala$tools$nsc$typechecker$Infer$Inferencer$$isCompatible(Infer.scala:425)at scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$isCompatibleArgs$1.apply(Infer.scala:428)at scala.tools.nsc.typechecker.Infer$Inferencer$$anonfun$isCompatibleArgs$1.apply(Infer.scala:428)at scala.collection.LinearSeqLike$class.corresponds(LinearSeqLike.scala:76)at scala.collection.immutable.List.corresponds(List.scala:84)at scala.tools.nsc.typechecker.Infer$Inferencer.isCompatibleArgs(Infer.scala:428)at scala.tools.nsc.typechecker.Infer$Inferencer.typesCompatible$1(Infer.scala:814)at scala.tools.nsc.typechecker.Infer$Inferencer.scala$tools$nsc$typechecker$Infer$Inferencer$$isApplicable(Infer.scala:833)at scala.tools.nsc.typechecker.Infer$Inferencer.tryTupleApply$1(Infer.scala:809)at scala.tools.nsc.typechecker.Infer$Inferencer.scala$tools$nsc$typechecker$Infer$Inferencer$$isApplicable(Infer.scala:856)at scala.tools.nsc.typechecker.Infer$Inferencer.isApplicableSafe(Infer.scala:877)at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$63.apply(Typers.scala:3146)at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$63.apply(Typers.scala:3135)at scala.collection.TraversableLike$$anonfun$filter$1.apply(TraversableLike.scala:264)at scala.collection.immutable.List.foreach(List.scala:318)at scala.collection.TraversableLike$class.filter(TraversableLike.scala:263)at scala.collection.AbstractTraversable.filter(Traversable.scala:105)at scala.reflect.internal.Symbols$Symbol.filter(Symbols.scala:1658)at scala.tools.nsc.typechecker.Typers$Typer.preSelectOverloaded$1(Typers.scala:3135)at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:3163)at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4589)at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4621)at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5526)at org.scalalang.macroparadise.typechecker.Analyzer$$anon$1.org$scalalang$macroparadise$typechecker$Typers$ParadiseTyper$$super$typed1(Analyzer.scala:17)at org.scalalang.macroparadise.typechecker.Typers$ParadiseTyper$class.typed1(Typers.scala:44)at org.scalalang.macroparadise.typechecker.Analyzer$$anon$1.typed1(Analyzer.scala:17)at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5604)at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5683)at scala.tools.nsc.typechecker.Typers$Typer.computeType(Typers.scala:5770)at scala.tools.nsc.typechecker.Namers$Namer.assignTypeToTree(Namers.scala:834)at scala.tools.nsc.typechecker.Namers$Namer.valDefSig(Namers.scala:1315)at scala.tools.nsc.typechecker.Namers$Namer.getSig$1(Namers.scala:1456)at scala.tools.nsc.typechecker.Namers$Namer.typeSig(Namers.scala:1465)at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1$$anonfun$apply$1.apply$mcV$sp(Namers.scala:731)at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1$$anonfun$apply$1.apply(Namers.scala:730)at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1$$anonfun$apply$1.apply(Namers.scala:730)at scala.tools.nsc.typechecker.Namers$Namer.scala$tools$nsc$typechecker$Namers$Namer$$logAndValidate(Namers.scala:1498)at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1.apply(Namers.scala:730)at scala.tools.nsc.typechecker.Namers$Namer$$anonfun$monoTypeCompleter$1.apply(Namers.scala:729)at org.scalalang.macroparadise.typechecker.Namers$$anon$3.completeImpl(Namers.scala:704)at scala.tools.nsc.typechecker.Namers$LockingTypeCompleter$class.complete(Namers.scala:1621)at org.scalalang.macroparadise.typechecker.Namers$$anon$3.complete(Namers.scala:702)at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1229)at scala.reflect.internal.Symbols$Symbol.initialize(Symbols.scala:1365)at org.scalalang.macroparadise.typechecker.Typers$ParadiseTyper$class.typed1(Typers.scala:39)at org.scalalang.macroparadise.typechecker.Analyzer$$anon$1.typed1(Analyzer.scala:17)at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5604)at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2926)at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$60.apply(Typers.scala:3030)at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$60.apply(Typers.scala:3030)at scala.collection.immutable.List.loop$1(List.scala:170)at scala.collection.immutable.List.mapConserve(List.scala:186)at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3030)at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1919)at org.scalalang.macroparadise.typechecker.Analyzer$$anon$1.org$scalalang$macroparadise$typechecker$Typers$ParadiseTyper$$super$typedTemplate(Analyzer.scala:17)at org.scalalang.macroparadise.typechecker.Typers$ParadiseTyper$class.typedTemplate(Typers.scala:51)at org.scalalang.macroparadise.typechecker.Analyzer$$anon$1.typedTemplate(Analyzer.scala:17)at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1759)at org.scalalang.macroparadise.typechecker.Analyzer$$anon$1.org$scalalang$macroparadise$typechecker$Typers$ParadiseTyper$$super$typedClassDef(Analyzer.scala:17)at org.scalalang.macroparadise.typechecker.Typers$ParadiseTyper$class.typedClassDef(Typers.scala:62)at org.scalalang.macroparadise.typechecker.Analyzer$$anon$1.typedClassDef(Analyzer.scala:17)at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5545)at org.scalalang.macroparadise.typechecker.Analyzer$$anon$1.org$scalalang$macroparadise$typechecker$Typers$ParadiseTyper$$super$typed1(Analyzer.scala:17)at org.scalalang.macroparadise.typechecker.Typers$ParadiseTyper$class.typed1(Typers.scala:44)at org.scalalang.macroparadise.typechecker.Analyzer$$anon$1.typed1(Analyzer.scala:17)at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5604)at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2926)at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$60.apply(Typers.scala:3030)at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$60.apply(Typers.scala:3030)at scala.collection.immutable.List.loop$1(List.scala:170)at scala.collection.immutable.List.mapConserve(List.scala:186)at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3030)at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5263)at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5549)at org.scalalang.macroparadise.typechecker.Analyzer$$anon$1.org$scalalang$macroparadise$typechecker$Typers$ParadiseTyper$$super$typed1(Analyzer.scala:17)at org.scalalang.macroparadise.typechecker.Typers$ParadiseTyper$class.typedPackageDef$1(Typers.scala:35)at org.scalalang.macroparadise.typechecker.Typers$ParadiseTyper$class.typed1(Typers.scala:43)at org.scalalang.macroparadise.typechecker.Analyzer$$anon$1.typed1(Analyzer.scala:17)at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5604)at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5666)at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:99)at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:464)at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:91)at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:91)at scala.collection.Iterator$class.foreach(Iterator.scala:727)at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:91)at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1583)at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1557)at scala.tools.nsc.Global$Run.compileSources(Global.scala:1553)at scala.tools.nsc.Global$Run.compile(Global.scala:1662)at xsbt.CachedCompiler0.run(CompilerInterface.scala:123)at xsbt.CachedCompiler0.run(CompilerInterface.scala:99)at xsbt.CompilerInterface.run(CompilerInterface.scala:27)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:601)at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:102)at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:48)at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply$mcV$sp(AggressiveCompile.scala:98)at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:98)at sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileScala$1$1.apply(AggressiveCompile.scala:98)at sbt.compiler.AggressiveCompile.sbt$compiler$AggressiveCompile$$timed(AggressiveCompile.scala:159)at sbt.compiler.AggressiveCompile$$anonfun$3.compileScala$1(AggressiveCompile.scala:97)at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:142)at sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:86)at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:38)at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:36)at sbt.inc.Incremental$.cycle(Incremental.scala:73)at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:33)at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:32)at sbt.inc.Incremental$.manageClassfiles(Incremental.scala:41)at sbt.inc.Incremental$.compile(Incremental.scala:32)at sbt.inc.IncrementalCompile$.apply(Compile.scala:26)at sbt.compiler.AggressiveCompile.compile2(AggressiveCompile.scala:150)at sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:70)at sbt.compiler.AggressiveCompile.apply(AggressiveCompile.scala:45)at sbt.Compiler$.apply(Compiler.scala:70)at sbt.Defaults$.sbt$Defaults$$compileTaskImpl(Defaults.scala:722)at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:716)at sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:716)at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)at sbt.std.Transform$$anon$4.work(System.scala:64)at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)at sbt.Execute.work(Execute.scala:244)at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)at java.util.concurrent.FutureTask.run(FutureTask.java:166)at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)at java.util.concurrent.FutureTask.run(FutureTask.java:166)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)at java.lang.Thread.run(Thread.java:722)
On Monday, August 5, 2013 6:53:16 AM UTC-7, Eugene Burmako wrote:Hi folks,
I've just released a new version of macro paradise, which represents a significant revamp and introduces new features. You can read the full text of the announcement at http://scalamacros.org/news/2013/08/05/macro-paradise-2.0.0-snapshot.html.
Short summary:
* Now a compiler plugin that works with Scala 2.10.2
* Backports quasiquotes from 2.11.0-M4
* Also provides freshly implemented macro annotations
Your feedback is very welcome!
Cheers,
Eugene
Why are you not using quasiquotes?
I hope this is helpful!
Thanks,
Simon
I think it is pretty unfortunate that the wrong way is easy, readable and concise while the right way is more complicated and verbose.
Is there a way to fix this?
By the way, I think the error messages caused by the assertions could be made more useful, e. g. "java.lang.Enum is not a type" instead of "java.lang.Enum".
Thanks and bye,
Simon
--
val Enum = newTypeName("_root_.java.lang.Enum")
tq"""$Enum[$className]"""
On Sat, Aug 10, 2013 at 11:52 PM, Simon Ochsenreither <simon.och...@gmail.com> wrote:
Cool! Thanks, good to know that you are aware of the issues already.
What's the battle plan here?
--
1) Denys will probably have something more to tell, but to me it looks like the nme.CONSTRUCTOR approach is the only possible option.
2) Do you mean 3, or there's something else to it?
3) Do you get these warnings just by compiling sources that contain quasiquotes, or I need to do something special to reproduce them?
4) What do you mean always recompiled?
--
1) I think that's a good idea. Mind opening an issue / submitting a pull request?
2-3) Is it reproducible in 2.11.0-M4? If yes, then I'd submit an issue to JIRA.
4) I see. So when you modify a quasiquote in a macro, the entire project that uses that macro gets recompiled?
--
The ENUM is not set by Scala compiler anywhere (it's only used to represent types coming from Java) so backend doesn't support it in any way.I wouldn't be very against adding support for it but one would have to figure out exact semantics. For the start:
- should ENUM flag be pickled? (probably yes)
- would class file parser be confused by the fact that there's a scala class that has an enum flag?
- would referring to enums synthesized from scala files work?
These are good questions!
I think a pretty idiomatic and minimal change would look like this: https://github.com/soc/scala/compare/topic;enums?expand=1
There are two isEnum methods, which aren't strictly required, so they could also be left out.
This way, we don't have any special-cased code anywhere in the compiler, it just wires up the a modifier flag to the appropriate ACC_ENUM, just like for all the other class file bits.
Creating enums would happen completely in the macro.
Any idea what's the issue here?
Thanks,
Simon
--
--
You also need to patch noFinishGetterSetter
And then it calls enterSym on each member. Following enterSym up to enterValDef reveals an interesting hardcode that forcefully sets types of STABLE | JAVA vals to ConstantType(Constant(tree.symbol)) [1]. That's the culprit, and that needs to be worked around.
--
Ideas/suggestions/opinions?
Newest code is here:
Scala: https://github.com/soc/scala/commits/topic/enums-2.10
Enums: https://github.com/soc/enum-paradise/tree/java-enums-via-macro-annotations
Please let me know what you think!
Thanks,
Simon
- The initialization of the static fields ends up in the constructor instead of the static initializer:
I think this is only a matter of adding a check for STATIC somewhere, but I haven't found the right place yet.
Current status:
public class JavaDayConsumer {
public static void main(String[] args) {
System.out.println(Day.Monday);
}
}
Compare ...
$ javap JavaDay
Compiled from "JavaDay.java"
public final class scalax.JavaDay extends java.lang.Enum<scalax.JavaDay> {
public static final scalax.JavaDay Monday;
public static final scalax.JavaDay Tuesday;
public static final scalax.JavaDay Wednesday;
public static final scalax.JavaDay Thursday;
public static final scalax.JavaDay Friday;
public static final scalax.JavaDay Saturday;
public static final scalax.JavaDay Sunday;
public static scalax.JavaDay[] values();
public static scalax.JavaDay valueOf(java.lang.String);
static {};
}
... with ...
$ javap Day
Warning: Binary file Day contains scalax.Day
Compiled from "Day.scala"
public class scalax.Day extends java.lang.Enum<scalax.Day> {
--
--
--
To unsubscribe from this group and stop receiving emails from it, send an email to scala-language+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
Instantiation of a macro annotation (along with its arguments) is currently packed into c.macroApplication.
--
I first tried reboot full, then I also deleted the .ivy2 folder. Both without success ...
--