bait-lang / bait

Simple yet powerful programming language for building reliable software. Work in progress.
MIT License
19 stars 5 forks source link

Scope system rework #246

Open serkonda7 opened 1 week ago

serkonda7 commented 1 week ago

Continuously updated

Tracker for details regarding the current and future form of Bait's scope system.

Changes will be split up into multiple PRs.

Status Quo

Hierarchy:

global scope
+-- file 1
  +-- blocks
    +-- ...
  +-- ...
+-- file 2
+-- ...

Storage:

table.Table.global_scope &ast.Scope

Contents high-level:

ScopeObject value variants:

// normal
Obj{
  name = full.pkg.name
  pkg = full.pkg
}

// builtin
Obj{
  name = name
  pkg = "builtin"
}

// ffi
Obj{
  name = LANG.pkg.name
  pkg = full.pkg
  lang = lang
}

Goal

Hierarchy:

universe
+-- ffi
+-- pkg 1
  +-- block (file 1)
    +-- blocks
      +-- ...
  +-- block (file 2)
  +-- ...
+-- pkg 2
+-- ...

Storage:

table.Table.pkg_scopes map[string]&ast.Scope

Contents high-level:

ScopeObject value variants:

// normal
table.pkg_scopes[full.pkg]Obj{
  name = name
}

// builtin
table.pkg_scopes["builtin"]Obj{
  name = name
}

// ffi
table.pkg_scopes["FFI"]Obj{
  name = pkg.name
  lang = lang // this might not even be needed
}
serkonda7 commented 4 days ago

Progress: