Open
Description
Using the following project structure
SlothCreator
├── .editorconfig
├── lib
│ ├── Generators
│ │ └── sloth_generator.onyx
│ └── Sloth
│ ├── activity.onyx
│ ├── color.onyx
│ ├── food.onyx
│ ├── habitat.onyx
│ ├── power.onyx
│ ├── schedule.onyx
│ └── sloth.onyx
├── onyx-pkg.kdl
└── project.onyx
onyx-pkg.kdl
package {
name "Sloth Creator"
author "clsource"
url ""
description "A package for your Sloth needs"
version "1.0.0"
}
config {
dependency_source_path "./deps"
dependency_binary_path "./bin"
}
project.onyx
package main
#load_all "lib/Sloth"
#load_all "lib/Generators"
use Sloth
use Generators
use core
main :: () {
habitat := Sloth.init_habitat(is_humid = true, is_warm = true)
sloth := Generators.generate_sloth(habitat)
sloth.energy_level = Sloth.sloth_eat(sloth, Sloth.DefaultFoodType.Large_Leaf)
core.printf("sloth: {} | energy: {} | power: {} ¡ color: {}", sloth.name, sloth.energy_level, sloth.power, sloth.color)
}
It would be awesome if we could have an import/require
keyword that can simplify the code.
import
Will load the package from the path and use
it.
import "lib/Sloth"
Would be the same as
#load_all "lib/Sloth"
use Sloth
And an alias can be done like
import MySloth "lib/Sloth"
would be the same as
#load_all "lib/Sloth"
use Sloth { MySloth :: package }
require
Will load the package from the path and use all the procedures.
require "lib/Sloth"
would be the same as
#load_all "lib/Sloth"
use Sloth {package, * }
Maybe can also call a macro procedure like Elixir's __using__
Metadata
Metadata
Assignees
Labels
No labels