Organizing a Workspace
You can share a type and helper across files by putting them in a workspace. This example gives the entry file access to root declarations without an import.
Before you start #
You need gcsl on your command search path and an empty writable directory.
Create the workspace #
-
Save these declarations as
workspace.gcsl:type Component = {name: String, version: String} def describe(item: Component): String { "{item.name} {item.version}" } -
Save the entry program as
main.gcslbeside it:describe({name = "gcsl"; version = "0.1.0"}) -
From that directory, check the workspace and run the entry file:
Check the result #
The check reports no problems in 2 files checked. The run prints
gcsl 0.1.0. The helper is visible because def contributes to the
shared directory scope. Replacing def with fn makes it private to
workspace.gcsl, so the entry file cannot resolve it.
When adding a child library directory, import its public fields or functions by its root-relative path. Keep independent projects behind their own workspace markers rather than relying on hidden files to separate their scopes.