platform(3tcl)
β¨ platform β the manual page, but make it cute β¨
okay bestie, this is platform(3tcl) from the Tcl Bundled Packages set, and it's literally the little package that tells you what machine you're on without you having to do detective work. slay. π
π NAME π
platform β system identification support code and utilities. it's giving "who am I, where am I, what CPU am I" but for Tcl. π¦
β¨ SYNOPSIS β¨
package require platform ?1.0.10?
platform::generic
platform::identify
platform::patterns identifier
π DESCRIPTION π
so the platform package hands you a few utility commands that are useful for identifying the architecture of a machine running Tcl. periodt.
now here's the tea: Tcl does give you the tcl_platform array for figuring out the current architecture β specifically the platform and machine elements β but ngl, that's not always sufficient. why? because on Unix machines, tcl_platform just reflects whatever values the uname command spits out, and those are not standardized across platforms and architectures. messy. π
and it gets worse, bestie. on at least one platform (AIX), tcl_platform(machine) contains the CPU serial number. like. why. π
so because of all that, individual applications have to go and manipulate the values in tcl_platform themselves β along with the output of system-specific utilities β which is both inconvenient for developers, and introduces the potential for inconsistencies in identifying architectures and in naming conventions. two Ls at once.
the platform package prevents exactly that fragmentation. it establishes a standard naming convention for architectures running Tcl and makes it way more convenient for developers to identify the current architecture a Tcl program is running on. no cap, it ate. π
πΈ COMMANDS πΈ
platform::identifyβ this one returns an identifier describing the platform the Tcl core is running on. the returned identifier has the general formatOS-CPU. theOSpart can contain details like kernel version, libc version, etc., and that information may contain dashes as well. theCPUpart will not contain dashes, which makes the preceding dash the last dash in the result. iconic little detail, remember it. β¨platform::genericβ this one returns a simplified identifier describing the platform the Tcl core is running on. in contrast toplatform::identify, it leaves out details like kernel version, libc version, etc. the returned identifier has the general formatOS-CPU. it's the chill, low-drama version. π§platform::patterns identifierβ this one takes an identifier as returned byplatform::identifyand returns a list of identifiers describing compatible architectures. so basically: "here's exactly what I am, now give me everyone I can vibe with." π
π EXAMPLE π
the use case is so good β you can ship an application with multiple builds of a shared library, so the same package works on many versions of an operating system. for example:
package require platform
# Assume that app script is .../theapp/bin/theapp.tcl
set binDir [file dirname [file normalize [info script]]]
set libDir [file join $binDir .. lib]
set platLibDir [file join $libDir [platform::identify]]
load [file join $platLibDir support[info sharedlibextension]]
look at that path building. main character energy fr fr. π«Ά
β KEYWORDS β
operating system, cpu architecture, platform, architecture
okay bestie that's the whole page, nothing skipped, every flag and detail intact. don't come for me, come with me. π
signing off with love from platform version 1.0.4, part of the Tcl Bundled Packages, living in section 3tcl of your friendly neighbourhood man pages. bye babes, go identify an architecture π¦π β¨
π¦ where this page comes from
- debian trixie: tcl9.0-doc 9.0.1+dfsg-2
- ubuntu questing: tcl9.0-doc 9.0.2+dfsg-1
- ubuntu resolute: tcl9.0-doc 9.0.3+dfsg-1
- ubuntu stonking: tcl9.0-doc 9.0.4+dfsg-1
- Copyright (c) 2006 ActiveState Software Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms