[Oberon] Life without local procedures
dsar at eml.cc
Thu Feb 22 19:51:49 CET 2018
On Wed, Feb 21, 2018, at 10:16 PM, Richard Hable wrote:
> I needed to search through a file line-by-line, splitting each line into
> parts and comparing some of those parts to the values I looked for. In
> order to keep the implementation readable, I extracted the line handling
> code into a separate method. Ideally, this would have been a local
> method with access to the local variables of the calling method.
This is indeed a case where a local procedure makes more sense
> I ended up creating a private method visible to the whole class, with
> more parameters than should have been necessary, and accessing member
> variables where it should only have to access local variables of the
> calling method.
When local procedures are not present this is the default programming
style, that is wrong because also the private interface must be kept
clean from unrelated procedures.
An alternative solution is to inject a service class that contains procedures
for that particular case, but I consider it an overwhelming solution, although
At work we use a language that is mainly object oriented but also supports
local procedures and I used them a lot to split the logic of big procedures.
My coworkers were puzzled at the beginning, they were used to private
methods, but with time they started to use local procedures too.
> Thus, my vote goes to keeping the support for local procedures in the
> Oberon compilers, including access to intermediate variables...
I can live without intermediate variables, especially if they simplify and
improve compiler code generation.
More information about the Oberon