askql
askql copied to clipboard
[playground] Infinity is reported as null
Consider the following program:
ask {
const factorial: int(int) = fun(n:int):int {
if (n < 2) {
return n
}
n * factorial(n - 1)
}
200:factorial
}
In CLI the result is:
float ask(const('factorial',fun(let('n',get('$0')),if(call(get('<'),get('n'),2),block(return(get('n'))),block()),call(get('*'),get('n'),call(get('factorial'),call(get('-'),get('n'),1))))),call(get('factorial'),200))
Infinity
🦄
However, Playground displays:
null
@czerwinskilukasz1 that is because of how JSON works: http://www.ecma-international.org/publications/standards/Ecma-404.htm So:
JSON.stringify(Infinity); //null
JSON.stringify(NaN); //null
@czerwinskilukasz1 as I understand the playground should showcase the scenario of client-server communication where client sends AskQL query and receives a JSON response back. JSON is the widely accepted format of data transfer so it makes sens to keep it for transporting the response. That's also how Graphi works for GraphQL. I don't think we're able to return Infinity
or NaN
back to the client from the server in JSON. What's your idea for handling that? Should we even allow Infinity
or NaN
as a result of AskQL query?