打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

用户:LynChern/Sandbox:修订间差异

来自 LNN的:not(博客)?
LynChern留言 | 贡献
DGCK81LNN留言 | 贡献
无编辑摘要
第1行: 第1行:
===Why is this page primarily written in  a non-English language?===
===Why is this page primarily written in  a non-English language?===


A good reason for this is that the command keywords of this programming language consist mostly of Chinese characters, and its users are generally capable of recognizing Chinese.There are plans to release an English version of the language and its compiler in the future.
A good reason for this is that the command keywords of this programming language consist mostly of Chinese characters, and its users are generally capable of recognizing Chinese. There are plans to release an English version of the language and its compiler in the future.


===Talks===
===Talks===


This article is undergoing frequent debugging within a sandbox. If you wish to contact the author, please leave a message on [[User_talk:LynChern|my talk]] page to discuss this.
This article is a work in progress. If you wish to contact the author, please leave a message on [[User_talk:LynChern|my talk]] page to discuss this.


===Authorization===
===Authorization===


The following users have been authorized to assist in modifying the contents of the sandbox. Please do not wrongfully ban them.
The following users have been authorized to assist in modifying the contents of the sandbox. Please do not ban them by mistake.


This authorization is not permanent; it will expire when this section is removed or when the users are removed from the list.
This authorization is not permanent; it will expire when this section is removed or when the users are removed from the list.


- [[User:DGCK81LNN]]
* [[User:DGCK81LNN]]


===The name of this language===
===The name of this language===


Please note that the name of this language is '''not''' "xxx语". In fact, this language does not have any official name now. If you are using a translator, referring to this language as "XXX" is incorrect.
Please note that the name of this language is '''not''' "xxx语". In fact, this language does not have any official name yet. If you are using a translator, referring to this language as "XXX" is incorrect.


===The stylistic characteristics of this language===
===The stylistic characteristics of this language===


Currently, the stylistic features of the language have not yet been finalized. Please note that "我是代码" is '''not''' actual code in this language; it is merely a placeholder indicating where the language's code will be implemented in the future.
Currently, the stylistic features of the language have not yet been finalized. Please note that "我是代码" is '''not''' actual code in this language; it is merely a placeholder indicating that the syntax is yet to be decided.


===本文尚未完工!===
===本文尚未完工!===

2026年4月20日 (一) 18:59的版本

Why is this page primarily written in a non-English language?

A good reason for this is that the command keywords of this programming language consist mostly of Chinese characters, and its users are generally capable of recognizing Chinese. There are plans to release an English version of the language and its compiler in the future.

Talks

This article is a work in progress. If you wish to contact the author, please leave a message on my talk page to discuss this.

Authorization

The following users have been authorized to assist in modifying the contents of the sandbox. Please do not ban them by mistake.

This authorization is not permanent; it will expire when this section is removed or when the users are removed from the list.

The name of this language

Please note that the name of this language is not "xxx语". In fact, this language does not have any official name yet. If you are using a translator, referring to this language as "XXX" is incorrect.

The stylistic characteristics of this language

Currently, the stylistic features of the language have not yet been finalized. Please note that "我是代码" is not actual code in this language; it is merely a placeholder indicating that the syntax is yet to be decided.

本文尚未完工!

该语言当前处于构想阶段,有较多内容还未完全确立。目前主要以概念形式表达,具体的语法正在设计。

目前本文的书写方法有很多留空,这并不代表未来不会有具体的内容。

本文格式

> 代表注释。在本文最终完工时,所有注释都会被移除。

当注释被使用时,代表本段内容很可能在未来作出更改。

简介

xxx语是一门高级编程语言,声明式语言

> 是的,我们连名字都未想好

特点

代码预览

我是代码

图灵完备证明

该代码可以模拟一个[[]],证明了本语言是图灵完备的。

> 这个章节不可能叫图灵完备证明,届时会更名为图灵机的名字。

我是代码

运行xxx语程序

要运行使用xxx语编写的程序,预期的用途是将源代码作为编译器的输入,从而被编译成可执行的目标语言的代码。

Python编译器

将Python视为机器码的编译器。

[[解释器资源地址|Python实现]]

> 等待开发计划

WhatLang编译器

将WhatLang视为机器码的编译器。

[[解释器资源地址|Python实现]]

> 等待开发计划

自编译器

使用xxx语表达编译器程序不是该语言的强项,实现有一定难度。在一段时间内,语言的设计者认为没有必要开发。

基本要素

让我们看一段xxx语代码

xxx语的代码可使用的字符包含了:所有ASCII可见字符(包含空格)及《通用汉字规范表》中的所有汉字。

未指定字符所使用的编码。理论上允许使用上述字符集以外的字符作为代码的一部分,但可能发生未知的错误。

xxx语的代码完全由以下这些要素构成:

  • 关键字
  • 标识符
  • 字面量

xxx语的关键字包含了在其他语言中通常被称为运算符与结构符的词元。

xxx语的代码是大小写敏感的,这意味着""和""不是同一个词元。

> 目前还未设计如何区分关键字与标识符。可能会像文言一样标识符有统一的特殊的格式,也可能像Python一样非关键字就是标识符。

