Perl / PPCs

This repository is for Requests For Comments - proposals to change the Perl language.
61 stars 22 forks source link

RFC0020: A builtin for Lexical Export #20

Closed leonerd closed 2 years ago

ivrntsv commented 2 years ago

Why it is lexically_export and not export_lexically? I think verb should be first.

leonerd commented 2 years ago

Why it is lexically_export and not export_lexically? I think verb should be first.

Hmm i hadn't thought about that. I'm not fussed either way. We should probably make it whatever seems more consistent with other things.

haarg commented 2 years ago

Could also be export_lexical. I'm not too bothered either way.

ivrntsv commented 2 years ago

I am not so fluent in English so I don't know whether some way is preffered from the language point of view. But from what I saw in programming languages without function overloading there is a naming pattern like action_some_concretization. For unrelated illustration: In Perl you can call sort function with package function: sort numerically @arr. So for me export_lexically sounds more naturally. But this is just a suggestion, food for thought.

rwp0 commented 2 years ago

I'm for export or lexport to make things simpler

leonerd commented 2 years ago

I'm for export or lexport to make things simpler

I think export is a bit too short for clarity. It doesn't express the lexical nature. I could imagine some sort of builtin function to tidy up the way we do symbolic package exports:

export_symbolically $caller, name => \&func, name2 => \&func2, ...; 
rwp0 commented 2 years ago

I'm for export or lexport to make things simpler

I think export is a bit too short for clarity. It doesn't express the lexical nature. I could imagine some sort of builtin function to tidy up the way we do symbolic package exports:

export_symbolically $caller, name => \&func, name2 => \&func2, ...; 

Hmm, do you mean a function in addition to the proposed :export attribute?

I'll add l_export to my list of names.

leonerd commented 2 years ago

There seems various thoughts on the name of this. I'm not overly attached to any of them so I think lets propose a vote on the various ideas. Use the "+1" thumbs-up reaction for voting on the following ideas.

Besides the name, is there any other concern anyone has?

leonerd commented 2 years ago

VOTE: lexically_export

leonerd commented 2 years ago

VOTE: export_lexically

leonerd commented 2 years ago

VOTE: export_lexical

ivrntsv commented 2 years ago

I'm sorry guys. I don't want to test your patience. But how about export_lex and hypothetical export_sym (which this RFC is not about)?

leonerd commented 2 years ago

@ivrntsv

But how about export_lex and hypothetical export_sym

I'm not sure that lex is sufficiently meaningful to new/casual readers, to work out what the thing is (Same as lexport).

This is no longer the 1980s, with code stored on reels of tape or punched cards where every byte matters. We're allowed to spell words out in full now ;)

leonerd commented 2 years ago

It seems export_lexical is currently the vote-winner. I'm not entirely sure how I feel about a function named as a singular noun ("lexical") having the ability to create multiple lexicals, but nevertheless I'll update the spec for that.

ivrntsv commented 2 years ago

As I see export_lexical is preffered by voters. But that mean mixing verb and adjective. Or maybe in that case export is noun. It should be written lexical_export then. I preffer to mix verb and adverb in export_lexically. Maybe the short variant is the winner so I suggested export_lex as variant. But I don't insist.

Addition: After some thought I see that lexical adjective plays well with exportable noun(s) that follow. Now I'm at peace. Thank you))

ivrntsv commented 2 years ago

I can't get this thing out of my head. So one final (I wish) thought. export_as_lexical (hypothetical export_as_symbol). This as part will give understanding that something exportable will become a lexical variable (or a package symbol) on the user side. export_lexical tells to export something lexical which is not true. Most of the time you export something global from a package.

leonerd commented 2 years ago

Hmm.. that is true. It's not that the thing being exported is necessarily a lexical (indeed; most of the time for doing coderefs it probably won't be). It's that once exported, the new thing that is created is a lexical. So maybe the word as should be part of its name.

iabyn commented 2 years ago

On Mon, Jul 04, 2022 at 03:35:50PM -0700, Paul Evans wrote:

Hmm.. that is true. It's not that the thing being exported is necessarily a lexical (indeed; most of the time for doing coderefs it probably won't be). It's that once exported, the new thing that is created is a lexical. So maybe the word as should be part of its name.

'export_lexically' would correctly describe how the thing is being exported rather than what is being exported.

-- You never really learn to swear until you learn to drive.

leonerd commented 2 years ago

@iabyn

'export_lexically' would correctly describe how the thing is being exported rather than what is being exported.

Indeed - is why I voted for that one in particular; though it seems export_lexical currently has 7 votes to its 5. But perhaps this distinction is enough to sway it in favour anyway..?

leonerd commented 2 years ago

Righty. Setlled on export_lexically