-
Notifications
You must be signed in to change notification settings - Fork 601
Commit 3a90558
committed
Gain control of macro namespace visibility
This commit undefines all macros that are visible to XS code but
shouldn't be. This stops macro namespace pollution by perl.
It works by changing embed.h to have two modes, controlled by a #ifdef
that is set by perl.h. perl.h now #includes embed.h twice. The first
time works as it always has. The second sets the #ifdef, and causes
embed.h to #undef the macros that shouldn't be visible. This call is
just before perl.h returns to its includer, so that these macros have
come and gone before the file that #included perl.h is affected by them.
The list of macros is determined by the visibility given by the apidoc
lines documenting them, and by painstaking experiments with our test
suite. Those experiments, and some manual inspection, have produced
three long lists of items beyond what the apidoc lines currently give.
One list is for items that the re extension to Perl requires.
A second list is for items that other Perl extensions require.
The third list is for items that at least one module shipped with perl
requires (or that I know something on CPAN requires) even though the
items aren't marked as being visible. There are over 700 items on this
list. And smoking cpan with this will add others.
The experiments were done automatically, and I have not manually done
much manual inspection.
I have wanted this ability to happen for a long time; and now things
have come together to enable it.
This allows us to have a clear-cut boundary with CPAN.
It means you can add macros that have internal-only use without having
to worry about making them likely not to clash with user names.
It shows precisely what our names are that are visible to CPAN, and we
can change some of them to be less likely to clash.1 parent dc9703c commit 3a90558Copy full SHA for 3a90558
0 commit comments