<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <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 face="Courier 10 Pitch" size="-1"><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>
    <br>
    PS.: while composing this mail, Santiago wrote:  Pascal needs to
    break backward compatibility to advance, that is, in fact, a new
    language. But if pascal is struggling to survive, let alone a new
    language if you are not mozilla, google...<br>
    <br>
    In which direction should Free Pascal move - lower type (range,
    overflow, memory) checking demands, with the implied additional
    sources for bugs, but also better speed and shorter code, a la C, or
    should Free Pascal rather take the lead and move towards safer, and
    more trustworthy, code, a la Rust?<br>
    <br>
    W.<br>
    <br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 03/07/2018 11:26, Jim Lee wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:88a472c9-d729-7ec9-8362-6b78a145986d@gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <p><br>
      </p>
      <br>
      <div class="moz-cite-prefix">On 07/02/18 15:13, Wolf wrote:<br>
      </div>
      <blockquote type="cite"
        cite="mid:7209b3ba-27e6-958f-b2be-a62c9e0d7771@gmail.com">
        <meta http-equiv="Content-Type" content="text/html;
          charset=utf-8">
        <p>Not so long ago, Florian was proudly bragging about "Pascal
          does not allow you to <a moz-do-not-send="true"
href="http://www.toodarkpark.org/computers/humor/shoot-self-in-foot.html">shoot
            yourself in the foot</a>"</p>
        <p>What about this little program:</p>
        <p>program Project1;<br>
          <br>
          var a,b: byte;<br>
          begin<br>
            a:=1;<br>
            b:=a*(-1);<br>
            writeln(b);    // result: 255<br>
          end.<br>
              <br>
        </p>
        <p>The result is obviously correct, given how the variables are
          declared. But there are no compiler warnings / errors that the
          assignment b:=a*(-1) is fishy, to put it mildly. And if you
          are serious about strong typing, it ought to be illegal, with
          a suitable complaint from the compiler.</p>
        <p>Who is shooting whom in the foot?</p>
        <p>Wolf<br>
        </p>
        <br>
        <br>
      </blockquote>
      <br>
      Should the compiler balk at this as well?<br>
      <br>
      program Project1;<br>
      <br>
      var a,b,c: byte;<br>
      begin<br>
        a:=5;<br>
        b:=6;<br>
        c:=a-b;<br>
        writeln(c);    // result: 255<br>
      end.<br>
      <br>
      Without the implicit conversion of signed/unsigned values, the
      utility of the language is greatly diminished.<br>
      <br>
      -Jim<br>
      <br>
      <!--'"--><br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
fpc-pascal maillist  -  <a class="moz-txt-link-abbreviated" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a></pre>
    </blockquote>
    <br>
  </body>
</html>