ZT_CMP_INT(3)

πŸ’– ZT_CMP_INT πŸ’–

okay bestie, so this one's from the LOCAL manual (section 3, the library-calls girlies) and it's literally about telling libzt that two integers have a relationship. yes we're doing math gossip now. πŸ’…

✨ NAME ✨

ZT_CMP_INT, zt_cmp_int β€” construct a claim of a relation between two integers


🌸 SYNOPSIS 🌸

#include <zt.h>

#define ZT_CMP_INT(left, rel, right) \
  zt_cmp_int( \
    ZT_CURRENT_LOCATION(), \
    zt_pack_integer((left), (#left)), \
    zt_pack_string((#rel), (#rel)), \
    zt_pack_integer((right), (#right)))

zt_claim
zt_cmp_int(zt_location location, zt_value left, zt_value rel,
    zt_value right);

πŸ¦‹ DESCRIPTION πŸ¦‹

so zt_cmp_int() constructs a claim of a relation between two integers. that's it, that's the whole vibe. πŸ‘‘

but like, do NOT call it directly, okay? you're supposed to go through the macro ZT_CMP_INT(), because the macro is the one doing the cute little extra work: it passes the source code location and it packs the arguments for you. she's the main character, the function is just backstage. ✨

the relation has to be one of these, and nothing else:

  • ==
  • !=
  • <
  • <=
  • >
  • >=

like, six options, pick one, no freestyling. πŸŽ€


🧚 IMPLEMENTATION NOTES 🧚

ZT_CMP_INT() evaluates left and right exactly once. not twice. once. so no double-side-effect jump scares, we love a hygienic macro fr fr. 🫢


⭐ RETURN VALUES ⭐

both the macro and the function hand you back a claim structure with the right attributes set. the way that... it just returns the claim. πŸ™ˆ

and then you usually pass that claim straight into zt_check() or into zt_assert(). that's the whole pipeline bestie, claim β†’ check. πŸ“


🌈 SEE ALSO 🌈

the whole comparison crew is here, they're all iconic, go say hi. πŸ’œ


πŸ’€ HISTORY πŸ’€

the ZT_CMP_INT() macro and the zt_cmp_int() function first appeared in libzt 0.1. so like, day-one legends. πŸ‘‘

and since libzt 0.3, zt_cmp_int() internally promotes the left and right arguments from ZT_INTEGER to ZT_INTMAX. glow-up era, honestly. ✨


πŸŽ€ AUTHORS πŸŽ€

Zygmunt Krynicki <me@zygoon.pl>


and that's the page bestie!! written for libzt 0.3.1, dated January 12, 2020, and yeah it's the ZT_CMP_INT(3) one. go compare some integers, you absolute icon. πŸ’…πŸ’–βœ¨