<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<br>
<div class="moz-cite-prefix">On 07/03/18 05:33, Wolf wrote:<br>
</div>
<blockquote type="cite"
cite="mid:75d08f45-0a79-8336-922e-fec41eb79d60@gmail.com">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<p>The major shortcoming of this thread, the way I see it, is that
the answer provided explains what the compiler does, but not why
the key authors of Free Pascal have made these choices. What
their choices achieve is a substantial watering-down of what is
supposedly Pascal's most significant paradigm: strong typing. As
Jim Lee points out, strong typing does limit utility - but if
utility is first concern, a weakly typed language such as C
would be more appropriate. <br>
</p>
<p>When looking at the (partial) disassembly of my little program,
we see to what degree the compiler writers have sacrificed
strong typing:<br>
</p>
<font face="Courier 10 Pitch"><i><font size="-1"><b>a:=1;</b><br>
movb $0x1,0x22de87(%rip) # move 1 as single byte
into 8 bit wide variable A<br>
<b>b:=a*(-1);</b><br>
movzbl 0x22de80(%rip),%eax # move A into register
%EAX and convert to 32 bit <br>
neg %rax # negate what is in %EAX<br>
mov %al,0x22de87(%rip) # extract the low 8 bit
from %EAX and store it in variable B <br>
<b>writeln(b); // result: 255</b></font></i></font><br>
. . .<br>
<br>
This was compiled without any optimizations. As you can see, the
brackets are ignored, as is the fact that variables A and B were
supposed to be multiplied. In other words, the compiler has
optimized the code, where it was not supposed to do so. It has
also replaced byte typed values with longint typed values. It has
taken my code and translated it as if I had written<br>
<font size="-1" face="Courier 10 Pitch"><i> var <br>
a: byte;<br>
b: longint;</i><i><br>
</i></font><font face="Courier 10 Pitch"><i><font size="-1">
begin<br>
a:=1;<br>
b:=-longint(a); // convert A to a longint and
negate it, then save result in B<br>
writeln( (Lower(b) ); // 'Lower' is a fictional
typecast to denote that I only use the %AL portion of the
%EAX register for the result<br>
end.</font></i></font><br>
Which is quite a bit different from what I did program. Sorry if I
am picky here, but this is the type of bug you can expect in
software if you test using examples, and not through rigorous
reasoning. And this is the reason why the original Borland Pascal
had range checking built-in. If you activate it, the compiler does
complain, both on my little program and on Jim's.<br>
But by now, range checking is optional, and Lazarus at least does
not even activate it by default. <br>
But range checking is not the same as type checking, so I regard
it as a crutch, a work-around that needs to be taken because the
compiler does not adhere to (the spirit of) strong typing. And in
this sense, what I submit here represents the same issue as what
is given in the subject string if the whole thread:<br>
<br>
Strong typing, and also readability, has been sacrificed on the
altar of utility, by using implicit type conversions.<br>
<br>
Maybe we do get some views from the key authors of Free Pascal.<br>
<br>
<br>
Wolf<br>
<br>
</blockquote>
<br>
I didn't fully understand the intent of your first post, but now I
get what you're saying.<br>
<br>
I tend to agree. Strict typing is the main thing that separates
Pascal from C, conceptually. I'd rather not see them converge.<br>
<br>
-Jim<br>
<br>
<br>
</body>
</html>