Closed kevin1 closed 8 years ago
typedefs should happen before top level expressions (globals) are evaluated (because our ast separates typedefs from expressions so we don't know whether a particular expr came before a typedef). However, function calls are allowed to reference these globals as long as the globals happen before the function is called. Consequently, we have to choose:
I think we should go with the first one — don't allow function calls in typedefs. If we do 2nd one, it becomes pretty non-obvious why this code is wrong:
fun F = 1
type t = { m = F () }
Also there's no way to enforce "no global variables" (aka "pure functions only") if you can call out to C++ — for example, F could be rand() or some arbitrary C++. Then F could return something different every time you init t
! And we have a way to make constructors.
Implementation: it may be easier to enforce this at the grammar level rather than in the type/semantic checker.
ok we will go with the second first option. note that our sast may still generate function calls in typedefs because some of our expressions internally call stdlib functions.
meant to say first, not second option lol
closed by #109
@el2724 pointed out while looking at #100