in reply to Re^2: why does Perl eval have a strange terminator?
in thread why does Perl eval have a strange terminator?

I suppose I didn't understand that a simple statement can be, the same time BE a compound statement

Something is either a simple statement or a compound statement, not both.

But one can include the other.


And eval is neither a simple nor a compound statement. As I've already said, eval is an operator (like +, and and time), not a type of statement.

Operators can include blocks and thus statements:

Replies are listed 'Best First'.
Re^4: why does Perl eval have a strange terminator?
by perlfan (Parson) on Jun 24, 2022 at 20:11 UTC
    Try::Tiny requires a ;, and if you investigate why it is because it is implemented using prototypes.
    sub try (&;@) { ... sub catch (&;@) { ... sub finally (&;@) { ...
    I am not suggesting "eval BLOCK" is implemented using prototypes, but one could implement their own that would literally become a drop-in replacement (since the ; is likey already there. FWIW, (&;@) means the BLOCK param is coerced into a coderef, then optionally (after that ;), which allows something like the:
    try { } catch { } finally { };
    So now the POD seems to make a little more sense.