dusklang / dusk

The Dusk Programming Language
Other
0 stars 0 forks source link

Cleanup: de-methodification #106

Closed zachwolfe closed 2 years ago

zachwolfe commented 3 years ago

Driver is for all intents and purposes a "god object". This has created a pervasive issue, which is that a piece of code starts out with as little context as necessary to get the job done, e.g., as a method on Type. Then later, I need more context, such as HIR decls. This leaves me with two options: pass in just the HIR data structures to that method, which looks ugly and inconsistent, or move the method up into the Driver, which has many problems of its own. For example, a piece of code might require write access to MIR but only read access to HIR. This is not expressible in this paradigm at all, because the borrow checker requires the Driver instance to be mutable. This leads to ugly workarounds and unnecessary copies.

Proposed solution: just use free functions, and pass only the necessary context.

zachwolfe commented 2 years ago

not a priority