-
Notifications
You must be signed in to change notification settings - Fork 559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup - remove unused parameter with magic numbers #22871
base: blead
Are you sure you want to change the base?
Conversation
On Sat, Dec 21, 2024 at 01:05:22PM -0800, Branislav Zahradník wrote:
PR is adding new macro `NewOp_v542` without this unused parameter.
Macro name is also POC of adding Perl version when macro will be added to maintain reasonable
backward compatibility by version string in symbol name.
I can't see what practical gain you get by including the version number in
the new macro. It just seems to make it worse.
…--
Modern art:
"That's easy, I could have done that!"
"Ah, but you didn't!"
|
Symbol name is describes behaviour. With new version behavior changed (3 parameters instead of 4). It's same like with humans. Look for example at French kings, there were for example:
They have version in names as well, so you can distinguish one born in 17th century and another in 18th. Same is for this pattern - you can introduce new symbol, new behaviour and still provide old one so there is no need to modify every old code simultaneously. |
On Mon, Dec 23, 2024 at 04:36:25AM -0800, Branislav Zahradník wrote:
> I can't see what practical gain you get by including the version number in the new macro. It just seems to make it worse.
Symbol name is describes behaviour. With new version behavior changed (3
parameters instead of 4).
But the version number tells you *nothing* about the behaviour.
We have a long history in perl (as do many other projects) of naming
newer variants of an API function. The new name usually tries to use some
sort of simple mnemonic to indicate its changed behaviour.
For example:
my_atof2() and my_atof3() - two- and three-arg variants of my_atof(); or
av_fetch_simple() - an optimised version of av_fetch() applicable in some
circumstances; or
newSVsv_flags() - a variant of newSVsv() that takes an extra 'flags'
argument.
Is newSVsv_530() easier for a developer to understand than
newSVsv_flags()? And if not, is there any other technical benefit of using
the newSVsv_530() naming convention?
…--
Technology is dominated by two types of people: those who understand what
they do not manage, and those who manage what they do not understand.
|
Well, difference is that I'm using release numbers and not version per symbol. I'm not using version to provide different behaviour with of same symbol. It will still be
It may not tell much about actual behaviour, but it tells which version of behaviour and it ensures that it will be preserved. Following this pattern ensures 100% forward compatibility (eg: no need to recompile XS with each release). It will even (with some tweaks) allow to propagate newer grammar into older versions - this is root assumption behind idea of exact |
NewOp's first argument has been unused since 2007 but remains required, polluting the codebase with magic numbers. A new macro is provided that eliminates these magic numbers while maintaining backward/forward compatibility through Perl version identification in its name.
First parameter of NewOpSz is unused since 2007.
0032ed0
to
63ab1d4
Compare
NewOp
's first parameter is unused since 2007, polluting codebase with magic numbers.PR is adding new macro
NewOp_v542
without this unused parameter.Macro name is also POC of adding Perl version when macro will be added to maintain reasonable
backward compatibility by version string in symbol name.