有没有控制结构或运算符的编程语言?

Osc*_*Ryz 9 language-agnostic programming-languages operators control-structure

喜欢Smalltalk还是Lisp?

编辑

控制结构如下:

     Java                 Python               
 if( condition ) {     if cond:           
     doSomething           doSomething     
 }                                         
Run Code Online (Sandbox Code Playgroud)

要么

     Java                Python                  
 while( true )  {        while True:            
     print("Hello");        print "Hello"      
 }                                            
Run Code Online (Sandbox Code Playgroud)

和运营商

 Java, Python
 1 + 2  // + operator 
 2 * 5  // * op
Run Code Online (Sandbox Code Playgroud)

在Smalltalk(如果我是正确的)那将是:

condition ifTrue:[
   doSomething
]

True whileTrue:[
   "Hello" print 
]
1 + 2 // + is a method of 1 and the parameter is 2 like 1.add(2) 
2 * 5 // same thing
Run Code Online (Sandbox Code Playgroud)

use*_*291 7

为什么你以前从未听说过口齿不清?

  • 取决于OP想要什么.`(如果exp1 exp2 exp3)`和`(+ exp1 exp2)`肯定是我称之为控制结构和运算符(因为在很多情况下,控制结构和运算符只是函数的不同名称).具有教堂数字的Lambda演算可能与OP(可能)想要的一样接近. (3认同)

Ply*_*ynx 7

你是说没有特殊的语法来达到同样的目的?

许多语言都有控制结构和运算符,它们"真正"是某种形式的消息传递或功能调用系统,可以重新定义.大多数"纯粹的"对象语言和纯函数语言符合要求.但他们仍然会有你的"+"和某种形式的代码块 - 包括SmallTalk! - 所以你的问题有点误导.


Eim*_*tas 0

D(在 DTrace 中使用)?