ObjectFlux
Jump to navigation
Jump to search
Designed by | User:Z Z |
---|---|
Appeared in | 2022 |
Computational class | Unknown |
Reference implementation | Unimplemented |
File extension(s) | .of |
Added here due to non trivial syntax.
work in progress (rewriting old stuff that was left from Array++)
Created by User:Z Z
Inspired by Table, Boxy and JSON
Reserved symbols
; ' ` { } ( ) [ ] " ~ $ , @ ^ : . \ # | 0 1 2 3 4 5 6 7 8 9
Grammar
Main
- force call ; - next (could be used for private variables) ' - nil ` - nil { - mutable object start } - mutable object end ( - local object start ) - local object end [ - non-mutable object start " - string (switches to String grammar) ~ - size , - add to return stack @ - argument object ^ - self in parent function : - name object . - get (if no argument is provided, return all internals of that object) \ - break $ - continue ( break, but for local objects ) # - define directive (used to specify parameters for internal object creation, when compiler generates the binaries) // - comment (switches to Comment grammar (line)) /* - comment (switches to Comment grammar (block)) | - operator
String
\ - special " - end (switches to Main grammar)
Comment (line)
\n - end (switches to Main grammar)
Comment (block)
*/ - end (switches to Main grammar)
Symbols description/usage
define
any unknown symbol - name (body) - same as arrow function in JS {body} - mutable function [body] - non-mutable function
operators
. - access children box (box.data box) (just image as you open a box, and takes out the element using your hand. the hand is "." ) ~ - split into array box~ - get size (index count) box~size - return splitted box into array box~:data - set index amount " - copy (same box different pointer) # - thread # - get thread ID, #box - define each entry inside(useful for loading/generating things)(return node of results), data#box - define data amount threads doing box) note: if you need local ID: save count of running threads, and then substract from current ID. (there should be no collisions in thread IDs, becase IDs on loop start are reservered) Just imagine this as compute shader) , - box end (mostly used to concat data) ' - nil (use to execute function with no args, since everything is a function) | - is operator (declare that compiler should find argumant on both sides) ( {| ) - function is operator ( | ) - get 1st argument (if it returns [], then this got called as a function) : - assign box to name / assign value to variable if no pointer provided, It'll just append with next index whenever box assigned to higher variable, its owner will change, and it wont unload when code box is finished variable owner will be closest one to the root of execution stack, so when it will be unloaded, there will be no actual pointers back to it. - calls argument first, then a function. If one of arguments missing, works as white space. Note that for built in operators this is optional.
varables
\ - same as _ENV in lua, but here returns the stack with loaded variables (threads located inside, where they got called)
misc
@ - label (places itself in stack of a block) ^ - back (it can be used to create loop) ^n - (goes to last "n" @ in stack, error if no found) $ - execute during declaration(basically used to cache/precompute data inside node declaration) $box - replaces itself with the box, (usually used as node : {$cache_things'([0]);$cache_things'([1])}) ; - end box and move to the next index ! - one line comment (final) !~comment~! or !`comment`! - multiline comment (final) (with ` hurts to type so thats why there is ~) ` - data escape (used to end block) `` - ` `] - end extcode block enter, space, tab - ignored by compilator
Examples
Sorting check
C++
#include <iostream> #include <stdio.h> int main() { int S = 0; std::cout << "size: "; std::cin >> S; int* A = new int[S]; //++S; std::cout << "elements:\n"; for (int i = 0; i < S; ++i) std::cin >> A[i]; int E = 0; for (int i = S - 2; i >= 0; --i) if (A[i] >= A[i + 1]) ++E; std::cout << "entropy: " << E; }
Array++
estd_cfg : {operators : 1} estdl : estd.init estd_cfg; !estd is standard library that provides math and etc main : estdl,{ ! concat estdl and function, so you shouldnt access estdl every time directly print "size: "; input.end : "\n"; ! modify function's end symbol array~ : atoi input'; ! pointer to recived data (atoi - ascii to integer) print "elements:\n"; index : 0; ! name cell, where 0 located @'; ! loop start array. index' : atoi input; ! read input (because . cancel calling we should load index value first) index : index' + 1; ! but "index : { +'{ index'; [1] }};" returns function, not data! {^;}.( index' >= array~' )'; ! loop reset pthread : #'; ! get current thread ID entrop : +{ ! summ all entries in array ( array~' - 1 ) # { ! new threaded function i : #' - pthread'; ! local variable that contains func array. i' >= array.( i' + 1 ) ! return } }; print("entropy: ", i2s entrop'); ! write result (i2s - integer to string) } main' ! execute main
Array++ (same, but no comments)
estd_cfg : {operators : 1} estdl : estd.init estd_cfg; main : estdl , { print "size: "; input.end : "\n"; array~ : atoi input'; { print "elements:\n"; index : 0; @'; array. index' : atoi input'; index : index' + 1; {^;}.( index' >= array~' )'; }'; pthread : #'; entrop : +{ ( array~' - 1 ) # { i : #' - pthread'; array. i' >= array.( i' + 1 ) } }; print("entropy: ", i2s entrop'); } main'
Tricks
Rebinding stuff
= : ":"; ! declare that = now does same as : ":" =; ! declare that : now does nothing begin = "{"'; ! retrieve { safely begin = ({); ! does same thing as above "\n" = (;); ! "\n" parsed during compilation, so there is no problem with this