Modules
Sparkle allows you to import variables from other Sparkle files. By default, variables are not publicly available and thus aren't able to be imported from other Sparkle files.
Cyclic imports are not allowed.
Private Variables
Private variables are not publicly available, and cannot be imported from other Sparkle files.
privately let secret_number be 42The privately let ... be ... syntax is used to declare a private variable, note
that this isn't allowed in update ... to ....
This is optional as it is the default behavior.
Public Variables
Public variables are available to be imported from other Sparkle files.
publicly let best_language be "sparkle"The publicly let ... be ... syntax is used to declare a public variable, note
that this isn't allowed in update ... to ....
Importing Variables
Sparkle files can import variables from other Sparkle files and use them.
The import ... from ... syntax is used to import variables from other Sparkle files.
The list of imported variables require the Oxford comma , and syntax, or just for a single variable.
1
2
3
4
5
6
7
8
9 import just swap from "./swap.sparkle"
let a be 1
let b be 2
call swap with a by reference, and b by reference
print a # should print 2
print b # should print 1Renaming Variables
Imported variables may be renamed using the as keyword if needed.
import just orange as orange_fruit from "./fruits.sparkle"
import blue, orange as orange_color, and magenta from "./colors.sparkle"Re-exporting Variables
Sparkle allows re-exporting variables from other Sparkle files using the publicly import syntax. Other Sparkle files may then import these variables.
publicly import just swap from "./swap.sparkle"