Skip to content

Commit e848b89

Browse files
committed
docs
1 parent e6f3e9a commit e848b89

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

doc/language_specification.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ OcheScript is a dynamically-typed, interpreted scripting language designed for e
2626
- [Native Functions](#native-functions)
2727
- [Dart Interop](#dart-interop)
2828
- [Directives](#directives)
29+
- [Runtime Stack Size Limits](#runtime-stack-size-limits)
2930

3031
## Entry
3132
[Back To Table Of Contents](#table-of-contents)
@@ -970,7 +971,9 @@ Using include directives is a compile-time preprocessor operation, and is platfo
970971

971972
See [Windows Example](http://github.com/atebitftw/ochescript/blob/main/lib/windows_preprocessor.dart).
972973

973-
## Stack Size Limits
974+
## Runtime Stack Size Limits
975+
[Back To Table Of Contents](#table-of-contents)
976+
974977
Since the scope of this language is to live embedded inside other Dart applications, the virtual machine stack is fixed to a size of 8192 elements. This is to prevent memory exhaustion in the host Dart environment. If the stack overflows, the virtual machine will throw a runtime error.
975978

976979
Most scripts will rarely come close to this limit (most will never exceed 100). However there are some rare scenarios that could cause a stack overflow:
@@ -982,4 +985,4 @@ Most scripts will rarely come close to this limit (most will never exceed 100).
982985
```js
983986
var x = [1, 2, 3, ..., 8192]; // are you really declaring 8192 static elements in a list??
984987
```
985-
This will cause a stack overflow because the compiler pushes each element of the list onto the stack before actually building the list. Better to define the list dynamically (e.g. `var x = []; for (var i = 0; i < 10000; i++) x.add(i);`) as this only pushes one element onto the stack at a time.
988+
This will cause a stack overflow because the compiler design pushes each element of the list onto the stack before actually building the list. Better to define the list dynamically (e.g. `var x = []; for (var i = 0; i < 10000; i++) x.add(i);`) as this only pushes one element onto the stack at a time.

0 commit comments

Comments
 (0)