(*** Does anybody know how UCSD behaves here? I don't want to dig out my old Apple //e in order to check this. ***)
Yes, it clips strings and it has a 10 for the default field size. Borland is the only Pascal compiler that I have used or heard of that does not clip strings and uses 1 as the default field size. Does someone know of another one (besides gpc)?
The above does not clarify how GPC's default behaviour should be.
It should be ISO Pascal with the de-facto-standard field widths.
IMHO Borland's method is more logical than what most Standard Pascal compilers do.
It may be more logical, but we didn't design the language.
However the only true contradiction between Borland and ISO in this context is string clipping which only occurs in very rare cases (at least in my programs).
It happens in quite a few places in my programs. In fact, it breaks one of my standard teaching examples to show students the power of Pascal. (Write a program to print a right triangle of stars (*).)
Thus I could live with string clipping being "on" by default. Concerning field widths, it does not contradict ISO Standard to follow Borland, so we should do that. (Remember that `--borland-pascal' turns string clipping off and that `--standard-pascal' makes GPC behave like other Standard Pascal compilers.)
I can not live with either being the standard behavior. If you do make Borland behavior standard, at least make it a configure option to not make Borland behavior standard so I don't have to maintain local changes to gpc to get what I really want. Similarly, if you choose to make Standard Pascal the default behavior, have a configure option to choose Borland for those who want it. Better yet, make gpc change depending on whether it is run as gpc (Standard Pascal) or bpc (Borland Pascal).
- When an Integer value is being output with a field width of zero, output is suppressed. Is this ISO Standard (doesn't seem so), or a bug?
This is not conforming and needs to be changed. It should be the same as 1.
- When a Real value is being output with a too narrow field width, other compilers bother to make the output as short as possible. Should GPC do the same?
It should follow 6.9.3.4.1 (ISO 7185) which says:
if TotalWidth >= ExpDigits + 6 then ActWidth := TotalWidth else ActWidth := ExpDigits + 6;
where ActWidth is the actual number of characters written, yeilding the format SV.V+EE where is S is - or blank, V.V is the number, EE is the exponent. (+ could be -).
- All Pascal compilers I have access to have the "feature" that it is impossible to output a positive Real value without at least one leading blank. This is annoying in some situations, so what about an additional switch, e.g. `--no-real-blank', to disable it optionally? (Better suggestions for the names of all compiler switches are welcome!)
Yes, they are following the standard. I have no problem with the switch as long as it is not standardly on.
Is it possible we should ask Juki what the standard behavior should be? Borland vs Standard?