Could the Manifest generation be implemented by a macro?

40 views
Skip to first unread message

Andrés Testi

unread,
May 18, 2012, 3:49:59 PM5/18/12
to scala-...@googlegroups.com
Currently the compiler does magic to generate Manifests on demand:

def foo[T](implicit Manifest[T]) = ...

foo[FooClass]<<Compiler generates a Manifest for FooClass in the foo invocation point>>

Could this compiler task, be replaced by a macro in a future version of Scala?

object Predef{
  
  implicit def manifest[T]: Manifest[T] = macro manifestImpl

  def manifestImpl[T](c: Context): Expr[Manifest[T]] = {
    // generate a Manifest for T
    ...
  }
}

Regards.

- Andrés

Eugene Burmako

unread,
May 18, 2012, 3:52:48 PM5/18/12
to scala-debate

Eugene Burmako

unread,
May 18, 2012, 3:54:17 PM5/18/12
to scala-debate
Currently implicit macros are broken, so manifest materialization
macros are hardcoded into the compiler. Later on, before RC, I'm going
to fix macros, and the hardcode will be gone.

On May 18, 10:52 pm, Eugene Burmako <eugene.burm...@epfl.ch> wrote:
> Sure
>
> https://github.com/scalamacros/kepler/blob/1d70943d85ea61e19b1bd718ca...

Andrés Testi

unread,
May 18, 2012, 4:05:37 PM5/18/12
to scala-...@googlegroups.com
Cool! Even as experimental, macros are useful to prototype language improvements!
Thanks for your reply.

- Andrés
Reply all
Reply to author
Forward
0 new messages