TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Adding keyword parameters to Tcl procs

58 pointsby BoingBoomTschak27 days ago

5 comments

jrapdx327 days ago
As a search of the Tcl wiki shows, attempts to add named-argument capability to the Tcl <i>proc</i> command have been around for several years.<p>My own <i>nxproc</i> extension is more comprehensive. (See wiki [0].)<p>The extension enables named arguments, regular positional arguments, and &#x27;rest&#x27; arguments, <i>nxargs</i> and <i>nxunknown</i>. <i>Nxproc</i> also provides (optional) type-checking of procedure arguments. (Types: string, number, bool and enumerated. Enums are lists of values restricting what the arg can contain.)<p><i>Nxproc</i> supports TclOO with <i>nxcontructor</i> and <i>nxmethod</i> commands -- same feature set as &quot;plain&quot; <i>nxproc</i>. Also provides case-insensitive &#x27;-ci&#x27; variants, and runtime display of named-argument default&#x2F;actual values and types.<p><i>Nxproc</i> is a Tcl C extension. Bundle has Windows, Linux binaries. Compiles easily on other platforms.<p>[0] <a href="https:&#x2F;&#x2F;wiki.tcl-lang.org&#x2F;page&#x2F;nxproc" rel="nofollow">https:&#x2F;&#x2F;wiki.tcl-lang.org&#x2F;page&#x2F;nxproc</a>
评论 #43757627 未加载
blacksqr27 days ago
The OpenACS web server toolkit has a lot of useful Tcl utilities, including the ad_proc procedure, which wraps proc and allows adding of switches, inline docs, and more.<p>I think it would be very useful to turn ad_proc into a built-in command and incorporate it into TCL.<p><a href="https:&#x2F;&#x2F;nstcl.sourceforge.net&#x2F;docs&#x2F;nstcl-core&#x2F;ad_proc.html" rel="nofollow">https:&#x2F;&#x2F;nstcl.sourceforge.net&#x2F;docs&#x2F;nstcl-core&#x2F;ad_proc.html</a>
评论 #43755493 未加载
评论 #43756008 未加载
tracnar27 days ago
I implemented something very similar a while ago, it&#x27;s indeed too bad it&#x27;s not built-in. I don&#x27;t think you need such a &quot;quasiquote&quot; function, [list {*}$args] can escape a single command, and then it&#x27;s a matter of joining multiple commands using a newline. IIRC that&#x27;s how I did it.<p>I also had further fun with wrapping &quot;proc&quot; by implementing a &quot;pyproc&quot; which called out to Python while looking like a normal Tcl proc.
评论 #43754948 未加载
andrewshadura27 days ago
Tcl is the shell done right. Simple, logical, consistent.
评论 #43754921 未加载
评论 #43756732 未加载
评论 #43756063 未加载
RicoElectrico27 days ago
Synopsys tools (either CosmosScope or Custom Wave view) do it by the way of names following values. Like:<p><pre><code> measureFoo $signal threshold 0.9 edge last</code></pre>