Records and Modules #27
Labels
design
Ideas pertaining to language design
feature
Features that add something new to the language
help-wanted
This is an great first issue for first time contributers
Passerine's module system is pretty simple. At it's core, a module is defined as:
Basically a module turns a scope into a struct, where all top-level variables become fields on that struct. As seen in the above example, we use
mod
to do this.All files are modules, and are imported using the
use
keyword.A folder with a file named
mod.pn
in it is also a module. This is similar to how Rust behaves:Modules are resolved at compile time. Upon using
use
, Passerine:X.pn
orX/mod.pn
in the current scope of the file being compiledmod
operation.All modules must form a tree hierarchy. i.e, there should be only one path from the root ,
nest
, to any other module. Modules can be mutually recursive, but in this case the full path must be specified:Modules are only executed once, upon first load.
Hello, World
would be printed to the terminal in the above example. Here's the big ol' todo list. If you'd like to help, I'll mentor anyone through any one of these steps:Record
variant onData
insrc/common/data.rs
, including methods for displaying it.::
),mod <block>
,use <path>
, andnest
keywords.{ foo: "Bar", baz: 27.5 }
{ thing: banana } = { thing: "Hello" }
mod
blocks to bytecode, converting them to recordsnest
keyword.The
dev
branch is a bit of a mess right now as I'm doing some big refactoring, so please make a feature branch off of master and implement any changes there. This will be a0.9.X
feature.The text was updated successfully, but these errors were encountered: