<aside> 💡 Owner: @Marcin Hagmajer

</aside>

// - AskCode is simpler than AskJSX because it deosn't have structures
// just chain of function expressions
//
// - simple expressions with function calls and identifiers
// - values encoded in json, strings in double or single quotes
// -
// - types available as first argument to `typed<T>(type: Type<T>, b: any)`
// - function application
// - anonymous function initializer { }

"Hello world!"

typed(string, "Hello world!")

{typed(string, "Hello world!")}

// function is just a series of expressions in a special, deferred block
// with expression separated by commas
// - much like function arguments and JSON arrays.

{typed(string, "Hello world!"), 'hi!'}()

{
	join('Hello ', ref('$0')),
}('Alice')

//

AskCode is basically functions applied to JSON values, plus the deferred operation block defined by d( which is a list of AskCode expressions to evaluate. Unless a returnedValue is set by your code somewhere with an operation like $returnedValue = v('Hello') then the value of the last expression will be become the value of the block. Blocks voluntarily can expect arguments. These are defined by AskCode expressions again with familiar syntax.

'Hello world!' // hello world in AskCode

// function (d) which return hello world

d('Hello world')(any) // needs `any` to exist in the type the environment

// this is a function that return the 'Hello world' string and will be validated against it

d('Hello world')(any) // needs `any` to exist in the type the environment

(d(r('id'), v('Hello world!'))(string, int), '5')

d(c('id', int, 5), join(toString(r('id')), 'Hello world'))

// d(c('id', int, 5), join('Hello ', r('id'):toString()))
// d(c('id', int, 5), r('id'):toString::join('Hello '))

// d(const('id', int, 5), get('id'):toString::join('Hello '))

// VM ma skórty na const, a aliasy jako let

d(const('id', int, 5), join(toString(get('id')), ' world!'))(string)

// z sugar na poziomie VM

d(const('id', int, 5), get('id'):toString::join('Hello '))(id)
'Hello world!' // hello world in AskCode

// anonymous function which return hello world

d('Hello world')(any) // needs `any` to exist in the type the environment

// this is a function that return the 'Hello world' string and will be validated against it

d('Hello world')(string) // needs `string` to exist in the type the environment

// This i us calling the function

(d('Hello world')(string)) // typed Hello world #1

typed(string, 'Hello world') // typed Hello world #2

// similarily with arguments

d(join('Hello ', get('args.0'), '!'))('John')

(d(r('id'), v('Hello world!'))(string, int), '5')

d(c('id', int, 5), join(toString(r('id')), 'Hello world'))

// d(c('id', int, 5), join('Hello ', r('id'):toString()))
// d(c('id', int, 5), r('id'):toString::join('Hello '))

// d(const('id', int, 5), get('id'):toString::join('Hello '))

// VM ma skórty na const, a aliasy jako let

d(const('id', int, 5), join(toString(get('id')), ' world!'))(string)

// z sugar na poziomie VM

d(const('id', int, 5), get('id'):toString::join('Hello '))(id)

AskQL queries are parsed into AskScript programs and then compiled into AskJSX programs and then compiled int to AskCode. AskCode consists only of 7 (to check) operations to simulate a Turing complete computing system.

Syntax

AskCode is an AskElement as JSON

AskElement is a tuple of string name and arguments being JSON values or other AskElements

['c', {}, ..., {}]
[elementSymbol, ...args]

Elements


https://notion-ga.ohwhos.now.sh/collect?tid=UA-147529689-3&host=hostnotion.co&page=/AskCode-data-request-protocol-e97e75e9acbe48a89dd93f313e62e9eb