On Wed, 31 May 2023, Hairy Pixels via fpc-pascal wrote:
What's the best way to make a pointer type which is distinct so that the following snippet would give an error. I thought "type pointer" would do it but it doesn't seem to work. type PA = type pointer; PB = type pointer; var a: PA; b: PB; begin a := b; // should give an error! end;
Type aliases are always assignment compatible. As far as I know, there is no way to do what you want with just 'pointer'. This will give an error: Type RA = record end; RB = record end; PA = ^RA; PB = ^RB; var a: PA; b: PB; begin a := b; end. Michael. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal