Is separate compilation something we can expect to be present when
2.10.0 comes out, or do you plan to "fix" it so macros can be compiled
together with code that uses before that?
--
Daniel C. Sobral
I travel to the future all the time.
It means two things:
1. Files defining macros cannot use them.
2. Software that uses self-defined macros need to be built with two
compilation steps.
The easiest way I can think to achieve this is to segregate all macros
into "macro" packages, and introduce two-step-compilation in SBT where
source from directories named "macro" are compiled in the first step,
and then the second step puts the target directory from the first in
the classpath (not default, iirc) and compiles everything except stuff
inside directories named "macro". The package segregation can be
avoided if you ignore Java convention.
This is not trivial, or, at least, I don't see a trivial way of doing
it. Consider how you'll go about changing Scala's build so that it can
use its own macros, for instance.
Now, macros are not a must-have feature for every piece of software --
Scala has lived without them for a long time, after all. Having
libraries that define useful macros will be useful all on its own, and
having the possibility of using macros, even if makes builds more
complex, will be a big plus. So I'm tagging this as an inconvenient
requirement that can be handled latter, or not at all, if the tooling
makes it mostly painless. I could put all macros on a subproject, for
instance, and have the rest of the code depend on it.
This discussion brought another question to my mind, however: will I
be able to define a macro and then use it in a single REPL session, or
will I have to compile all my macros beforehand?
What's the story for Eclipse? Ie. the presentation and build compilers?
Cheers,
Miles
--
Miles Sabin
tel: +44 7813 944 528
gtalk: mi...@milessabin.com
skype: milessabin
g+: http://www.milessabin.com
http://twitter.com/milessabin
http://www.chuusai.com/
Speaking of REPL, I have a feeling that everything will be okay, since
my impression is that REPL compiles every line in a separate
compilation run. Anyways, I'm going to summon Paul (cc'd) to clarify
this situation.
I was trying to use the alphakeplerdemo, but I'm getting this error:
dcs@ayanami:~/github/alphakeplerdemo (skeleton)$ scalac -Xmacros Rx.scala
Rx.scala:24: error: unbound wildcard type
def macro forAllMatches(pattern: String, f: _): Unit = {
^
one error found
Shouldn't it have worked?
The 2.10 release seems to be one of the largest feature releases ever, even without macros. I assume Typesafe wants to release it before (or on) ScalaDays, so the time is running out fast for testing.
Because they said[1] that Scala 2.10 is released in the beginning of 2012. And April is probably already a stretched term for "beginning".
The meeting notes also stopped being publsihed months ago,
The first error happens because you use sbt.
The second error happens because toolboxes reject already typed trees. That's because of non-idempotency of typer. Though, I wonder why it happens - you just did resetAllAttrs.