Skip to content

Latest commit

 

History

History
83 lines (63 loc) · 1.75 KB

File metadata and controls

83 lines (63 loc) · 1.75 KB

LSR 002 - Lamina代码风格建议

基本信息

  • LSR 编号 002
  • 标题 Lamina代码风格建议
  • 作者 Ziyang-Bai, Ange1PLSGreet, CGrakeski
  • 状态 草案
  • 类型 信息类
  • 创建日期 8-6-2025
  • Lamina 版本 > v1.x.x

Lamina基本信息

Lamina 有这些保留字:

print true false null include define bigint input

这些保留字不可被用作变量/函数名。

代码块缩进

在Lamina的代码风格建议当中,虽然不对缩进进行强制规范,但是仍然更推荐使用4个西文空格(而非制表符)来进行代码块的缩进。拥有缩进的代码可以使得你的语句结构更加清晰。

示例代码:

include "json";

func parse_front_end_data() {
    return json_decode("{'name':10,'age':20,'a':[1,2,3]}");
}

这些缩进规则的应用到包括if块,else块,for块以及while块。

代码布局

  1. 若函数内有多个参数,可将参数分行写出,对齐括号。

示例代码:

func a(
        arg1, arg2,
        arg3, arg4
      ){
    print(arg1);
} // 推荐
func a(arg1, arg2, arg3, arg4){
    print(arg1);
} // 不推荐
  1. include语句后与下文代码建议空一行。

示例代码:

include "splash";

print("Hi!"); // 推荐
include "splash";
print("Hi!"); // 不推荐
  1. 需特别说明的是,Lamina对大括号相对于语句的位置并无特殊规定,也就是下面两种与其他的写法都是可被接受的:

    func a(){
        // 代码……
    }
    
    func a()
    {
        // 代码……
    }