I made https://github.com/mauro3/Parameters.jl potentially for your
use-case.  So instead of

  const g=9.81
  const rho=1000.0
  pressure(h) = rho*g*h

you write:

  using Parameters
  @with_kw type Para{R}
    g::R=9.81
    rho::R=1000.0
  end
  pressure(h,p::Para) = (@unpack p: g, rho; rho*g*h)
  p = Para{Float64}()
  pressure(10,p)

The extra verbosity often pays off later.  Say you fly to Mars, find
liquid water (hooray!) and want to calculate the pressure:

  pm = Para{Float64}(g=3.71)
  pressure(10,pm)

On Tue, 2016-04-05 at 15:24, K leo <cnbiz...@gmail.com> wrote:
> Thanks for the tip.
>
> Don't you have to do include everytime you change some files?
> My codes have not been complicated enough to use modules, but how does that
> help with only a couple files?
>
> On Tuesday, April 5, 2016 at 6:45:00 PM UTC+5:30, Erik Schnetter wrote:
>>
>> I usually put code into a module, and use `using` to load the module.
>>
>> After updating a module, I use `workspace()` to remove all previous
>> definition in the REPL:
>>
>> `workspace(); using FunHPC`
>>
>> -erik
>>
>>
>> On Tue, Apr 5, 2016 at 9:13 AM, K leo <cnbi...@gmail.com <javascript:>>
>> wrote:
>> > I have some const defined in various files in the following way:
>> >
>> > [code]const AConst=1[/code]
>> >
>> > Everytime after I modify something in the files (constants remain
>> unchanged)
>> > and include a file on Julia's REPL, I always get a bunch warnings about
>> > redefining constants.  Repeating the process many time can get Julia to
>> have
>> > slow response.
>> >
>> > What can I do to avoid these warnings?
>>
>>
>>
>> --
>> Erik Schnetter <schn...@gmail.com <javascript:>>
>> http://www.perimeterinstitute.ca/personal/eschnetter/
>>

Reply via email to