(err, "multi-package scale")

On Thu, May 7, 2015 at 9:47 PM, Isaiah Norton <[email protected]>
wrote:

> Yes, exactly -- this is what e.g. the StatsBase and GraphicsBase packages
> are doing, on a multi-module scale. But it works well within a single
> module too, in combination with the lazy loading.
>
> On Thu, May 7, 2015 at 2:49 PM, Kristoffer Carlsson <[email protected]
> > wrote:
>
>> That seemed to do the trick.
>>
>> I kinda like how this forces you to be explicit in what you will extend
>> from the main module.
>>
>>
>> On Thursday, May 7, 2015 at 8:28:47 PM UTC+2, Kristoffer Carlsson wrote:
>>>
>>> Question:
>>>
>>> Is the solution to define "main functions" in the library module and
>>> then import those functions into the book modules?
>>>
>>> Sort of like how you import Base.push! if you want to extend the push!
>>> function.
>>>
>>>
>>> On Thursday, May 7, 2015 at 7:43:26 PM UTC+2, Kristoffer Carlsson wrote:
>>>>
>>>> I realized this doesn't work well for me.
>>>>
>>>> The problem with using @lazymod and splitting my "books" into different
>>>> modules is that I have methods with the same name in the "book" modules.
>>>> This will cause conflicts and I won't get the methods when I import the
>>>> second book module.
>>>>
>>>> Maybe I could use https://github.com/davidagold/MetaMerge.jl but at
>>>> this point it seems like an awful amount of work just to be able to do
>>>> something as simple as not loading the whole package...
>>>>
>>>> Assuming that I have a huge number of different types that all have the
>>>> same parent abstract type. There is a method for each type operating on the
>>>> type.
>>>>
>>>> Is it right that there is no way to put this in a package and have a
>>>> user only load part of the types and methods?
>>>>
>>>>
>>>>
>>>> On Tuesday, May 5, 2015 at 6:52:24 PM UTC+2, Jameson wrote:
>>>>>
>>>>> Also see https://github.com/JuliaLang/julia/pull/6884
>>>>>
>>>>> On Tue, May 5, 2015 at 12:52 PM Kristoffer Carlsson <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> Thank you for the link. My current structure is now then:
>>>>>>
>>>>>> # MyPackage.jl
>>>>>> module MyPackage
>>>>>>
>>>>>> export foo, AbstractBook
>>>>>>
>>>>>> include("required.jl")
>>>>>> include("library.jl")
>>>>>> end
>>>>>>
>>>>>> # required.jl
>>>>>> abstract AbstractBook
>>>>>> foo(a::AbstractBook) = print(a)
>>>>>>
>>>>>> # library.jl
>>>>>> module Library
>>>>>>
>>>>>> using Requires
>>>>>>
>>>>>> @lazymod BookModule1 "book1.jl"
>>>>>> @lazymod BookModule" "book2.jl"
>>>>>>
>>>>>> end
>>>>>>
>>>>>>
>>>>>> # book1.jl
>>>>>> module BookModule1
>>>>>> using MyPackage
>>>>>> export Book1
>>>>>> type Book1 <: AbstractBook
>>>>>> end
>>>>>>
>>>>>> # book2.jl
>>>>>> module BookModule2
>>>>>> using MyPackage
>>>>>> export Book2
>>>>>> type Book2 <: AbstractBook
>>>>>> end
>>>>>>
>>>>>> I can then load the Book1Mod using
>>>>>>
>>>>>> julia> MyPackage.Library.bookmodule1()
>>>>>> MyPackage.Library.BookModule1
>>>>>>
>>>>>>
>>>>>> which is a little bit uglier than what I would like but it works!
>>>>>>
>>>>>> Thanks!
>>>>>>
>>>>>> // Kristoffer
>>>>>>
>>>>>> On Tuesday, May 5, 2015 at 6:12:35 PM UTC+2, Isaiah wrote:
>>>>>>
>>>>>>> Have a look at https://github.com/one-more-minute/Requires.jl
>>>>>>>
>>>>>>
>>>>>>> On Tue, May 5, 2015 at 12:04 PM, Kristoffer Carlsson <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> I have a package where some functionality should always be loaded
>>>>>>>> when writing the normal "using MyPackage" and some functionality needs 
>>>>>>>> to
>>>>>>>> be explicitly loaded. The use case for me is that I have a library of
>>>>>>>> different things (let's call them books) and it is likely that only a 
>>>>>>>> few
>>>>>>>> books from this library are used and I want to reduce the loading time 
>>>>>>>> of
>>>>>>>> the package.
>>>>>>>>
>>>>>>>> To make it concrete let's assume I currently have the following
>>>>>>>> file/module structure:
>>>>>>>> # MyPackage.jl
>>>>>>>> module MyPackage
>>>>>>>> export foo
>>>>>>>> include("required.jl")
>>>>>>>> include("library.jl")
>>>>>>>> end
>>>>>>>>
>>>>>>>> # required.jl
>>>>>>>> abstract AbstractBook
>>>>>>>> foo(a::AbstractBook) = print(a)
>>>>>>>>
>>>>>>>> # library.jl
>>>>>>>>
>>>>>>>> include("book1.jl")
>>>>>>>> include("book2.jl")
>>>>>>>>
>>>>>>>> # book1.jl
>>>>>>>> type Book1 <: AbstractBook
>>>>>>>>
>>>>>>>> # book2.jl (oh boy...)
>>>>>>>> using Gadfly
>>>>>>>> using Winston
>>>>>>>> using Images
>>>>>>>> using PyCall
>>>>>>>> type Book2 <: AbstractBook
>>>>>>>>
>>>>>>>> Now, I want my usage of the package to look something like this:
>>>>>>>> using MyPackage # Loads everything required
>>>>>>>> using MyPackage.Library.Book1 # Only loads book1.jl, book2.jl is
>>>>>>>> not touched, fast loading
>>>>>>>>
>>>>>>>> Foo(Book1())
>>>>>>>>
>>>>>>>> I guess I have to put my books into their own separate modules,
>>>>>>>> akin:
>>>>>>>>
>>>>>>>> # MyPackage.jl
>>>>>>>> module MyPackage
>>>>>>>> export foo
>>>>>>>> include("required.jl")
>>>>>>>> end
>>>>>>>>
>>>>>>>> # required.jl
>>>>>>>> abstract AbstractBook
>>>>>>>> foo(a::AbstractBook) = print(a)
>>>>>>>>
>>>>>>>> # book1.jl
>>>>>>>> module BookModule1
>>>>>>>> using MyPackage
>>>>>>>> export Book1
>>>>>>>> type Book1 <: AbstractBook
>>>>>>>> end
>>>>>>>>
>>>>>>>> # book2.jl
>>>>>>>> module BookModule2
>>>>>>>> using MyPackage
>>>>>>>> export Book2
>>>>>>>> type Book2 <: AbstractBook
>>>>>>>> end
>>>>>>>>
>>>>>>>> But now there is no convenient way to load the book modules?
>>>>>>>>
>>>>>>>> Can anyone help me how to properly structure this? A link to a
>>>>>>>> package that does this will likely work just fine.
>>>>>>>>
>>>>>>>> Best regards,
>>>>>>>> Kristoffer Carlsson
>>>>>>>>
>>>>>>>
>>>>>>>
>

Reply via email to