New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to implement recursive types? #348
Comments
Could you make the offending methods of |
I think |
doesn't that kinda defeats the purpose of eager typechecking though? Btw, can you elaborate a bit on why is it that macros couldn't get the type of their arguments with lazy typechecking? I mean what prevents |
In the original version of lazy type checking, symbols were untyped. So while it wasn't generally recommended, you could do things like:
What is the type of There was also some implementation complexity with keeping a stack of functions to be compiled (remember: mutual recursion), but I believe this is just an implementation detail and shouldn't have any user-visible implications. I think if we were going to go back to more lazy typechecking, it would be an explicit goal to avoid any API changes, so that symbols would still be typed, and therefore it would be possible to type check quotes just by cascading the type checking on any not-yet-type-checked functions, like you describe. |
I see, thanks for the info as always. I ended up adding all methods in the first call to |
Hi!
Consider the following:
Let's say that
Node
has a special requirement to know the size of its fields in order to complete its layout (eg. it might want to reorder them to pack them better). Callingsizeof()
on the types of the fields triggers their completion. Now,dynamic_array(Node)
has no problem with completing itself on a type that isn't complete (i.e. its struct layout is independent ofsizeof(Node)
). However,dynamic_array(Node)
also needs to create methods on its resulting type and those methods do need to callsizeof(Node)
, but it cannot create those methods in__staticinitialize
becauseNode
is not complete yet (remember, we're inNode.__getentries
at this point and we're trying to getsizeof(each field)
).Looks like eager typechecking strikes again :) Any ideas on how to solve this appreciated. Thanks!
PS: In case it's not clear,
dynamic_array(T)
is a Lua function that returns a new Terra type that models a dynamically-allocated array ofT
.The text was updated successfully, but these errors were encountered: