QOL Proposal: use(xxx) statement to reduce repeating element #1098
Labels
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
I propose zig uses the use statement as a way to reduce repeating code in a given block.
idea taken from D with statement but would want to support a reduced usage set. The look up rule works as such, it first tries to look up the symbol in the use block, if that fails it follows the normal scope look up rules.
Example:
Example of possible use on struct function, lets you avoid typing self.xxxx for everything.
Can be used on enum types:
I would think we would not want it allowed on optional? or error! types.
It would be a nice to have on function signatures like foo1 or foo2, but not necessary.
It isn't difficult to support nesting use blocks, but I found in D that it makes the code harder to read.
PROS:
CONS:
The text was updated successfully, but these errors were encountered: