你以为这世上只有语言C++、Java、Python等等这些语言吗
晦涩编程语言(Esoteric Programming Language,Esolang)大赏
(能让人笑出来的语言不失为一个好语言)
1. Shakespeare(SPL)
对,就是莎士比亚的剧本
功能
| 概念 | 语句 |
|---|---|
| 变量 | 角色名 |
| 分段 | Act I: 、Scene I: |
| 引入变量 | [Enter ...] |
| 引出变量 | [Exit ...] |
| 赋值 | You are ...、You are as ... as ... |
| 加法 | sum of A and B |
| 减法 | difference between A and B |
| 乘法 | product of A and B |
| 除法 | quotient between A and B |
| 平方 | square of A |
| 立方 | cube of A |
| 输入数字 | Listen to your heart. |
| 输入字符 | Open your mind. |
| 输出数字 | Speak your mind. |
| 输出字符 | Open your heart. |
| 大于 | Am I/Is ... better than ...? |
| 小于 | Am I/Is ... worse than ...? |
| 等于 | Am I/Is ... equal than ...? |
| 条件跳转 | If so, let us proceed to scene III. |
| 结束 | [Exeunt] |
| 注释 | 其他样式的语句 |
结构
标题
对代码没什么影响,相当于给你的程序命名,结尾有一个.,比如say hello world.,这个不必要
人物介绍
把你代码中用到的变量介绍一遍,变量名随意但首字母必须大写,如Romeo、Shabby等
具体格式就是Name, something.,something 写什么都行
幕
因为是剧本所以必须得有幕,这个可以用来标注代码每一段的用途,格式是 Act I: something,注意数字用罗马数字
景
剧本嘛,景也是要有的,格式是 Scene I: something
对话
SPL的语句都是以对话形式执行的,对话前必须引入角色,每句话要有一个对应的角色作为说话者,此时语句中的 You 指代这个场景中的另一个人(在场景中只有两个人的时候),I 就是说话者
比如这个:
[Enter Romeo]
[Enter Shabby]
Shabby:
You are nothing. Speak your mind.就是输出 Romeo 存储的数字
示例(A + B problem)
The Addition of Two Integers.
Romeo, a young man.
Shabby, a value.
Awsl, dudsifidasoicodsibjw.
Act I: wowowowowow.
Scene I: Input.
[Enter Romeo and Awsl]
Awsl:
You are nothing! Listen to your mind!
[Exit Romeo]
[Enter Shabby]
Awsl:
You are nothing! Listen to your heart!
Scene II: Plus.
[Exit Shabby]
[Enter Romeo]
Awsl:
You are the sum of yourself and Shabby!
Scene III: Output.
Awsl:
Speak thy mind!
[Exeunt]什么,你说这还是太好懂了?