Mailing List Archive

G_ARRAY should be called G_LIST
I've been mildly annoyed about this for years. We have three kinds of
context in perl - void context, scalar context and list context. The
three constants for it are called G_VOID, G_SCALAR and G_ARRAY.

Yes, G_ARRAY.

I propose to add a new G_LIST constant with the same value as the
current G_ARRAY, and perform a simple s/G_ARRAY/G_LIST/ across our
codebase to fix up this little cognitive roadbump.

I imagine adding a back-compat constant to ppport.h and similar should
be relatively straightforward.

Any objections?


(I don't plan to address `wantarray` right now, because that is visible
to perl code and would have far-wider consequences for renaming it)

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
Re: G_ARRAY should be called G_LIST [ In reply to ]
> On May 31, 2021, at 10:07 AM, Paul LeoNerd Evans <leonerd@leonerd.org.uk> wrote:
>
> I've been mildly annoyed about this for years. We have three kinds of
> context in perl - void context, scalar context and list context. The
> three constants for it are called G_VOID, G_SCALAR and G_ARRAY.
>
> Yes, G_ARRAY.
>
> I propose to add a new G_LIST constant with the same value as the
> current G_ARRAY, and perform a simple s/G_ARRAY/G_LIST/ across our
> codebase to fix up this little cognitive roadbump.
>
> I imagine adding a back-compat constant to ppport.h and similar should
> be relatively straightforward.
>
> Any objections?

Sounds great to me. FWIW I think these kinds of clarifications will go a long way toward making Perl a more inviting platform from the C side.

-F
Re: G_ARRAY should be called G_LIST [ In reply to ]
On 5/31/21 10:07 AM, Paul "LeoNerd" Evans wrote:
> I've been mildly annoyed about this for years. We have three kinds of
> context in perl - void context, scalar context and list context. The
> three constants for it are called G_VOID, G_SCALAR and G_ARRAY.
>
> Yes, G_ARRAY.
>

Do you know to what extent G_ARRAY is used on CPAN?
Re: G_ARRAY should be called G_LIST [ In reply to ]
On Mon, 31 May 2021 10:11:18 -0400
James E Keenan <jkeenan@pobox.com> wrote:

> Do you know to what extent G_ARRAY is used on CPAN?

I don't, but I have no intention to delete it at this time.

cop.h currently does:

#define G_SCALAR 2
#define G_ARRAY 3
#define G_VOID 1

so I was simply going to add another line

#define G_LIST 3

and not remove the existing G_ARRAY.

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
Re: G_ARRAY should be called G_LIST [ In reply to ]
On 5/31/21 10:15 AM, Paul "LeoNerd" Evans wrote:
> On Mon, 31 May 2021 10:11:18 -0400
> James E Keenan <jkeenan@pobox.com> wrote:
>
>> Do you know to what extent G_ARRAY is used on CPAN?
>
> I don't, but I have no intention to delete it at this time.
>
> cop.h currently does:
>
> #define G_SCALAR 2
> #define G_ARRAY 3
> #define G_VOID 1
>
> so I was simply going to add another line
>
> #define G_LIST 3
>
> and not remove the existing G_ARRAY.
>

Thanks. +1
Re: G_ARRAY should be called G_LIST [ In reply to ]
On Mon, 31 May 2021 15:15:36 +0100, "Paul \"LeoNerd\" Evans"
<leonerd@leonerd.org.uk> wrote:

> On Mon, 31 May 2021 10:11:18 -0400
> James E Keenan <jkeenan@pobox.com> wrote:
>
> > Do you know to what extent G_ARRAY is used on CPAN?
>
> I don't, but I have no intention to delete it at this time.
>
> cop.h currently does:
>
> #define G_SCALAR 2
> #define G_ARRAY 3
> #define G_VOID 1
>
> so I was simply going to add another line
>
> #define G_LIST 3
>
> and not remove the existing G_ARRAY.

+1

--
H.Merijn Brand https://tux.nl Perl Monger http://amsterdam.pm.org/
using perl5.00307 .. 5.33 porting perl5 on HP-UX, AIX, and Linux
https://tux.nl/email.html http://qa.perl.org https://www.test-smoke.org
Re: G_ARRAY should be called G_LIST [ In reply to ]
On Mon, 31 May 2021 15:07:36 +0100
"Paul \"LeoNerd\" Evans" <leonerd@leonerd.org.uk> wrote:

> I propose to add a new G_LIST constant with the same value as the
> current G_ARRAY, and perform a simple s/G_ARRAY/G_LIST/ across our
> codebase to fix up this little cognitive roadbump.

Update: I've begun on this branch:

https://github.com/leonerd/perl5/tree/rename-g-array-to-g-list

Of all the change, I think the most pleasing one is:

--- a/scope.c
+++ b/scope.c
@@ -1519,7 +1519,7 @@ Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
case G_SCALAR:
gimme_text = "SCALAR";
break;
- case G_ARRAY:
+ case G_LIST:
gimme_text = "LIST";
break;
default:


Most of the remaining hits for G_ARRAY are in the dist/ and cpan/
directories.

* For dist/ I imagine these would be tidied up in a later commit,
perhaps after someone (khw?) has had a poke of Devel::PPPort to add
some back-compat magics there.

* For cpan/ I note about half the hits are from my own
Scalar-List-Utils, so I can easily fix those up. Since they're all
macros I imagine a simple

#ifndef G_LIST
# define G_LIST G_ARRAY
#endif

would make easy work of these.

In any case, none of those are particularly problematic. Due to how
much code there will be around CPAN using the previous G_ARRAY name I
highly doubt that we'll be in a position to remove that name for a long
time yet, so it will remain around for a good long while.

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
Re: G_ARRAY should be called G_LIST [ In reply to ]
2021-5-31 23:08 Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> wrote:

>
> Yes, G_ARRAY.
>
> I propose to add a new G_LIST constant with the same value as the
> current G_ARRAY, and perform a simple s/G_ARRAY/G_LIST/ across our
> codebase to fix up this little cognitive roadbump.
>
> I imagine adding a back-compat constant to ppport.h and similar should
> be relatively straightforward.
>
> Any objections?
>

My personal view.

If G_ARRAY is an internal constant, it is no problem.

On the other hand, If G_ARRAY is published, and used in some CPAN modules,
it has some problems.

I think G_LIST is the best name, but G_ARRAY is not so bad.

Adding G_LIST adds another complexity because the meanings of G_LIST and
G_ARRAY are duplicated.

Paul is motivated and seems to want to experiment with the Perl core, so I
don't strongly oppose it.
Re: G_ARRAY should be called G_LIST [ In reply to ]
On Mon, 31 May 2021 23:52:29 +0100
"Paul \"LeoNerd\" Evans" <leonerd@leonerd.org.uk> wrote:

> Update: I've begun on this branch:
>
> https://github.com/leonerd/perl5/tree/rename-g-array-to-g-list
>

And now squashed/merged:

https://github.com/Perl/perl5/commit/eb7e169eaa8ff0e7

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/