Get the latest tech news

Adding keyword parameters to Tcl procs


hings that really annoy me with some programming languages: the lack of keyword (optional, always named and order agnostic) parameters and when the language has a builtin feature not made available to the user. Tcl hits the nail here, because a lot of its standard commands have UNIX-like options but it doesn't make any of this available in either proc or apply.

Tcl hits the nail here, because a lot of its standard commands have UNIX-like options but it doesn't make any of this available in either proc or apply. As you can see in the third example, I even implemented that Tcl behaviour where mandatory positional parameter count is used to disambiguate them from options (which is how you can do puts $string without having to safeguard it with a-- marker). In fact, I don't think a hacker can wield Tcl for some time without making something like it (cf the wiki).

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Tcl procs

Tcl procs

Photo of keyword parameters

keyword parameters