Anyone got any interest/comment on the following simple object system in AOK? No inheritance or polymorphism but, hey, you can't have everything.
There's a whole tutorial on this at
https://ttv1.github.io/aok/
A brief intro follows.
AOK is a pre-processor that converts
a.b.c
into
a["b"]["c"]
Very simple trick but it starts to make AWK code starting to look at lot like Python, Ruby, LUA etc.
For a simple example of AOK, the following Symbol constructor initializes something that tracks string frequency. Also, it keeps a handle on the most fr3quent string seen so far (the mode).
function Symbol(i) {
have(i,"count")
i.mode = ""
i.most = 0
}
function have(lst,key,fun) {
# ensure there is a list at key.
# recursively, build a nested structure with "fun", if supplied
lst[key][1];
delete lst[key][1]
if (fun) @fun(lst[key])
}
The interface to Symbols is the Symbol1 function that updates the count, mode etc.
function Symbol1(i,str, n) {
n = ++i.counts[str]
if (n > i.most) {
i.mode = str
i.most = n
}}