if语句可以作为函数调用来实现吗? [英] Can if statements be implemented as function calls?
问题描述
在发布的代码中,我发现其中一种风格上的惯例是使用:
if ){
而不是(我的偏好):
if(condition){
也可能是不重要的一个,但我想到,如果'if'语句被实现为一种函数调用,那么第一种样式可能是合理的。然后我可以停止反对它。
有人知道一种编程语言,其中if语句是作为函数调用实现的,其中参数是单个布尔表达式?
编辑:我意识到if()后面的块有问题,我表达我的问题的方式可能太幼稚了,但我对这些答案感到鼓舞
tcl是一种语言,它实现 http:// tmml.sourceforge.net/doc/tcl/if.html 事实上,tcl中的所有语言结构(for循环,while循环等)都是作为命令/函数实现。 One of the stylistic 'conventions' I find slightly irritating in published code, is the use of: instead of (my preference): A slight difference, and probably an unimportant one, but it occurred to me that the first style might be justified if 'if' statements were implemented as a kind of function call. Then I could stop objecting to it. Does anyone know of a programming language where an if statement is implemented as a function call, where the argument is a single boolean expression? EDIT: I realise the blocks following the if() are problematic, and the way I expressed my question was probably too naive, but I'm encouraged by the answers so far. tcl is one language which implements http://tmml.sourceforge.net/doc/tcl/if.html In fact, all language constructs in tcl (for loop , while loop etc.) are implemented as commands/functions. 这篇关于if语句可以作为函数调用来实现吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! if 作为常规在带有两个参数的构建函数/命令中;条件和要执行的代码块
if {$ vbl == 1} {putsvbl is one}
if(condition) {
if (condition) {
if
as a regular in built function/command which takes two parameters ; condition and the code block to execute if {$vbl == 1} { puts "vbl is one" }