December 2021 Archives

Do-It-Yourself Lexical Pragmas

The phrase "Lexical Pragmas" is probably both redundant and ungrammatical (the correct plural of "pragma" being "pragmata", I believe). But the use of "pragma" to mean "Perl module with an all-lower-case name" is fairly common, and I wanted to make clear that this was not what I was talking about. This blog entry is about writing Perl code whose configuration changes are limited to a lexical scope, just like built-in pragmata such as strict or /users/tom_wyant/2021/12/index.html

My Favorite Warnings: ambiguous

... computer language design is just like a stroll in the park. Jurassic Park, that is. -- Larry Wall

Perl's grammar is inherently ambiguous. That is, it is possible for a syntactically correct chunk of Perl to have more than one valid interpretation. Maybe this is because Larry Wall is a linguist? After all, natural languages are full of ambiguity.

The ambiguous warning is part of the group syntax; that is…

My Favorite Warnings: syntax

Warnings category syntax contains a number of sub-categories representing possibly-problematic syntax. These include ambiguous syntax, problematic bareword usage, invalid printf conversions, and more. But there are also syntax diagnostics that do not fall under any of the sub-categories. These tend to be a miscellaneous group, and a normal-sized blog post can do no more than to give a sample.

What brought this to my attent…

My Favorite Warnings: shadow

Who knows what evil lurks in the hearts of men? The Shadow knows!

OK, Perl does not literally have a warning about a 1930's pulp fiction and radio serial character. But Perl 5.28 introduced shadow as a new warning category for cases where a variable is redeclared in the same scope. Previously, such warnings were under misc.

To tickle this it is su…

Closures

A casual remark about closures which I made in My Favorite Warnings: redefine touched off a long off-topic exchange with Aristotle that I thought ought to be promoted to a top-level blog entry. The big thing I learned was that any Perl subroutine can be a closure. The rest of this blog will try to make clear why I now believe this. The words are my own, as are any errors or misconceptions.

The second sentence of ="h…

About Tom Wyant

user-pic I blog about Perl.