Skip to content
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

Implicit context #73

Open
DenialAdams opened this issue Dec 22, 2022 · 0 comments
Open

Implicit context #73

DenialAdams opened this issue Dec 22, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@DenialAdams
Copy link
Owner

I've grown to like the idea of an implicit context (i.e. Odin, Jai).

It's brilliant for making your allocator explicit (we can move away from the "there is one global heap" system) while not forcing you to thread stuff throughout all of your code.

I'm also very interested if we can generalize the concept of an implicit context.

I've noticed that a very common pattern is my Rust code is creating a "FooContext" struct and threading it through all of the code that deals with Foo. Why can't we use the same implicit context mechanism (not necessarily the same context variable, but some way to declare an implicit context?) to thread something like that through?

Ultimately, I think maybe it would look something like:

  • There is a global implicit 'context' that contains the allocator. It is truly implicit. It has a fixed list of fields.
  • There is a way to define a semi-implict context struct for a set of functions. It is semi-implicit, because I think we still want to show that the functions are connected and depend on a context. Maybe named parameters help here and we just establish a ctx: ctx pattern and forego this, idk.

some more discussion over at zig issue 1286 (not linking it because i don't want github to cross-link my stuff there)

@DenialAdams DenialAdams added the enhancement New feature or request label Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant