Skip to content

Commit 9b03caa

Browse files
authored
Merge pull request #16 from ECP-Solutions/change_run_procedure_to_function
Change `Run` procedure to function
2 parents 77d4cee + 1fa7da6 commit 9b03caa

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,35 @@
22

33
All notable changes for ASF. This file combines the release notes from the project's releases.
44

5+
## [v2.0.7] - 2026-01-28
6+
https://github.com/ECP-Solutions/ASF/releases/tag/v2.0.6
7+
8+
## Summary
9+
10+
ASF v2.0.7 is a minor improvement for `ASF` core ergonomic.
11+
12+
---
13+
14+
## Highlights
15+
16+
- **Improved**:
17+
- ASF: the `Run` method now returns the result of the compiled program being executed.
18+
```vb
19+
Private Sub ForEachTest()
20+
Dim result As Variant
21+
Dim engine As ASF: Set engine = New ASF
22+
23+
With engine
24+
result = .Run(.Compile("o = {x: 10, y: 20}; s = 0; o.forEach(fun(v) { s = s + v }); return(s);"))
25+
End With
26+
Set engine = Nothing
27+
End Sub
28+
```
29+
30+
31+
---
32+
**Full Changelog**: https://github.com/ECP-Solutions/ASF/compare/v2.0.6...v2.0.7
33+
534
## [v2.0.6] - 2026-01-23
635
https://github.com/ECP-Solutions/ASF/releases/tag/v2.0.6
736

docs/API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This document describes the runtime API exposed by ASF scripts and the VM builti
3131

3232
## Runtime model & conventions
3333

34-
- **Program**: a compiled AST that can be executed by the VM. The ASF host exposes `.Compile(script)` → programIndex and `.Run(programIndex)` to run.
34+
- **Program**: a compiled AST that can be executed by the VM. The ASF host exposes `.Compile(script)` → programIndex and `.Run(programIndex)` to run. The `Run` method returns the result of the program being executed.
3535
- **Scope / closures**: closures capture the environment by reference (shared-write semantics). That means nested functions can mutate outer-scope variables and see changes across closures.
3636
- **Indexing base**: arrays honor `__option_base` set in runtime globals (commonly 0 or 1). All array helpers and methods handle this consistently.
3737
- **Call signature for array callbacks**:

docs/Language reference.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,8 @@ Sub RunASFCode()
105105
code = "let x = 10; print(x * 2);"
106106
107107
' Compile and run
108-
Dim idx As Long
109-
idx = engine.Compile(code)
110-
engine.Run idx
111-
112-
' Get output (if function returns a value)
113108
Dim result As Variant
114-
result = engine.OUTPUT_
109+
result = engine.Run(engine.compile(code))
115110
End Sub
116111
```
117112

src/ASF.cls

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ End Sub
4545
Public Property Get OUTPUT_() As Variant
4646
vAssignment OUTPUT_, OUTPUT__
4747
End Property
48-
Public Sub Run(idx As Long)
48+
Public Function Run(idx As Long) As Variant
4949
If Not GLOBALS_ Is Nothing Then
5050
With VM_
5151
.SetGlobals GLOBALS_
5252
.RunProgramByIndex idx
5353
vAssignment OUTPUT__, .OUTPUT_
54+
vAssignment Run, .OUTPUT_
5455
If .verbose Then
5556
Debug.Print "=== Runtime Log ==="
5657
Dim elm As Variant
@@ -60,7 +61,7 @@ Public Sub Run(idx As Long)
6061
End If
6162
End With
6263
End If
63-
End Sub
64+
End Function
6465
Private Sub vAssignment(ByRef var As Variant, ByRef vValue As Variant)
6566
If IsObject(vValue) Then
6667
Set var = vValue

0 commit comments

Comments
 (0)