Created
August 1, 2022 18:14
-
-
Save krayfaus/391edda20762afadad4f6cd7e777d661 to your computer and use it in GitHub Desktop.
This is not real source code. The extension here is only for minimal highlighting.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Context :: struct | |
{ | |
allocator : Allocator; | |
assertion_failure_handler : Assertion_Failure_Handler; | |
logger : Logger; | |
} | |
// 'context' is a reserved keyword. | |
// It refers to the currently bound context. | |
// 'action' doesn't need to know the context type. | |
// What to do in case it's called without the required context? compilation error! -_- | |
action :: procedure () | |
{ | |
print("Mode: {}\n", context.mode); | |
} | |
ActionContext :: struct | |
{ | |
using base: Context; | |
mode: String; | |
} | |
main :: () | |
{ | |
action_context : ActionContext = { ...context, "Fast" }; | |
using action_context | |
{ | |
return action(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment