[Oberon] Should one automatically initalize local pointer or procedure variables (safety precaution)?
skulski at pas.rochester.edu
Mon Mar 4 19:10:19 CET 2019
> PROCEDURE P;
> VAR ptr1, ptr2, ptr3: Ptr;
> BEGIN ptr1 := NIL; ptr2 := NIL; ptr3 := NIL; proc1 := NIL; proc2 := NIL (* <--- generated by the compiler*)
> END P;
>Such a scheme could easily be accomplished via the code below. However, if the programmer -
>adopting good programming style - himself initializes a local pointer or procedure variable before
>it is used, it will be initialized twice. Which is an argument against adapting the compiler in this way.
If pre-assigning NIL to pointers becomes an official part of the language then programmers will stop initializing on their own.
>PS: If you are familiar with the (internals of the) Swift compiler, you’ll know what I am getting at..
I have not heard of Swift. I checked the Wikipedia. There I found:
"Swift was introduced at Apple's 2014 Worldwide Developers Conference (WWDC)."
"Swift won first place for Most Loved Programming Language in the Stack Overflow Developer Survey 2015..."
More information about the Oberon