是否有一种没有控制结构或运算符的编程语言?
喜欢 Smalltalk 或 Lisp?
编辑
其中控制结构类似于:
Java Python
if( condition ) { if cond:
doSomething doSomething
}
Or
Java Python
while( true ) { while True:
print("Hello"); print "Hello"
}
And 运算符
Java, Python
1 + 2 // + operator
2 * 5 // * op
在 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
Like Smalltalk or 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:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(18)
你以前怎么从未听说过 lisp?
how come you've never heard of lisp before?
您的意思是没有特殊的语法来实现相同的目的?
许多语言都具有控制结构和运算符,它们“实际上”是某种形式的消息传递或可以重新定义的功能调用系统。大多数“纯”对象语言和纯函数语言都符合要求。但他们仍然会有你的“+”和某种形式的代码块——包括 SmallTalk!——所以你的问题有点误导。
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.
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.
纯 lambda 演算?这是整个语言的语法:
您拥有的只是变量、函数应用和函数创建。它的功率相当于图灵机。对于诸如
类的构造和诸如
类的数据类型,有众所周知的编码(通常是“Church 编码”) 。 lambda 演算中的编码可能有很多有趣——我们的学生将在明年春天的本科语言课程中做到这一点。
Pure lambda calculus? Here's the grammar for the entire language:
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
and such datatypes as
Coding in lambda calculus can be a lot of fun—our students will do it in the undergraduate languages course next spring.
Forth 可能符合条件,具体取决于您所说的“无控制结构或运营商”的含义。 Forth 可能看起来有它们,但实际上它们都只是符号,并且“控制结构”和“运算符”可以由程序员定义(或重新定义)。
Forth may qualify, depending on exactly what you mean by "no control structures or operators". 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.
Logo 或更具体地说,海龟图形?我相信我们都记得,PEN UP、PEN DOWN、FORWARD 10 等等。
What about Logo or more specifically, Turtle Graphics? I'm sure we all remember that, PEN UP, PEN DOWN, FORWARD 10, etc.
SMITH 编程语言:
http://esolangs.org/wiki/SMITH
http://catseye.tc/projects/smith/
它没有跳跃,并且是图灵完备的。几年前我还为这个坏男孩制作了一个 Haskell 解释器。
The SMITH programming language:
http://esolangs.org/wiki/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.
那么我将首先提到brain****。
I'll be first to mention brain**** then.
在 Tcl 中,没有控制结构;只有命令,并且它们全部都可以重新定义。每最后一张。也没有运营商。好吧,除了 in 表达式,但这实际上只是导入的外来语法,不是语言本身的一部分。 (我们还可以导入完整的 C 或 Fortran 或其他任何语言。)
In Tcl, there's no control structures; 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.)
FRACTRAN 怎么样?
当然,规则2中有一个隐含的控制结构。
How about FRACTRAN?
Of course there is an implicit control structure in rule 2.
D(在 DTrace 中使用)?
D (used in DTrace)?
APT -(自动编程工具)广泛用于 NC 机床编程。
该语言也没有 IO 功能。
APT - (Automatic Programmed Tool) used extensively for programming NC machine tools.
The language also has no IO capabilities.
XSLT(或有人说 XSL)具有诸如
if
和for
之类的控制结构,但您通常应该避免它们,并通过编写具有正确的特异性级别的规则来处理所有事情。因此,控制结构就在那里,但由翻译引擎所做的默认操作暗示:应用潜在递归规则。For
和if
(以及其他一些)确实存在,但在很多情况下您可以而且应该解决它们。XSLT (or XSL, some say) has control structures like
if
andfor
, but you should generally avoid them and deal with everything by writing rules with the correct level of specificity. So the control structures are there, but are implied by the default thing the translation engine does: apply potentially-recursive rules.For
andif
(and some others) do exist, but in many many situations you can and should work around them.每当怎么样?
程序由“待办事项列表”组成——一系列以随机顺序执行的语句。每个语句都可以包含一个先决条件,如果未满足该先决条件,则会导致该语句被推迟到某个(随机)稍后的时间。
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 调用其所有运算符函数的方式)。
I'm not entirely clear on the concept, but I think PostScript meets the criteria, although it calls all of its functions operators (the way LISP calls all of its operators functions).
Makefile 语法似乎没有任何运算符或控制结构。我想说它是一种编程语言,但它不是图灵完备的(无论如何都没有对 POSIX 标准的扩展)
Makefile syntax doesn't seem to have any operators or control structures. I'd say it's a programming language but it isn't Turing Complete (without extensions to the POSIX standard anyway)
那么...您正在寻找一种超级简单的语言吗? 批量编程怎么样?如果您有任何版本的 Windows,则可以使用批处理编译器。它也比您想象的更有用,因为您可以执行基本的文件功能(复制、重命名、创建目录、删除文件等)
http://www.csulb.edu/~murdock/dosindex.html
示例
如果您正在寻找学习一些非常基本编程的方法,这是一个很好的起点。 (请小心使用“删除”和“格式化”命令。不要尝试这些命令。)
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. 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
Example
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.)