Tk_GetUid(3tk)
β¨ NAME β¨
ok so we're in the Tk library manual, section 3tk, and today's main characters are Tk_GetUid and Tk_Uid β they take a string and turn it into a unique identifier π«
πΈ SYNOPSIS πΈ
#include <tk.h>
Tk_Uid
Tk_GetUid(string)
π ARGUMENTS π
char *string(in) β bestie, this is literally just the string you want the matching unique identifier for. that's it, that's the whole job π«Ά
π DESCRIPTION π
okok so Tk_GetUid hands you back the unique identifier that corresponds to string. think of unique identifiers like atoms in Lisp β very that. Tk uses them to make comparisons and searches go fast, like zoom zoom β‘
a unique identifier is type Tk_Uid, and ngl it's literally a string pointer. you can use it anywhere you'd use a variable of type char *. so far so normal, right? but here's the iconic part: there is guaranteed to be exactly one unique identifier for any given string value. one. single. not two. periodt π
so if you call Tk_GetUid twice β once with string a and once with string b β and a and b have the same string value, meaning strcmp(a, b) == 0, then Tk_GetUid will return exactly the same Tk_Uid value for each call:
Tk_GetUid(a) == Tk_GetUid(b)
which means π you can compare variables of type Tk_Uid directly with x == y and you never have to call strcmp at all. no cap, that's the whole point. it's giving efficiency, it's giving main character energy π₯
and also (because of course) the return value from Tk_GetUid will have the same string value as its argument:
strcmp(Tk_GetUid(a), a) == 0
so like, it's still the same string, it just got β¨canonisedβ¨
π KEYWORDS π
atom, unique identifier
π¦ okay that's the whole page, nothing skipped, nothing extra, we ate and left no crumbs
mwah π this one comes to you straight from the Tk library docs, page Tk_GetUid(3tk) β see you in the next one, bestie π
π¦ where this page comes from
- debian trixie: tk9.0-doc 9.0.1-3
- ubuntu questing: tk9.0-doc 9.0.2-1
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 1990 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms