You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because the VM is stack based, can make a simple stored function syntax. Because it is compiled, this doesn't require a particularly performant data structure. It will only be relevant the first time a user-defined program is entered, not during audio rendering.
The [ and ] chars are not used at the moment, so they might be good candidates.
Defining
Proposed syntax:[name proc]
For example: [avg +2/].
This would be easy to compile.
When a [ is encountered, create a pointer to the next char: the start of name.
Insert a null byte at the whitespace.
Create a second pointer to the char after the space: the start of proc.
Insert a null byte at the ].
These two strings are placed in an unordered array of key:value pair structs for retrieval later in the compilation process.
Since compilation takes place linearly, it should be possible to redefine a func whenever.
Invoking
Proposed syntax: [name]
For example: 2 4[avg]
When a [ is encountered, create a pointer to the next char: the start of name.
Read until either a space or a ], and create a null byte at either address.
If no space was detected, it is not a function definition. Search linearly through the key:value array doing nothing more than strcmp over the keys.
If a match is detected, compile the raw string value to bytecode.
This method means recompiling strings every time they are referenced, but it is dead simple.
Should work with recursive invocations, like if the definition of avg was +[divTwo].
The text was updated successfully, but these errors were encountered:
Because the VM is stack based, can make a simple stored function syntax. Because it is compiled, this doesn't require a particularly performant data structure. It will only be relevant the first time a user-defined program is entered, not during audio rendering.
The
[
and]
chars are not used at the moment, so they might be good candidates.Defining
Proposed syntax:
[name proc]
For example:
[avg +2/]
.This would be easy to compile.
[
is encountered, create a pointer to the next char: the start ofname
.proc
.]
.Invoking
Proposed syntax:
[name]
For example:
2 4[avg]
[
is encountered, create a pointer to the next char: the start ofname
.]
, and create a null byte at either address.strcmp
over the keys.avg
was+[divTwo]
.The text was updated successfully, but these errors were encountered: