Skip to content

Commit

Permalink
fixed minor direct include bug
Browse files Browse the repository at this point in the history
  • Loading branch information
maniospas committed Feb 10, 2025
1 parent 1e34376 commit 6657307
Show file tree
Hide file tree
Showing 5 changed files with 571 additions and 559 deletions.
9 changes: 8 additions & 1 deletion docs/advanced/preprocessor.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,13 @@ usage of the same variables.
var x;
var y;
}
!namespace main {
var x;
var y;
}


!include { // do not allow the namespace activation leak
!include { // keep the namespace activation compartmenized here
!with dims: // subsequent x and y are now dims::x and dims::y
Point = {
norm() => (this.x^2+this.y^2)^0.5;
Expand All @@ -196,6 +201,8 @@ usage of the same variables.
p = new {Point: x=3;y=4}
}

// the scope is the same so we still access p
!with main:
p.x = 0;
print(p);
print(p.dims::x);
Expand Down
27 changes: 24 additions & 3 deletions playground/test.bb
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
!include {
!with colors:
print(bb.ansi.green+"test");
// main.bb
!namespace dims {
var x;
var y;
}
!namespace main {
var x;
var y;
}


!include { // keep namespace activations in here only
!with dims: // subsequent x and y are now dims::x and dims::y
Point = {
norm() => (this.x^2+this.y^2)^0.5;
str() => "(!{this.x}, !{this.y})";
}
p = new {Point: x=3;y=4}
}

// the scope is the same so we still access p
!with main:
p.x = 0;
print(p);
print(p.dims::x);
Loading

0 comments on commit 6657307

Please sign in to comment.