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

WIP: RNG functionality as modules #1264

Merged
merged 2 commits into from
Sep 22, 2012
Merged

WIP: RNG functionality as modules #1264

merged 2 commits into from
Sep 22, 2012

Conversation

ViralBShah
Copy link
Member

I decided to junk my earlier attempt at integrating the RNG modules in base. I am trying to get it to work standalone to start with, and expect something like the following to work before I merge into base:

julia> load("rng_librandom.jl")
julia> load("rng.jl")
julia> import RNG
julia> RNG.librandom_init()
julia> RNG.rand()

Currently, this is what I get:

julia> load("rng_librandom.jl")

julia> load("rng.jl")
LibRandom not defined
 in load_now at util.jl:232
 in load_now at util.jl:244
 in require at util.jl:174
at /Users/viral/julia/extras/rng.jl:107
 in load_now at util.jl:255
 in require at util.jl:174

julia> load("rng.jl")

julia> import RNG

julia> RNG.librandom_init()
stderrEntropy pool not available to seed RNG, using ad-hoc entropy sources.
exec: No such file or directory
in srand: LibRandom not defined
 in srand at /Users/viral/julia/extras/rng.jl:87
 in librandom_init at /Users/viral/julia/extras/rng.jl:33

@JeffBezanson
Copy link
Member

Every module does contain a reference to itself (i.e. Mod.Mod), but it is not exported by default:

julia> module Bar
       end

julia> import Bar.*

julia> Bar
Bar not defined

The idea was simply to export nothing by default, but maybe this consequence is unintuitive.

@staticfloat
Copy link
Member

May I ask why we need to have an explicit librandom.init() call? Shouldn't we have some kind of automatic initialization function that's called via the import keyword?

@JeffBezanson
Copy link
Member

Yes we probably need something like _init that is always called at load time. Lots of C libraries require some kind of mylib_init call and this should be automated.

ViralBShah added a commit that referenced this pull request Sep 22, 2012
WIP: RNG functionality as modules
@ViralBShah ViralBShah merged commit b8ddf8c into master Sep 22, 2012
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

Successfully merging this pull request may close these issues.

3 participants