From 0599ab00c293b692ef7868cfd5e3e430b32146e3 Mon Sep 17 00:00:00 2001 From: Will Sargent Date: Sun, 23 May 2021 10:11:15 -0700 Subject: [PATCH] One does not simply walk into Mordor --- _overviews/scala3-macros/tutorial/quotes.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_overviews/scala3-macros/tutorial/quotes.md b/_overviews/scala3-macros/tutorial/quotes.md index da92bcec54..fe99cb4260 100644 --- a/_overviews/scala3-macros/tutorial/quotes.md +++ b/_overviews/scala3-macros/tutorial/quotes.md @@ -25,7 +25,7 @@ Due to some technical considerations we only allow it directly within `inline` d It is possible to write a quote within a quote, but usually when we write macros we do not encounter such code. ## Level consistency -One cannot simple write any arbitrary code within quotes and within splices. +One cannot simply write any arbitrary code within quotes and within splices. A part of the program will live at compile-time and the other will live at runtime. Consider the following ill-constructed code. @@ -45,7 +45,7 @@ def myBadCounter2(using Quotes): Expr[Int] = '{ ${ x += 1; 'x } } ``` -Clearly, this should work as the variable does not exist yet. +Clearly, this should not work as the variable does not exist yet. To make sure you can only write programs that do not contain these kinds of problems we restrict the set of references to variable and other definitions. We introduce _levels_ as a count of the number of quotes minus the number of splices surrounding an expression or definition.