Get the latest tech news

Context: Odin’s Most Misunderstood Feature


Even with the documentation on the topic, many people completely misunderstand what the context system is for, and what problem it actually solves. For those not familiar with Odin, in each scope, there is an implicit value named context. This context variable is local to each scope and is implicitly passed by pointer to any procedure call in that scope (if the procedure has the Odin calling convention). The main purpose of the implicit context system is for the ability to intercept third-party code and libraries and modify their functionality. One such case is modifying how a library allocates something or logs something. In C, this was usually achieved with the library defining macros which could be overridden so that the user could define what they wanted. However, not many libraries support this, in any language, by default which meant intercepting third-party code to see what it does and to change how it does it is generally not possible.

None

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Context

Context

Photo of odin

odin

Related news:

News photo

Apple CEO Tim Cook out-earns the average American’s salary in just 7 hours—to put that into context, he could buy a new $439,000 home in 2 days

News photo

Show HN: SFX – A language where 0.1 and 0.2 = 0.3 and Context is first-class

News photo

Agentic AI is all about the context — engineering, that is