Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
moritz opened this Issue · 4 comments

4 participants

@moritz
Owner

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
Owner

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
Collaborator

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
Owner

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
Collaborator

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

@TimToady TimToady closed this in 0a50011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.