Commit 5e26279
committed
Formalize symbol names reserved for Perl's use in XS
This creates a regular expression pattern of names that we feel free to
expose to XS code's namespace. Hence they are names reserved for our use,
and should any conflicts arise, the module needs to change, not us.
Naturally, the pattern is pretty restrictive.
Any symbol beginning with "PL_"
Any symbol containing perl, Perl, or PERL, usually delimitted on
both sides so as to keep it from being part of a larger word.
Any other spelling that we expose could be considered to pollute the XS
code space. We have felt free to do that all the time. Any new
function's short name will do that.
And we generally feel free to create macros with arbitrary names which
could conflict with an existing XS name.
Some important potential conflicts are:
New keywords: We create an exposed KEY_foo macro. Some existing
modules use some of these. My grep of CPAN shows maybe a dozen of these
get used; mostly KEY_END.
config.h is full of symbols like HAS_foo, I_bar, and others that are all
exposed. I don't imagine we can claim to reserve any symbol beginning
with either HAS_ or I_. And I don't know what to do here.
Informally, myself and others have used a trailing underscore to
indicate a private symbol. There are a few distributions that use some
of these anyway. And there has been pushback when new short symbols
that use this convention have been added.
I would like to get a formal rule about use of this convention. There
are 200+ of these currently. We could reserve any names with trailing
underscores, or if that is too much, any ending in, say, '_pl_' or
'_PL_'.
We have 3000+ undocumented macro names that don't end in underscores and
which are currently visible to XS code. This number includes the
KEY_foo ones, but not the ones in config.h.
To deal with namespace pollution, we have had the -DNO_SHORT_NAMES
Configure option for use just with embedded perls. This hasn't worked
at least since we added inline functions, and it always applied to only
functions. I have a WIP to get this to work again, and to extend it to
work with documented macros. It just occurred to me how to make this be
customizable, so that downstream someone could add a list of symbols
that should only exist as 'Perl_foo', and then recompile, leaving short
names for everything not in the list.1 parent 55c5b50 commit 5e26279
1 file changed
+25
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
107 | 128 | | |
108 | 129 | | |
109 | 130 | | |
110 | 131 | | |
111 | 132 | | |
112 | 133 | | |
113 | 134 | | |
114 | | - | |
| 135 | + | |
115 | 136 | | |
116 | 137 | | |
117 | 138 | | |
| |||
1336 | 1357 | | |
1337 | 1358 | | |
1338 | 1359 | | |
| 1360 | + | |
| 1361 | + | |
1339 | 1362 | | |
1340 | 1363 | | |
1341 | 1364 | | |
| |||
4729 | 4752 | | |
4730 | 4753 | | |
4731 | 4754 | | |
4732 | | - | |
4733 | | - | |
4734 | | - | |
| 4755 | + | |
4735 | 4756 | | |
4736 | 4757 | | |
4737 | 4758 | | |
| |||
0 commit comments