I'm taking it upon myself to respond since I was the one who labelled a Delphi inline variable example as "not Pascal". But first, I want to say that I sympathise with your point about heredocs, and I specifically sympathise with your using that term since some means of embedding (in particular) SQL (etc.) in the body of a program, where it can be read in the context of the program's flow, is sorely lacking.
I see a lot of "it's not Pascal". Who determines if it's "Pascal"? A group of individuals? We did not invent Pascal, so how can you say something is not "Pascal"?
Is Delphi not "Pascal"? They are the ones who own Pascal. They're the original, they're the ones who pioneered it and added inline variables and type inference, etc.
We must go back to the roots.
Delphi (i.e. Borland, as was) does not own Pascal. FPC does not own Pascal. The ISO has some claim to own Pascal by virtue of their standard, but it was always looked at askance by the community since it was published at a time when implementations like UCSD were dominant but largely ignored them.
I am not entirely happy with a lot of the stuff that has been stuffed into Pascal implementations over the last few years. I don't particularly want to single anything out for criticism since I don't want to be seen as criticising the developers, but by now there are far too many things in the base language. However my specific complaints about this example
procedure Test;
begin
var I := 22;
ShowMessage (I.ToString);
end;
are
* It appears to fly in the face of Wirth's dictum that all declarations should precede begin.
* That however is not its intention, which is that it applies to precisely the following statement.
* But the lack of any form of enclosure obfuscates that.
* The declaration could have been preceded by a begin (and the statement followed by a mandatory end), but that would again fly in the face of "declarations precede begin" and "a single statement need not be encapsulated by begin...end" (the latter being something upon which Wirth later recanted, but not in Pascal).
* The lack of type information hinders both the compiler and the reader. I could quote a related warning from K&R here, but instead would present
procedure Test;
begin
var I := 22;
ShowMessage ((I - 255).ToString);
end;
* Should I be considered signed or unsigned? Should it wrap or raise an exception? If it wraps, at what point? And so on.
So, without trying to sound too Jesuitical, we have to distill certain principles from what Wirth himself (ably assisted by Jensen) wrote about Pascal, and from extensions made to the language by UCSD, ISO, Borland et al. provided that they do not directly fly in the face of the language Wirth designed.
First is that all declarations appear in this pattern:
<header>
<declarations>
<statements>
As far as I can see, Wirth defined it like that at least in part to distinguish it from ALGOL, of which he was washing his hands for political reasons (I've written about that elsewhere). ALGOL declared variables inside the statement block, Pascal does not: like it or not, departing from that is Not Pascal.
Wirth defined that all variables had an associated type specified after the variable name. That was bleeding-edge stuff: most ALGOL implementations were only just waking up to the necessity of specifying whether a variable was a float or an integer let alone to the possibility of strings, structured records, booleans, and integers of different sizes. My position is that Wirth was excessively tolerant of automatic type transfers (casts), and while he subsequently tightened his compatibility rules up doing so was Not Pascal.
And so on.
So, where does that leave us? I would suggest that while the example I gave above was Not Pascal (for the reasons I gave) something like this would be far closer to Wirth's intent:
procedure Test;
begin
with I: integer= 22 do
ShowMessage (I.ToString);
end;
or alternatively
const a: integer= 22;
...
procedure Test;
begin
with I= a do // Inference allowed since consatnt's type known
ShowMessage (I.ToString);
end;
Those are, arguably, Pascal. However even if he had wanted to define the language like that Wirth couldn't have implemented it: he was working with the ALGOL-W compiler based on recursive ascent, and when one compares the /syntax/ of Pascal with that of ALGOL-W one finds that it is very similar: modifying the internal operation of a recursive ascent parser is arduous in the extreme, and Wirth was convinced that he only had a few months to get Pascal demonstrable in order to preempt ALGOL-68.
He was of course wrong in that, but that can be the subject of another rant.
MarkMLl