Skip to content

How to forward declare function that referenced a struct? #109

Answered by edubart
codehz asked this question in Q&A
Discussion options

You must be logged in to vote

You can only do this using <forwarddecl> annotation, here is an example:

local S <forwarddecl> = @record{} -- declare S with incomplete fields
local F = @function(): S -- use S
S = @record{ f: F } -- define S fields

Another option is to use S inside its definition:

local S = @record{ f: function(): S }

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@edubart
Comment options

Answer selected by edubart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants