Hi all. I've got a bit of a silly question for yo...
# compiler
d
Hi all. I've got a bit of a silly question for you. In the grammar,
atomicExpression
includes a number of things that can be evaluated, like
literalConstant
and
functionLiteral
. Even the different
jump
structures (like
throw
and
return
) appear to technically evaluate to
Nothing
. But the list also includes
loop
, which doesn't appear to be an expression. In fact, if you try to assign a
for
loop to a variable, the compiler says that "For is not an expression, and only expressions are allowed here." So, I was wondering, why does
loop
show up as part of
atomicExpression
in the grammar? Is there some context in which loops can be evaluated?
u
No, loops are never treated as expressions, except in the parser. I suppose it was just easier to treat everything as expression in the grammar and prohibit non-expressions such as loops later in the resolution
👍 1
d
Great, thanks @udalov!