Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Conditional (computer programming)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Tcl==== {{Main|Tcl}} In [[Tcl]] <code>if</code> is not a keyword but a function (in Tcl known as command or <code>proc</code>). For example <syntaxhighlight lang="tcl"> if {$x > 10} { puts "Foo!" } </syntaxhighlight> invokes a function named <code>if</code> passing 2 arguments: The first one being the condition and the second one being the true branch. Both arguments are passed as strings (in Tcl everything within curly brackets is a string). In the above example the condition is not evaluated before calling the function. Instead, the implementation of the <code>if</code> function receives the condition as a string value and is responsible to evaluate this string as an expression in the callers scope.<ref>{{cite web|title=New Control Structures|url=https://wiki.tcl-lang.org/page/New+Control+Structures|publisher=[[Tcler's wiki]]|access-date=August 21, 2020}}</ref> Such a behavior is possible by using <code>uplevel</code> and <code>expr</code> commands: :Uplevel makes it possible to implement new control constructs as Tcl procedures (for example, uplevel could be used to implement the while construct as a Tcl procedure).<ref>{{cite web|title=uplevel manual page|url=https://www.tcl.tk/man/tcl8.6/TclCmd/uplevel.htm|publisher=[[www.tcl.tk]]|access-date=August 21, 2020}}</ref> Because <code>if</code> is actually a function it also returns a value: :The return value from the command is the result of the body script that was executed, or an empty string if none of the expressions was non-zero and there was no bodyN.<ref>{{cite web|title=if manual page|url=http://www.tcl.tk/man/tcl8.6/TclCmd/if.htm|publisher=[[www.tcl.tk]]|access-date=August 21, 2020}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)