Recent

Author Topic: Comparison operator  (Read 2296 times)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12598
  • 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: 18707
  • To Europe: simply sell USA bonds: dollar collapses
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.
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

Warfley

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