<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 06.11.2015 22:45, Mark Morgan Lloyd
      wrote:<br>
    </div>
    <blockquote cite="mid:n1j71n$dca$1@pye-srv-01.telemetry.co.uk"
      type="cite">Luca Olivetti wrote:
      <br>
      <blockquote type="cite"> with a=somerecord, b=someotherrecord do
        <br>
         begin
        <br>
           a.x:=b.x;
        <br>
         end;
        <br>
      </blockquote>
      <br>
      Just because something is 20+ years old doesn't necessarily make
      it bad. That syntax looks OK to me (i.e. make a and b look like
      consts) but I also find myself wondering what the type rules are,
      i.e.
      <br>
      <br>
      with pod: TTabSheet= Pages.Objects[deleteAt] do
      <br>
      <br>
      vs
      <br>
      <br>
      with pod= TTabSheet(Pages.Objects[deleteAt]) do
      <br>
    </blockquote>
    <br>
    Do not forget that you can overload operators! In particular you can
    overload the comparison operator to return a record, so your<br>
    "with a=somerecord do" can already be a valid pascal code now:<br>
    <br>
    <tt><b>type</b></tt><tt><b><br>
      </b></tt><tt><b>  TMyRec = record</b></tt><tt><b><br>
      </b></tt><tt><b>    I: Integer;</b></tt><tt><b><br>
      </b></tt><tt><b>  end;</b></tt><tt><b><br>
      </b></tt><tt><b><br>
      </b></tt><tt><b>  TMyResult = record</b></tt><tt><b><br>
      </b></tt><tt><b>    Res: Integer;</b></tt><tt><b><br>
      </b></tt><tt><b>  end;</b></tt><tt><b><br>
      </b></tt><tt><b><br>
      </b></tt><tt><b>operator = (z1: TMyRec; z2 : TMyRec) b :
        TMyResult;</b></tt><tt><b><br>
      </b></tt><tt><b>begin</b></tt><tt><b><br>
      </b></tt><tt><b>  Result.Res := z1.I+z2.I;</b></tt><tt><b><br>
      </b></tt><tt><b>end;</b></tt><tt><b><br>
      </b></tt><tt><b><br>
      </b></tt><tt><b>var</b></tt><tt><b><br>
      </b></tt><tt><b>  m1, m2: TMyRec;</b></tt><tt><b><br>
      </b></tt><tt><b>begin</b></tt><tt><b><br>
      </b></tt><tt><b>  m1.I := 10;</b></tt><tt><b><br>
      </b></tt><tt><b>  m2.I := 1;</b></tt><tt><b><br>
      </b></tt><tt><b>  with m1=m2 do</b></tt><tt><b><br>
      </b></tt><tt><b>    writeln(Res);</b></tt><tt><b><br>
      </b></tt><tt><b>  readln;</b></tt><tt><b><br>
      </b></tt><tt><b>end.</b></tt><br>
    <br>
    The assignment operator would be better, since it doesn't return a
    value (in pascal, of course) and thus cannot be used in a with
    statement now:<br>
    <br>
    <tt><b>with a:=somerecord, b:=someotherrecord do</b></tt><tt><b><br>
      </b></tt><tt><b>begin</b></tt><tt><b><br>
      </b></tt><tt><b>  a.x:=b.x;</b></tt><tt><b><br>
      </b></tt><tt><b>end; </b></tt><tt><b><br>
      </b></tt><br>
    IMO there is no need to set a type of a/b on the left side of the
    with assignment - the left side should always gain the type from the
    the right side. In this case you can decide whether the "AS" or the
    direct re-type should be used:<br>
    <br>
    <b><tt>with pod := Pages.Objects[deleteAt] as TTabSheet do
      </tt></b><b><tt><br>
      </tt></b><b><tt>
        with pod := TTabSheet(Pages.Objects[deleteAt]) do
      </tt></b><b><tt><br>
      </tt></b><br>
    -> both are valid and the syntax is already in pascal - why not
    to use it.<br>
    <br>
    Ondrej<br>
  </body>
</html>