snirk-lang / protosnirk

The beginnings of a programming language
MIT License
1 stars 1 forks source link

Cannot reference function types from variables #90

Open SnirkImmington opened 5 years ago

SnirkImmington commented 5 years ago

Consider the protosnirk program

fn main()
    // empty

fn foo()
    let bar = main

We emit

%load_main = load void (), void ()* @main
%bar = alloca void main

for the line let bar = main.

From an LLVM perspective, we assume all variables can have allocas created for them and that they can be loaded from them. So we would need to handle the case of variable-sized types or a routine for determining the size of an alloca.

From a usability standpoint, C is the only language that I can think of that supports function pointers but not closures, so it might be a good idea to wait until we have those first...