Skip to content
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

S11 doesn't say how 'require' distinguishes module names and file names #23

Closed
moritz opened this issue Aug 31, 2012 · 4 comments
Closed

Comments

@moritz
Copy link
Contributor

moritz commented Aug 31, 2012

S11/"Runtime Importation" talks about allowing both module names and file names, but it does not specify how the compiler (or rather the runtime) should figure out whether a given variable should be taken as a module name (to be looked up in @*INC) or as a file name.

Perl 5's approach of always assuming a file name if it's not a bare package name is too limiting IMHO, it leads to needless (and buggy) reimplementations of module locating code.

My best idea so far is to create a second keyword, 'require-file', which always interprets its first argument as a file name.
An idea I like less, but which might work for many cases, is to treat the presence of a dot in the string as an indicator that it's a file/path, not a module name.
Better ideas are welcome too.

@moritz
Copy link
Contributor Author

moritz commented Aug 31, 2012

That sounds pretty dangerous -- a 'touch YourModule` in the current working directory could make a working program stop work. And execute code not in @*INC, even though that's not what the programmer meant.

@tadzik
Copy link
Member

tadzik commented Aug 31, 2012

Seems that I accidentally edited my comment. The idea was to check for existence of the file and decide basing on that. I agree that it's probably unsafe though.

@FROGGS
Copy link
Contributor

FROGGS commented Aug 31, 2012

I vote for require-file since if I do require Something and mean a file, and later there is a module called Something I get problems...

@tadzik
Copy link
Member

tadzik commented Aug 31, 2012

Maybe have a flag for require, like :file or :path? Or, how jnthn++ suggests, just make decision basing on the type, so one can do require 'foo'.IO or so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants