A Peek into Pugs Internals #17

Pugs AST

if 42 { say "hello" }
 else { say "oh no!" }

Why does `42` parse as `Val (VInt 42)`, and not just `42`? Because an `if` can take any expression as the condition; this one just happens to be a value. And Perl distinguishes between different types of values, so this is an integer and not, say a sting. If I had a more complex condition here, we'd just look at a more complex AST for this.
Copyright © 2006 Gaal Yahas