From 8344c53b0476156f5b844e79943a889043ea7145 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Mon, 7 Aug 2023 14:11:31 +0100 Subject: [PATCH] Remove `experimental::builtin` warnings from most of the builtin.c functions Removes the experimental status and associated `experimental::builtin` warning from most of the functions in the `builtin::` space. Still remaining experimental are: * is_bool - because stable boolean tracking was only recently introduced and may not have been thoroughly tested yet * created_as_string, created_as_number - similar * export_lexically - because lexical export of subs is equally still quite new and may need more testing --- builtin.c | 56 +++++++++++++++++++----------------------- lib/builtin.pm | 19 ++++++++------ pod/perlexperiment.pod | 4 +-- t/lib/warnings/builtin | 27 -------------------- 4 files changed, 39 insertions(+), 67 deletions(-) diff --git a/builtin.c b/builtin.c index a5f9f6c9d222..1d1f60150a78 100644 --- a/builtin.c +++ b/builtin.c @@ -21,6 +21,7 @@ struct BuiltinFuncDescriptor { XSUBADDR_t xsub; OP *(*checker)(pTHX_ OP *, GV *, SV *); IV ckval; + bool is_experimental; }; #define warn_experimental_builtin(name, prefix) S_warn_experimental_builtin(aTHX_ name, prefix) @@ -68,7 +69,6 @@ XS(XS_builtin_true); XS(XS_builtin_true) { dXSARGS; - warn_experimental_builtin("true", true); if(items) croak_xs_usage(cv, ""); XSRETURN_YES; @@ -78,7 +78,6 @@ XS(XS_builtin_false); XS(XS_builtin_false) { dXSARGS; - warn_experimental_builtin("false", true); if(items) croak_xs_usage(cv, ""); XSRETURN_NO; @@ -93,8 +92,6 @@ static OP *ck_builtin_const(pTHX_ OP *entersubop, GV *namegv, SV *ckobj) { const struct BuiltinFuncDescriptor *builtin = NUM2PTR(const struct BuiltinFuncDescriptor *, SvUV(ckobj)); - warn_experimental_builtin(builtin->name, false); - SV *prototype = newSVpvs(""); SAVEFREESV(prototype); @@ -123,13 +120,12 @@ XS(XS_builtin_func1_scalar) dXSARGS; dXSI32; - warn_experimental_builtin(PL_op_name[ix], true); - if(items != 1) croak_xs_usage(cv, "arg"); switch(ix) { case OP_IS_BOOL: + warn_experimental_builtin(PL_op_name[ix], true); Perl_pp_is_bool(aTHX); break; @@ -174,8 +170,6 @@ XS(XS_builtin_trim) { dXSARGS; - warn_experimental_builtin("trim", true); - if (items != 1) { croak_xs_usage(cv, "arg"); } @@ -342,8 +336,6 @@ XS(XS_builtin_func1_void) dXSARGS; dXSI32; - warn_experimental_builtin(PL_op_name[ix], true); - if(items != 1) croak_xs_usage(cv, "arg"); @@ -398,7 +390,8 @@ static OP *ck_builtin_func1(pTHX_ OP *entersubop, GV *namegv, SV *ckobj) { const struct BuiltinFuncDescriptor *builtin = NUM2PTR(const struct BuiltinFuncDescriptor *, SvUV(ckobj)); - warn_experimental_builtin(builtin->name, false); + if(builtin->is_experimental) + warn_experimental_builtin(builtin->name, false); SV *prototype = newSVpvs("$"); SAVEFREESV(prototype); @@ -470,7 +463,8 @@ static OP *ck_builtin_funcN(pTHX_ OP *entersubop, GV *namegv, SV *ckobj) { const struct BuiltinFuncDescriptor *builtin = NUM2PTR(const struct BuiltinFuncDescriptor *, SvUV(ckobj)); - warn_experimental_builtin(builtin->name, false); + if(builtin->is_experimental) + warn_experimental_builtin(builtin->name, false); SV *prototype = newSVpvs("@"); SAVEFREESV(prototype); @@ -485,30 +479,30 @@ static const char builtin_not_recognised[] = "'%" SVf "' is not recognised as a static const struct BuiltinFuncDescriptor builtins[] = { /* constants */ - { "builtin::true", &XS_builtin_true, &ck_builtin_const, BUILTIN_CONST_TRUE }, - { "builtin::false", &XS_builtin_false, &ck_builtin_const, BUILTIN_CONST_FALSE }, + { "builtin::true", &XS_builtin_true, &ck_builtin_const, BUILTIN_CONST_TRUE, false }, + { "builtin::false", &XS_builtin_false, &ck_builtin_const, BUILTIN_CONST_FALSE, false }, /* unary functions */ - { "builtin::is_bool", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_IS_BOOL }, - { "builtin::weaken", &XS_builtin_func1_void, &ck_builtin_func1, OP_WEAKEN }, - { "builtin::unweaken", &XS_builtin_func1_void, &ck_builtin_func1, OP_UNWEAKEN }, - { "builtin::is_weak", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_IS_WEAK }, - { "builtin::blessed", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_BLESSED }, - { "builtin::refaddr", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_REFADDR }, - { "builtin::reftype", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_REFTYPE }, - { "builtin::ceil", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_CEIL }, - { "builtin::floor", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_FLOOR }, - { "builtin::is_tainted", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_IS_TAINTED }, - { "builtin::trim", &XS_builtin_trim, &ck_builtin_func1, 0 }, - - { "builtin::created_as_string", &XS_builtin_created_as_string, &ck_builtin_func1, 0 }, - { "builtin::created_as_number", &XS_builtin_created_as_number, &ck_builtin_func1, 0 }, + { "builtin::is_bool", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_IS_BOOL, true }, + { "builtin::weaken", &XS_builtin_func1_void, &ck_builtin_func1, OP_WEAKEN, false }, + { "builtin::unweaken", &XS_builtin_func1_void, &ck_builtin_func1, OP_UNWEAKEN, false }, + { "builtin::is_weak", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_IS_WEAK, false }, + { "builtin::blessed", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_BLESSED, false }, + { "builtin::refaddr", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_REFADDR, false }, + { "builtin::reftype", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_REFTYPE, false }, + { "builtin::ceil", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_CEIL, false }, + { "builtin::floor", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_FLOOR, false }, + { "builtin::is_tainted", &XS_builtin_func1_scalar, &ck_builtin_func1, OP_IS_TAINTED, false }, + { "builtin::trim", &XS_builtin_trim, &ck_builtin_func1, 0, false }, + + { "builtin::created_as_string", &XS_builtin_created_as_string, &ck_builtin_func1, 0, true }, + { "builtin::created_as_number", &XS_builtin_created_as_number, &ck_builtin_func1, 0, true }, /* list functions */ - { "builtin::indexed", &XS_builtin_indexed, &ck_builtin_funcN, 0 }, - { "builtin::export_lexically", &XS_builtin_export_lexically, NULL, 0 }, + { "builtin::indexed", &XS_builtin_indexed, &ck_builtin_funcN, 0, false }, + { "builtin::export_lexically", &XS_builtin_export_lexically, NULL, 0, true }, - { NULL, NULL, NULL, 0 } + { NULL, NULL, NULL, 0, false } }; XS(XS_builtin_import); diff --git a/lib/builtin.pm b/lib/builtin.pm index bf601fd54324..3a96b4b97ebd 100644 --- a/lib/builtin.pm +++ b/lib/builtin.pm @@ -1,4 +1,4 @@ -package builtin 0.008; +package builtin 0.009; use strict; use warnings; @@ -40,12 +40,9 @@ can be requested for convenience. Individual named functions can be imported by listing them as import parameters on the C statement for this pragma. -The overall C mechanism, as well as every individual function it -provides, are currently B. - -B: At present, the entire C namespace is experimental. -Calling functions in it will trigger warnings of the C -category. +B: At present, many of the functions in the C namespace are +experimental. Calling them will trigger warnings of the +C category. =head2 Lexical Import @@ -106,6 +103,8 @@ This gives an equivalent value to expressions like C or C. $bool = is_bool($val); +This function is currently B. + Returns true when given a distinguished boolean value, or false if not. A distinguished boolean value is the result of any boolean-returning builtin function (such as C or C itself), boolean-returning operator @@ -167,6 +166,8 @@ C for array references, or C for hash references. $bool = created_as_string($val); +This function is currently B. + Returns a boolean representing if the argument value was originally created as a string. It will return true for any scalar expression whose most recent assignment or modification was of a string-like nature - such as assignment @@ -188,6 +189,8 @@ strings. For example $bool = created_as_number($val); +This function is currently B. + Returns a boolean representing if the argument value was originally created as a number. It will return true for any scalar expression whose most recent assignment or modification was of a numerical nature - such as assignment from @@ -293,6 +296,8 @@ Returns true when given a tainted variable. export_lexically($name1, $ref1, $name2, $ref2, ...) +This function is currently B. + Exports new lexical names into the scope currently being compiled. Names given by the first of each pair of values will refer to the corresponding item whose reference is given by the second. Types of item that are permitted are diff --git a/pod/perlexperiment.pod b/pod/perlexperiment.pod index efd4caa72567..e8ad0bc42d90 100644 --- a/pod/perlexperiment.pod +++ b/pod/perlexperiment.pod @@ -178,8 +178,8 @@ Using this feature triggers warnings in the category C. In Perl 5.36.0, a new namespace, C, was created for new core functions that will not be present in every namespace, but will be available for -importing. The namespace itself is considered an experiment. Specific -functions within it may also be experimental. +importing. The namespace itself was considered experimental until Perl 5.39.2. +Some specific functions within it remain experimental. The ticket for this experiment is L<[perl #19764]|https://github.com/Perl/perl5/issues/19764>. diff --git a/t/lib/warnings/builtin b/t/lib/warnings/builtin index 110bc3986fbe..632a275b0bc8 100644 --- a/t/lib/warnings/builtin +++ b/t/lib/warnings/builtin @@ -27,14 +27,8 @@ $true->(); $false->(); EXPECT Built-in function 'builtin::is_bool' is experimental at - line 6. -Built-in function 'builtin::true' is experimental at - line 7. -Built-in function 'builtin::false' is experimental at - line 8. Built-in function 'builtin::is_bool' is experimental at - line 9. -Built-in function 'builtin::true' is experimental at - line 10. -Built-in function 'builtin::false' is experimental at - line 11. Built-in function 'builtin::is_bool' is experimental at - line 12. -Built-in function 'builtin::true' is experimental at - line 13. -Built-in function 'builtin::false' is experimental at - line 14. ######## # builtin.c - weakrefs use strict; @@ -62,15 +56,6 @@ $is_weak->($ref); $weaken->($ref); $unweaken->($ref); EXPECT -Built-in function 'builtin::is_weak' is experimental at - line 7. -Built-in function 'builtin::weaken' is experimental at - line 8. -Built-in function 'builtin::unweaken' is experimental at - line 9. -Built-in function 'builtin::is_weak' is experimental at - line 10. -Built-in function 'builtin::weaken' is experimental at - line 11. -Built-in function 'builtin::unweaken' is experimental at - line 12. -Built-in function 'builtin::is_weak' is experimental at - line 13. -Built-in function 'builtin::weaken' is experimental at - line 14. -Built-in function 'builtin::unweaken' is experimental at - line 15. ######## # builtin.c - blessed refs use strict; @@ -98,15 +83,6 @@ $blessed->($ref); $refaddr->($ref); $reftype->($ref); EXPECT -Built-in function 'builtin::blessed' is experimental at - line 7. -Built-in function 'builtin::refaddr' is experimental at - line 8. -Built-in function 'builtin::reftype' is experimental at - line 9. -Built-in function 'builtin::blessed' is experimental at - line 10. -Built-in function 'builtin::refaddr' is experimental at - line 11. -Built-in function 'builtin::reftype' is experimental at - line 12. -Built-in function 'builtin::blessed' is experimental at - line 13. -Built-in function 'builtin::refaddr' is experimental at - line 14. -Built-in function 'builtin::reftype' is experimental at - line 15. ######## # builtin.c - indexed use strict; @@ -116,8 +92,5 @@ my @array = indexed 1..3; my $scalar = indexed 1..3; indexed 1..3; EXPECT -Built-in function 'builtin::indexed' is experimental at - line 5. -Built-in function 'builtin::indexed' is experimental at - line 6. -Built-in function 'builtin::indexed' is experimental at - line 7. Useless use of builtin::indexed in scalar context at - line 6. Useless use of builtin::indexed in void context at - line 7.