Does that restriction (including file in only one place) apply to "import" or "using"? I think not, but just confirming. Sorry if the docs clearly address that, but I don't remember.
Thank you. On Friday, December 12, 2014 10:40:56 AM UTC-5, Stefan Karpinski wrote: > > Yeah, that will do it. You should only include dataTypes.jl in one place. > > On Fri, Dec 12, 2014 at 10:28 AM, Test This <[email protected] > <javascript:>> wrote: > >> Hi Stefan, >> >> Please see below for what may be relevant code structure. I am happy to >> email the actual code off the list if you think that is necessary. >> >> >> The code which resulted in the problem had three different files. >> >> 1. dataTypes.jl (this file defines the Params composite type). >> >> 2. paramcombos.jl (there is a baseparams() function in this file, which >> creates >> an instance of Params type). >> >> 3. runsim.jl (the simulate function which gave the error was in this file) >> >> I did not declare any module statements in either dataTypes.jl or >> runsim.jl, but did >> declare module paramcombos in paramcombos.jl. The relevant structure of >> the files: >> >> ------------------------------------------------------------- >> *## File dataTypes.jl* >> >> type Params >> . >> . >> . >> end >> >> ------------------------------------------------------------- >> *## File paramcombos.jl* >> >> module paramcombos >> >> import Distributions >> include("dataTypes.jl") >> >> function baseparams() >> ... # body of this function >> return Params(...) >> end >> end >> >> ------------------------------------------------------------- >> *## File runsim.jl* >> >> include("dataTypes.jl") >> require("paramcombos.jl") >> >> >> function simulate(params::Params, rseed::Int) >> ... # body of this function >> end >> >> function main() >> basep = paramcombos.baseparams() >> simulate(basep, 1) >> end >> >> main() >> >> >> Thanks for looking into this. >> >> >> >> On Friday, December 12, 2014 8:16:40 AM UTC-5, Stefan Karpinski wrote: >>> >>> I would love to detect this kind of confusing situation and indicate >>> what's happening better because obviously it's pretty confusing when you >>> first encounter it. >>> >>> On Fri, Dec 12, 2014 at 4:37 AM, Test This <[email protected]> wrote: >>> >>>> Thanks Stefan. Yes, it looks like this is related to my lack of clear >>>> understanding about include vs. require. >>>> >>>> I am reading the docs John Myles (http://julia.readthedocs.org/ >>>> en/release-0.3/manual/modules/) directed me to and will report back on >>>> whether that helps me fix the issue. >>>> >>>> >>>> >>>> On Thursday, December 11, 2014 11:54:55 PM UTC-5, Stefan Karpinski >>>> wrote: >>>>> >>>>> It is possible that you have managed to get into a state where there >>>>> are two different types by the name Params. >>>>> >>>>> >>>>> On Dec 11, 2014, at 9:10 PM, Test This <[email protected]> wrote: >>>>> >>>>> >>>>> I am running into what appears to be weird error. I have this function >>>>> simulate that takes two arguments. When I try to run the file containing >>>>> this function I get >>>>> the following error. I have added println( methods(simulate) ) to the >>>>> code so that you can see its methods. >>>>> >>>>> >>>>> *# 1 method for generic function "simulate":* >>>>> *simulate(params::Params,rseed::Int64) at >>>>> /Users/code/simulationcode.jl:340* >>>>> *ERROR: `simulate` has no method matching simulate(::Params, ::Int64)* >>>>> >>>>> >>>>> Are the 2nd and 3rd lines not contradictory? >>>>> >>>>> Thanks in advance for your help. >>>>> >>>>> >>> >
