Skip to main content
Engineering LibreTexts

8.14: Load Types

  • Page ID
    45285
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Metacello lets you specify the way packages are loaded through its “load types". At the time of this writing, there are only two possible load types: atomic and linear.

    Atomic loading is used where packages have been partitioned in such a way that they can not be loaded individually. The definitions from each package are merged together into one giant load by the Monticello package loader. Class side initialize methods and pre/post code execution are performed for the whole set of packages, not individually.

    If you use a linear load, then each package is loaded in order. Class side initialize methods and pre/post code execution are performed just before or after loading that specific package.

    It is important to notice that managing dependences does not imply the order packages will be loaded. That a package A depends on package B doesn’t mean that B will be loaded before A. It just guarantees that if you want to load A, then B will be loaded too.

    A problem with this also happens with methods override. If a package overrides a method from another package, and the order is not preserved, this can be a problem because we are not sure of the order in which they will load, and thus, we cannot be sure which version of the method will be finally loaded.

    When using atomic loading the package order is lost and we have the mentioned problems. However, if we use the linear mode, then each package is loaded in order. Moreover, the methods override should be preserved too.

    A possible problem with linear mode is the following: suppose project A depends on other two projects B and C. B depends on the project D version 1.1 and C depends on project D version 1.2 (the same project but another version). First question, which D version does A have at the end? By default (you can change this using the method operator: in the project method), Metacello will finally load version 1.2, i.e., the latest one.

    However, in atomic loading only 1.2 is loaded. In linear loading, both versions may (depending on the dependency order) be loaded, although 1.2 will be finally loaded. But this means that 1.1 may be loaded first and then 1.2. Sometimes this can be a problem because an older version of a package or project may not even load in the Pharo image we are using.

    For all the mentioned reasons, the default mode is linear. Users should use atomic loading in particular cases and when they are completely sure.

    Finally, if you want to explicitly set a load type, you have to do it in the project method. Example:

    ConfigurationOfCoolToolSet >>project
    
        ^ project ifNil: [ | constructor |
            "Bootstrap Metacello if it is not already loaded"
            self class ensureMetacello.
            "Construct Metacello project"
            constructor := (Smalltalk at: #MetacelloVersionConstructor) on: self.
            project := constructor project.
            project loadType: #linear. ’"or #atomic’"
            project ]
    

    This page titled 8.14: Load Types is shared under a CC BY-SA 3.0 license and was authored, remixed, and/or curated by Alexandre Bergel, Damien Cassou, Stéphane Ducasse, Jannik Laval (Square Bracket Associates) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.