On 21/11/12 7:49, Kenneth Cochran wrote:
Yes.

type newString = type string;

Any function that accepts newString as a parameter will cause a
compilation error if you try to pass a normal string. You'll have to
cast it to newString first.

This is not the case, as the following program demonstrates. The compiler does not even blink.

program Project1;

{$mode objfpc}{$H+}

type TnewString = type string;

function NewStringFn(ns: TnewString): integer;
var c: Char;
begin
  Result := 0;
  for c in ns do
   if (c<>#0) then inc(Result);
end;

var s:string = 'ansistring';
    ns:TnewString = 'new string';
begin
  writeln('The new string length is ',NewStringFn(ns));
  writeln('The old string length is ',NewStringFn(s));
end.

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to