Recent

Author Topic: Comparison operator  (Read 1123 times)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11990
  • FPC developer.
Re: Comparison operator
« Reply #15 on: November 18, 2024, 10:35:47 am »
You can shorten that up using the CompareMem.

Will fail if your T record contains automated types.

Thaddy

  • Hero Member
  • *****
  • Posts: 16367
  • Censorship about opinions does not belong here.
Re: Comparison operator
« Reply #16 on: November 18, 2024, 10:45:17 am »
You simply can't use comparemem in the general case anyway, there are simply too many exceptions especially if locals are compared.
There is nothing wrong with being blunt. At a minimum it is also honest.

Warfley

  • Hero Member
  • *****
  • Posts: 1851
Re: Comparison operator
« Reply #17 on: November 18, 2024, 10:48:57 am »
You can shorten that up using the CompareMem.
Only if you have memory comparable types. Not all types are memory comparable. AnsiStrings and Dynamic Arrays for example aren't (and thereby also any composite type like arrays or records that contain those) and those are pretty common default types. And of course because Pascal allows for operator overloading you can easily define your own types with their own equality operators that do special comparisons.
« Last Edit: November 18, 2024, 10:51:21 am by Warfley »

 

TinyPortal © 2005-2018