Tk_GetUid(3)

🌸 NAME 🌸

okay so bestie, this is Tk_GetUid(3) from the Tk Library Procedures β€” the iconic page about Tk_GetUid and Tk_Uid, aka how to convert from string to unique identifier. πŸ’…βœ¨

✨ SYNOPSIS ✨

#include <tk.h>

Tk_Uid
Tk_GetUid(string)

πŸŽ€ ARGUMENTS πŸŽ€

  • char *string (in) β€” the string for which the corresponding unique identifier is desired. That's the input, bestie, and it's giving main-character energy. 🫢

πŸ’– DESCRIPTION πŸ’–

So Tk_GetUid returns the unique identifier corresponding to string. Unique identifiers are similar to atoms in Lisp, and Tk uses them to speed up comparisons and searches. slay. 🌈

A unique identifier (type Tk_Uid) is a string pointer and may be used anywhere that a variable of type char * could be used. But here's the guaranteed icon behavior: there is guaranteed to be exactly one unique identifier for any given string value. πŸ‘‘

If Tk_GetUid is called twice, once with string a and once with string b, and if a and b have the same string value (strcmp(a, b) == 0), then Tk_GetUid will return exactly the same Tk_Uid value for each call (Tk_GetUid(a) == Tk_GetUid(b)). Not me being obsessed with the exact same Tk_Uid value β€” it's literally the point. πŸ’€βœ¨

That means variables of type Tk_Uid may be compared directly (x == y) without having to call strcmp. Highkey convenient. In addition, the return value from Tk_GetUid will have the same string value as its argument (strcmp(Tk_GetUid(a), a) == 0). fr fr. πŸ¦‹

πŸ’œ KEYWORDS πŸ’œ

  • atom
  • unique identifier

xoxo, this is from Tk πŸ’– β€” source/version energy, page label Tk_GetUid(3), and no date in this footer so we're not inventing one, periodt 🫢✨

πŸ“¦ where this page comes from