简体   繁体   English

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

[英]Is there a programming language with no controls structures or operators?

Like Smalltalk or Lisp? 喜欢Smalltalk还是Lisp?

EDIT 编辑

Where control structures are like: 控制结构如下:

     Java                 Python               
 if( condition ) {     if cond:           
     doSomething           doSomething     
 }                                         

Or 要么

     Java                Python                  
 while( true )  {        while True:            
     print("Hello");        print "Hello"      
 }                                            

And operators 和运营商

 Java, Python
 1 + 2  // + operator 
 2 * 5  // * op

In Smalltalk ( if I'm correct ) that would be: 在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

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

You mean without special syntax for achieving the same? 你是说没有特殊的语法来达到同样的目的?

Lots of languages have control structures and operators that are "really" some form of message passing or functional call system that can be redefined. 许多语言都有控制结构和运算符,它们“真正”是某种形式的消息传递或功能调用系统,可以重新定义。 Most "pure" object languages and pure functional languages fit the bill. 大多数“纯粹的”对象语言和纯函数语言符合要求。 But they are all still going to have your "+" and some form of code block--including SmallTalk!--so your question is a little misleading. 但他们仍然会有你的“+”和某种形式的代码块 - 包括SmallTalk! - 所以你的问题有点误导。

  1. Assembly 部件
  2. Befunge Befunge

Pure lambda calculus? 纯lambda演算? Here's the grammar for the entire language: 这是整个语言的语法:

e ::= x | e1 e2 | \x . e

All you have are variables, function application, and function creation. 您所拥有的只是变量,函数应用程序和函数创建。 It's equivalent in power to a Turing machine. 它相当于图灵机的功率。 There are well-known codings (typically "Church encodings") for such constructs as 对于这样的结构,有众所周知的编码(通常是“教会编码”)

  • If-then-else IF-THEN-ELSE
  • while-do 而-DO
  • recursion 递归

and such datatypes as 和这样的数据类型

  • Booleans 布尔
  • integers 整数
  • records 记录
  • lists, trees, and other recursive types 列表,树和其他递归类型

Coding in lambda calculus can be a lot of fun—our students will do it in the undergraduate languages course next spring. lambda演算中的编码可以带来很多乐趣 - 我们的学生将在明年春天的本科语言课程中完成。

Forth may qualify, depending on exactly what you mean by "no control structures or operators". 根据“无控制结构或操作员​​”的具体含义,Forth可能符合条件。 Forth may appear to have them, but really they are all just symbols, and the "control structures" and "operators" can be defined (or redefined) by the programmer. Forth可能看起来有它们,但实际上它们都只是符号,程序员可以定义(或重新定义)“控制结构”和“运算符”。

Prolog * Prolog *

*I cannot be held accountable for any frustration and/or headaches caused by trying to get your head around this technology, nor am I liable for any damages caused by you due to aforementioned conditions including, but not limited to, broken keyboard, punched-in screen and/or head-shaped dents in your desk. *我不能对因试图了解这项技术而引起的任何挫折和/或头痛负责,也不对由于上述条件造成的任何损害承担责任,包括但不限于键盘损坏,打孔 - 在你的桌子上的屏幕和/或头形凹痕。

What about Logo or more specifically, Turtle Graphics ? Logo或更具体地说, Turtle Graphics怎么样? I'm sure we all remember that, PEN UP, PEN DOWN, FORWARD 10, etc. 我相信大家都记得,PEN UP,PEN DOWN,FORWARD 10等等。

我会先提到脑****然后。

The SMITH programming language: SMITH编程语言:

http://esolangs.org/wiki/SMITH http://esolangs.org/wiki/SMITH

http://catseye.tc/projects/smith/ http://catseye.tc/projects/smith/

It has no jumps and is Turing complete. 它没有跳跃,图灵完成。 I've also made a Haskell interpreter for this bad boy a few years back. 几年前我也为这个坏孩子做了一个Haskell翻译。

In Tcl, there's no control structures; 在Tcl中,没有控制结构; there's just commands and they can all be redefined. 只有命令,它们可以重新定义。 Every last one. 最后一个。 There's also no operators. 也没有运营商。 Well, except for in expressions, but that's really just an imported foreign syntax that isn't part of the language itself. 好吧,除了在表达式中,但这实际上只是一个导入的外来语法,它不是语言本身的一部分。 (We can also import full C or Fortran or just about anything else.) (我们也可以导入完整的CFortran或其他任何东西。)

How about FRACTRAN ? FRACTRAN怎么

FRACTRAN is a Turing-complete esoteric programming language invented by the mathematician John Conway. FRACTRAN是由数学家John Conway发明的图灵完备的深奥编程语言。 A FRACTRAN program is an ordered list of positive fractions together with an initial positive integer input n . FRACTRAN程序是正分数的有序列表以及初始正整数输入n The program is run by updating the integer ( n ) as follows: 程序通过更新整数( n )来运行,如下所示:

  1. for the first fraction f in the list for which nf is an integer, replace n by nf 对于nf为整数的列表中的第一个分数f ,将n替换为nf
  2. repeat this rule until no fraction in the list produces an integer when multiplied by n , then halt. 重复此规则,直到列表中没有分数乘以n时产生整数,然后停止。

Of course there is an implicit control structure in rule 2. 当然,规则2中有一个隐含的控制结构。

D(用于DTrace)?

APT - (Automatic Programmed Tool) used extensively for programming NC machine tools. APT - (自动编程工具)广泛用于编程数控机床。 The language also has no IO capabilities. 该语言也没有IO功能。

XSLT (or XSL, some say) has control structures like if and for , but you should generally avoid them and deal with everything by writing rules with the correct level of specificity. XSLT(或XSL,有人说)具有控制结构,如iffor ,但是你通常应该避免它们并通过编写具有正确特异性级别的规则来处理所有事情。 So the control structures are there, but are implied by the default thing the translation engine does: apply potentially-recursive rules. 所以控制结构就在那里,但是由翻译引擎做的默认事项暗示:应用潜在的递归规则。

For and if (and some others) do exist, but in many many situations you can and should work around them. Forif (以及其他一些)确实存在,但在许多情况下,您可以而且应该解决它们。

How about Whenever ? 如何

Programs consist of "to-do list" - a series of statements which are executed in random order. 程序由“待办事项列表”组成 - 一系列以随机顺序执行的语句。 Each statement can contain a prerequisite, which if not fulfilled causes the statement to be deferred until some (random) later time. 每个语句都可以包含一个先决条件,如果不满足,则会将语句推迟到某个(随机)更晚的时间。

我对这个概念并不完全清楚,但我认为PostScript符合标准,虽然它调用了所有函数运算符(LISP调用其所有运算符函数的方式)。

Makefile syntax doesn't seem to have any operators or control structures. Makefile语法似乎没有任何运算符或控件结构。 I'd say it's a programming language but it isn't Turing Complete (without extensions to the POSIX standard anyway) 我会说它是一种编程语言,但它不是Turing Complete(无论如何都没有扩展到POSIX标准)

So... you're looking for a super-simple language? 那么......你在寻找一种超级简单的语言? How about Batch programming? 批量编程怎么样? If you have any version of Windows, then you have access to a Batch compiler. 如果您有任何版本的Windows,则可以访问批处理编译器。 It's also more useful than you'd think, since you can carry out basic file functions (copy, rename, make directory, delete file, etc.) 它也比你想象的更有用,因为你可以执行基本的文件功能(复制,重命名,制作目录,删除文件等)。

http://www.csulb.edu/~murdock/dosindex.html http://www.csulb.edu/~murdock/dosindex.html

Example

  1. Open notepad and make a .Bat file on your Windows box. 打开记事本,在Windows框中创建一个.Bat文件。
  2. Open the .Bat file with notepad 用记事本打开.Bat文件
  3. In the first line, type "echo off" 在第一行中,键入“echo off”
  4. In the second line, type "echo hello world" 在第二行,输入“echo hello world”
  5. In the third line, type "pause" 在第三行,输入“pause”
  6. Save and run the file. 保存并运行该文件。

If you're looking for a way to learn some very basic programming, this is a good way to start. 如果您正在寻找一种学习一些非常基本的编程的方法,这是一个很好的开始。 (Just be careful with the Delete and Format commands. Don't experiment with those.) (请注意删除和格式化命令。不要试验那些。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM