Recent

Author Topic: Comparison operator  (Read 2542 times)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12955
  • 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: 19464
  • Glad to be alive.
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.
Any "programmer" that knows only one programming language is not a programmer

Warfley

  • Hero Member
  • *****
  • Posts: 2071
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