Skip to content

Is the meta programming allowed in REPL? #5551

Closed
@plokhotnyuk

Description

@plokhotnyuk

I have tried to run an example from the Principled Meta Programming doc page.

  1. It seems that some import is missing to compile with the showExpr call.
  2. Even after successful compilation without that call I cannot use the assert macro:
andriy@notebook:~/Downloads/dotty-0.10.0/bin$ ./dotr
Starting dotty REPL...
scala> import scala.quoted._                                                                                                                                                                                       
     | 
     | inline def assert(expr: => Boolean): Unit =
     |   ~ assertImpl('(expr))
     | 
     | def assertImpl(expr: Expr[Boolean]) =
     |   '{ if !(~expr) then throw new AssertionError("failed assertion")}
def assert(expr: => Boolean): Unit
def assertImpl(expr: quoted.Expr[Boolean]): quoted.Expr[Unit]

scala> assert(0 == 0)
1 |assert(0 == 0)
  |^^^^^^^^^^^^^^
  |Could not find macro class rs$line$1$ in classpath. The most common reason for that is that you apply macros in the compilation run that defines them

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions