OK. Please understand that I'm not trying to criticise or snipe here, just trying to get to the bottom of things.
I believe it was alpine ? who mentioned that scripting languages are more flexible with variable declaration. My experience with a scripting language concurs.
Maybe, but I think you've been making the distinction for some while. I think that the point he might have been making was that that type of language tends to be far more heavily oriented towards global variables possibly modified by a namespace prefix, although I'd tentatively suggest that at least some of them belatedly adopted the ALGOL/Pascal scoping rules (to the extent that they could without breaking their backwards compatibility).
Scripting languages, and others with a "compile on demand" or "execute this string" facility, also tended to allow things to be declared and undeclared on the fly. Note that I'm saying "declared" here, i.e. something exists as a named entity, rather than "defined" i.e.something has a sensible value (in many cases this is non-nil, consider Pascal's Assigned() function).
So if we have broad agreement over what a scripting language is (and I don't think we're far from that), then it is possible to "undeclare" something by expunging this from the relevant namespace: and this is distinct from allocating something the undefined value (nil or whatever).
I'd throw in that some languages are more serious about the behaviour of undefined values than others. For example, in SQL the result of a nil = nil comparison is false, since no assumptions at all can be made about that content.
In ALGOL/Pascal it's not possible to undeclare something, although it's possible to (unintentionally) lose a reference to something on the heap resulting in a dangling pointer. The nearest you can get is a pointer with a nil value, but that pointer is still normally identified by name so it's not really undeclared. However when doing very low-level work one can hit problems, since while a pointer containing a nil cannot he dereferenced a pointer containing a zero address can... but their bit patterns are indistinguishable.
So there is really no bit pattern which can be assigned to a pointer to call it undefined. Similarly, there is no bit pattern that can be assigned to an integer which will be unambiguously interpreted as undefined: that's why a (16-bit, signed) integer runs -32768..+32767 with no gaps.
So in ALGOL/Pascal and their derivatives, there is no way to undeclare something (declaration is handled by the scoping rules), and no value that can be assigned to a pointer or integer which will be unambiguously interpreted as undefined.
I understand that the original version of pascal by wirth was not perfect didn’t enforce what to do with loop variable after the loop. Maybe there are other versions of pascal out there that don’t address the undefined variable after loop issue.
Are you seriously suggesting that there are versions of Pascal that weren't invented by Wirth?
At this point fpc will probably out live Delphi if Delphi is resorting to this sort of convoluted nonsense.
Why be stay tethered to inferior versions of pascal?
For compatibility with what Wirth defined.
If the variable is indeed Not guaranteed to be what it was last assigned in the loop {or is uninitialized } something should be done about using undefined variables.
Allowing this is not robust language design. If people are porting old pascal code to fpc and are trying to use an unassigned variable. It should warn them in my opinion or even give a compile error. I don’t know much about compilers so I don’t know how this can be done but it definitely should be done...
Sven said that it was something best considered by Florian. Knowing the extent to which Sven's been deeply involved with the compiler I wouldn't for one minute dream of arguing about that.
MarkMLl