Once upon a time, on 11/21/2012 08:37 PM to be precise, Frank Church said: > Lets say I am using some string variables, but I want to ensure that > there are no typing errors in some code I am using. > so I define newString as a new string type and declare a variable as > ANewString. > > That way if I create a function such as functionUsingNewString(a: > newString) and I pass a plain string as a parameter to > functionNewString the compiler declares an error. > > If c is string and b is newString and I do b := c the compiler should > generate an error unless I do b := newString(c); > > Is this possible? If you declare something like
Type NewString = Record Data: Array of Char; End; And a function: Function ToNewString(a: String): NewString; Begin SetLength(Result.Data, Length(a)); Move(a[1], Result.Data[0], Length(a) * SizeOf(Char)); End; ; The compiler should generate an error when you try to typecast a String to a NewString. -- Ewald _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal