Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The Pascal/Modula-2 WITH statement brings all of the members of a record into the lexical scope, without them being mentioned in the statement (i.e. implicitly).

So when you add, remove or rename members of a record, you are potentially influencing the contents of scopes in other files all over the project. You can cause variable shadowing that way.

   VAR
     B : INTEGER;

   WITH ^P DO
     A := B;  (* B is just a local, A is a field *)
   END
If B is added as a field, the above suddenly means ^P.A = ^P.B.

Any time you edit a Modula-2 record, you have to search the program for all the places where its type may be targeted by WITH.

Probably if you stick to some rules, like never using WITH on another module's record type, you will be fine.

Diagnostics related to shadowing could help.



I assume it’s statically checked, so you’ll get a compilation error?




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: