platform(3tcl)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ 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 format OS-CPU. the OS part can contain details like kernel version, libc version, etc., and that information may contain dashes as well. the CPU part 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 to platform::identify, it leaves out details like kernel version, libc version, etc. the returned identifier has the general format OS-CPU. it's the chill, low-drama version. 🧚
  • platform::patterns identifier β€” this one takes an identifier as returned by platform::identify and 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