xxx语标识符

标识符是用来标识变量、函数、类、模块,或任何其他用户自定义项目的名称。

xxx语的标识符的特点在于:

  • 第一点
  • 第二点
  • 第三点
  • ...

> 额,我没设计好

xxx语关键字

下面列出了xxx语中的关键字。关键字承担着赋予代码明确语义的重要能力,是语言中的核心词元。你不能将其作为常量、变量、类或任何标识符的名称。

这些词元的具体作用会在下文逐步揭示。

entry a entry b entry c
entry a entry b entry c

下面列出了xxx语中的保留字。保留字是指在语言的发展中为未来可能会添加的新特性或语法结构而预先留出的词元。它们目前没有实际的语义功能,但为了保证代码在未来版本中的兼容性,你同样不能将保留字作为常量、变量、类或任何标识符的名称。

entry a entry b entry c
entry a entry b entry c

xxx语字面量

> todo

转义符

数据类型

xxx语中有多种数据类型

xxx语是强类型的,它不支持自动类型转换。如果要转换类型,必须通过调用标准库函数等方法显式地将数据进行类型转换。

原子类型

一、整型

xxx语实际上把整数存在你的计算机中的浮点寄存器中,所以实际上被当作浮点数看待。 int bool enum

二、浮点

float

结构类型

三、数组

arrary

四、类

对象是类的实例

> todo

声明与赋值

声明是告诉编译器,应该以何种方式读取或写入数据,并为存储数据做准备,这个动作被称为分配内存地址。赋值,是将具体的内容填充到声明时已经分配好的内存地址。在声明时,还需要设置标识符,这是称呼这份数据的名字;在赋值后,就可以通过直接使用标识符,指代其对应的数据。

声明与赋值缺一不可,一个标识符只有在同时经历了声明和赋值之后,才能在代码中被正常使用。

我是代码

在这行代码中,""指明了数据类型,""是具体的标识符,而""则是赋予该标识符的数据。

在声明时,如果不添加额外的关键字,那么在同一代码段内,你不能在下文再次声明或赋值同一个标识符,这样的数据也被称为常量。这意味着,xxx语默认声明的是常量。代码段的相关概念在后文介绍。

你可以先声明,然后再赋值。例如:

我是代码
我是代码

上述的两种声明的写法都被称为显式声明。

xxx语言支持自动类型推断。这意味着,你可以在不显式指明数据类型的情况下,直接给一个标识符赋值。编译器会根据赋给它的具体内容,自动推断出该标识符的数据类型并完成内存分配。这种写法也被称为隐式声明。

例如:

我是代码

在这行代码中,虽然我们没有写出代表整数类型的"",但因为赋予的具体数据""是一个整数,编译器就会自动将""推断为整数类型。在实际效果上,它与 "" 是等价的。这种写法只是省去了指明数据类型,但不代表没有声明。这仍然是一行同时声明并赋值的代码。

注释

在计算机语言中,注释是计算机语言的一个重要组成部分,用于在源代码中解释代码的作用,可以增强程序的可读性、可维护性。

xxx语注释是一种在xxx语程序中用于提供代码功能说明的文本。

注释不会被编译器包含在最终的可执行文件中,因此不会对程序的运行结果产生任何影响。

在程序中经常注释是良好的编程习惯,它们帮助程序员更容易地理解代码的用途和功能,并且在团队协作中非常有用。

xxx语没有行内注释与多行注释之分,其写法如下:

我是代码

或者

我是代码

其中,""被称为注释的文本。

xxx语与其他编程语言不同,注释是需要关键字才能表达的。这是该语言的特色之一。

代码段

代码段是xxx语的核心概念,也是该语言的特色之一。

代码段的写法如下:

我是代码
    ...

我是代码

引入

函数

普通函数

> 普通函数的创建方法要卸载这儿

调用普通函数

使用标准库中的函数

偏函数

> 本章内容未进行严格的论证,未确定具体的副作用

> 此处应该写如何把普通函数包装成偏函数对象

> 偏函数有一些实验性语法还未进行严格的论证,比如将偏函数作为一等公民的想法还在策划

调用偏函数

返回值函数

> 本章内容未进行严格的论证,未确定具体的副作用

> 此处应该写如何将普通函数或偏函数包装成返回值函数,以及形成返回值函数的各种限制

> 此处会提到表达式中可以使用返回值函数


表达式

分支

变量

> 本章内容未进行严格的论证,未确定具体的副作用

循环

> 本章内容未进行严格的论证,未确定具体的副作用

面向对象

> 本章内容未进行严格的论证,未确定具体的副作用

概念:

  • 对象
  • 结构
  • 方法

继承 改写

错误处理

约定

该语言本身不具备某种数据结构,这是鼓励程序员自己实现。

不过,这里提出了一些约定配合标准库实现了一些其他语言常见的数据结构。

带参数的排序

字典

里面有什么?

> todo

本章介绍编译器在编译时内部会发生什么。

内存布局

编译后的可执行文件在内存中的布局只包含代码区栈区,这是该语言的特色之一。

影子栈

xxx语言刻意向程序员隐藏了生命周期的概念。

这为内存安全的特性保驾护航。

外部资源

分类