struct::map(n)

πŸ“¦
version 2.0 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸ’– struct::map β€” bestie's guide to key/value maps πŸ’–

okay so this is struct::map(n), from tcllib. Sit down, grab a strawberry, we're doing data structures πŸ’…


✨ NAME ✨

struct::map β€” manage key/value maps. yes that's it, that's the whole vibe. a lil map. a lil dict-with-attitude. πŸŽ€


🌸 SYNOPSIS 🌸

package require struct::map ?1?

::struct::map mapName

mapName method ?arg arg ...?

mapName get

mapName names

mapName set name ?value?

mapName unset ?pattern...?

like. look at it. so clean. so organized. the way she just has a synopsis 😭


πŸ¦‹ DESCRIPTION πŸ¦‹

Okay bestie, here's the tea: this package gives you a snit class whose instances manage a key/value map. In other words β€” and I cannot stress this enough β€” it's an object wrapper around Tcl arrays. that's the whole thing. iconic behavior, no notes πŸ‘‘


πŸ’… API πŸ’…

The main command is the one that makes maps for you:

  • ::struct::map mapName β€” Creates a new, empty map, and it comes with an associated global Tcl command whose name is mapName. You use that command to invoke all the various operations on the map. It has this general form:
mapName method ?arg arg ...?

where method and its arguments determine the exact behavior of the command. 🫢

and listen β€” if mapName is specified as %AUTO%, the package itself generates a unique name for you. no brainstorming required. The result of the command is the fully-qualified name of the instance command. slay ✨

🌈 The commands you can actually run on a map object

  • mapName get β€” Returns the entire map as a Tcl dictionary. the whole thing, all at once, no crumbs πŸ’–
  • mapName names β€” Returns the list of all keys known to the map, in arbitrary order. don't come for her about the ordering, she never promised you that πŸŽ€
  • mapName set name ?value? β€” Sets key name to the specified value, if the value is specified. Returns the value for the key. Throws an error if the key is not known. she's dramatic like that 😭
  • mapName unset ?pattern...? β€” Removes all keys matching at least one of the glob patterns from the map. If no pattern is specified, all keys are removed. In other words, the default pattern is *. The result of the command is the empty string. ghosted. gone. nothing left πŸ’€

πŸ”₯ BUGS, IDEAS, FEEDBACK πŸ”₯

ngl, this document β€” and the package it describes β€” will undoubtedly contain bugs and other problems. it's giving "we're all just doing our best". Please report such in the category struct :: list of the Tcllib Trackers:

http://core.tcl.tk/tcllib/reportlist

Please also report any ideas for enhancements you may have for either the package and/or the documentation. we love a glow-up suggestion πŸ’œ

When proposing code changes, please provide unified diffs, i.e the output of diff -u.

Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. iykyk 🧚


and that's the page!! brought to you by tcllib, version 1, dated... well, the page footer says struct::map(n) β€” so consider this your official sign-off from your fave manual page bestie. go forth and map your keys to your values, no cap πŸŒŸπŸ’–

πŸ“¦ where this page comes from