language · keyword ·
to
Connect map key/value or function input/output types
Use a map for lookup by identity or name when sequential scanning would hide the intent.
toStatus: experimental
Function pointer call
Use a map for lookup by identity or name when sequential scanning would hide the intent.
cpu · complete-program · type checked
Twice(int value) returns int
{
return value * 2
}
AddThree(int value) returns int
{
return value + 3
}
function of int to int callback = Twice
int doubled = callback(21)
callback = AddThree
int shifted = callback(doubled)
if shifted == 45
{
Console.Log("function-pointer-ok")
}
project.mech
package = "tests.compiler.kyber.functionPointerCall"
version = "0.1.0"
backend = "kyber"
osTarget = "windows"
archTarget = "x64"
selfContainedApp = false
Notes and source
Map literals and list literals both use brackets; to distinguishes a map pair.
Collections are experimental.
yeho/parser_types.cpp parseMapTypeRef; parser_expressions.cpp parseListOrMapLiteralExpression