I would like to write my own custom compound statements that have a similar mechanism to using
and lock
mechanisms where they have code injected at the beginning and end of the statement block before compilation.
I have tried searching for questions who may have asked similar questions but I could not properly figure out what this kind of "code scoping" is called, other than the documentation saying these are compound statements.
Im aware that "lock" and "using" are keywords. I dont want to have my own keywords as I know this is not possible.
Im not sure if this is possible in c# for example:
Rather than doing:
StartContext(8);
//make method calls
EndContext();
This could be reduced down to:
DoSomethingInContext(8) {
//make method calls
}
Ofcourse this does not have to be just a single one line call. The start and ends of encapuslated code could be multiple lines of code thats is inserted by the custom compound statement.