Workspaces

A Workspace in Jai represents a completely separate environment, inside which we can compile programs. When the compiler starts up, it makes a Workspace for the first files that you tell it to compile on the commandline. Different Workspaces cannot refer to each others’ namespaces, imported modules, etc; different workspaces are totally separate and encapsulated from each other. This allows you to run a bunch of code that uses global data, imports modules, and so forth inside one workspace, and these things do not affect the target program at all. You can compile separate target workspaces, and they will not affect each other at all.

A workspace can be created using compiler_create_workspace.

build :: () {
  w := compiler_create_workspace();
  if !w {
    print("Workspace creation failed.\n");
    return;
  }
  // ... other code
}

A build can instantiate multiple workspaces.

build :: () {
  ws1 := compiler_create_workspace("Workspace 1");
  // do build for workspace 1...

  ws2 := compiler_create_workspace("Workspace 2");
  // do build for workspace 2...

  ws3 := compiler_create_workspace("Workspace 3");
  // do build for workspace 3...
}

For a more detailed description of Workspaces, there is a great guide in the how_to called how_to/400_workspaces.jai.