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
RFC0020: A builtin for Lexical Export #20
Conversation
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. |
Could also be |
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. |
I'm for |
I think
|
Hmm, do you mean a function in addition to the proposed I'll add |
|
||
## Motivation | ||
|
||
"Traditional" Perl modules of the era around Perl 5.8 have always used symbolic aliasing into the caller's package to implement their export mechanism. This was the only mechanism available to them at the time, and served well in the era of procedural modules with functions in them. As more code became object-oriented, using packages to implement classes, the problems of making these exports visible as named symbols in the class's namespace became apparent, because each imported function would be visible as a named method on the class, whether it wanted that or not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not just that era, that has true ever since 5.0
|
||
If no sigil is present on the name argument, it is presumed to be of the first kind, and the value must be a `CODE` reference. | ||
|
||
As the only effect this function has is to add new things to the compiletime lexical scope, it shall be an error to call this function during regular runtime, when no code is currently being compiled. It shall also be an error to pass non-reference values, references to unsupported items (e.g. globs), or references whose type does not match the sigil of its name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I like how the the compiletime lexical scope is implicit, are we sure that's good enough? (though OTOH hints and hints hash already have that issue and we survive fine)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would the alternative be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has to be a compiletime scope, because that's the only thing that can work. It's unlikely there are multiple nested ones, and in any case I think it would be weird if we were to try to allow some kind of "uplevel" ability to affect scopes beyond the immediate caller. I don't think there's any other way we could offer.
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? |
VOTE: |
VOTE: |
VOTE: |
rfcs/rfc0020.md
Outdated
+ If the name is a `SCALAR` reference, a new scalar variable will be created in the scope. The corresponding name argument must begin with a `$` sigil. | ||
|
||
+ If the name is an `ARRAY` reference, a new array variable will be created in the scope. The corresponding name argument must begin with a `@` sigil. | ||
|
||
+ If the name is a `HASH` reference, a new hash variable will be created in the scope. The corresponding name argument must begin with a `%` sigil. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't these all be "If the value is a ... reference" rather than "If the name is a ... reference"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, absolutely right. Fix pushed.
I'm sorry guys. I don't want to test your patience. But how about |
I'm not sure that 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 ;) |
It seems |
As I see Addition: After some thought I see that lexical adjective plays well with exportable noun(s) that follow. Now I'm at peace. Thank you)) |
I can't get this thing out of my head. So one final (I wish) thought. |
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 |
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.
|
Indeed - is why I voted for that one in particular; though it seems |
Righty. Setlled on |
No description provided.