purpose of Base.require(symbol)? vs Base.require(String)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

purpose of Base.require(symbol)? vs Base.require(String)

waTeim
this no longer appears possible  if not using the old-deprecated method:  Base.require(some-path-to-a-file) but rather implicitly requires
LOAD_PATH to be set and the argument to require is of type symbol.

Cumbersome.

But it looks like it was done deliberately, so my question is what's the purpose?  If it's just to differentiate from the older signature, then I have a suggestion.  change it to:

Base.require(mod::Symbol;path::Array{UTF8String} = [])  or maybe instead of the empty array [pwd()] which could either augment LOAD_PATH or
override it.
Reply | Threaded
Open this post in threaded view
|

Re: purpose of Base.require(symbol)? vs Base.require(String)

Jameson Nash
The `require` function is deprecated:
```
deprecations.jl
 704 @noinline function require(f::AbstractString)
 705     depwarn("`require` is deprecated, use `using` or `import` instead", :require)
```

On Sat, Mar 26, 2016 at 5:45 PM waTeim <[hidden email]> wrote:
this no longer appears possible  if not using the old-deprecated method:  Base.require(some-path-to-a-file) but rather implicitly requires
LOAD_PATH to be set and the argument to require is of type symbol.

Cumbersome.

But it looks like it was done deliberately, so my question is what's the purpose?  If it's just to differentiate from the older signature, then I have a suggestion.  change it to:

Base.require(mod::Symbol;path::Array{UTF8String} = [])  or maybe instead of the empty array [pwd()] which could either augment LOAD_PATH or
override it.
Reply | Threaded
Open this post in threaded view
|

Re: purpose of Base.require(symbol)? vs Base.require(String)

waTeim
Yea that one is (require in require.jl, module OldRequire).  But its replacement is not (require in loading.jl). 
Reply | Threaded
Open this post in threaded view
|

Re: purpose of Base.require(symbol)? vs Base.require(String)

Jameson Nash
it reuses the same name, but it's not intended to be exported (observe that it's not in the list of replacements in the depwarn message)

On Sat, Mar 26, 2016 at 5:55 PM waTeim <[hidden email]> wrote:
Yea that one is (require in require.jl, module OldRequire).  But its replacement is not (require in loading.jl). 
Reply | Threaded
Open this post in threaded view
|

Re: purpose of Base.require(symbol)? vs Base.require(String)

waTeim
Hmm ok got it, however, that creates another problem.  What's the mechanism to import a module without using "import"?  The problem with import is that it's not a function. By the comments seems like this is what require is for.
Reply | Threaded
Open this post in threaded view
|

Re: purpose of Base.require(symbol)? vs Base.require(String)

Jameson Nash
`eval` or `include`

On Sat, Mar 26, 2016 at 6:05 PM waTeim <[hidden email]> wrote:
Hmm ok got it, however, that creates another problem.  What's the mechanism to import a module without using "import"?  The problem with import is that it's not a function. By the comments seems like this is what require is for.
Reply | Threaded
Open this post in threaded view
|

Re: purpose of Base.require(symbol)? vs Base.require(String)

waTeim
Oh!  For some reason I though that both of those would parse the entire file and bypass any sort fo precompilation (.ji).
Reply | Threaded
Open this post in threaded view
|

Re: purpose of Base.require(symbol)? vs Base.require(String)

Tim Holy
include does bypass precompilation. You can use

    modulename = :Images
    @eval import $modulename

--Tim

On Saturday, March 26, 2016 03:14:26 PM waTeim wrote:
> Oh!  For some reason I though that both of those would parse the entire
> file and bypass any sort fo precompilation (.ji).