Skip to content

Have an imported module in a template be available when amending it #758

Answered by HT154
ghyatzo asked this question in Q&A
Discussion options

You must be logged in to vote

Take this module for example:

module MyModule

a: String = "hello"
b: Int = 0

You can think of this module as either a type or a value. Evaluating this module produces a representation of its value:

a = "hello"
b = 0

As a type, this is similar to a class with properties a and b, and in fact you can use it as a class, like so:

import "MyModule.pkl"

x = new MyModule {
  b = 2
}

As you've seen, the type/value distinction is made evident by the two different kinds of import:

  • The import "MyModule.pkl" statement introduces a few things that all share one name:
    • The value of the module, bound to a local property, equivalent to local MyModule = import("MyModule.pkl")
    • The type of the module [NB:…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@ghyatzo
Comment options

@HT154
Comment options

Answer selected by ghyatzo
@ghyatzo
Comment options

@HT154
Comment options

@ghyatzo
Comment options

@holzensp
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants