TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Adding keyword parameters to Tcl procs

58 点作者 BoingBoomTschak19 天前

5 条评论

jrapdx319 天前
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 未加载
blacksqr19 天前
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 未加载
tracnar19 天前
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 未加载
andrewshadura19 天前
Tcl is the shell done right. Simple, logical, consistent.
评论 #43754921 未加载
评论 #43756732 未加载
评论 #43756063 未加载
RicoElectrico19 天前
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>