Uh oh!
There was an error while loading. Please reload this page.
Add complete CovScript syntax guide documentation (Chapter 2) - #1
Conversation
…control flow, functions, OOP, modules) Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>
Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>
mikecovlee
left a comment
There was a problem hiding this comment.
现有的文档,如 ./intro/hello.md、./intro/install.md 和 PR 中的内容显著脱离,请整合在一起
| var z = 30 | ||
| # 链式赋值 | ||
| var p = var q = var r = 0 |
There was a problem hiding this comment.
已修正。CovScript 不支持链式声明,已改为分别声明每个变量。(commit b54c601)
| - 变量名必须以字母或下划线开头 | ||
| - 变量名可以包含字母、数字和下划线 | ||
| - 变量名区分大小写 | ||
| - 不能使用 CovScript 的关键字作为变量名 |
There was a problem hiding this comment.
已修改为使用非关键字的示例(如 function)以避免混淆。(commit 021bbad)
| ### 空值类型 (Null) | ||
| 使用 `null` 表示空值或无效值。 |
There was a problem hiding this comment.
已添加说明:在 CovScript 中,null 本质上是一个空指针。(commit 021bbad)
| var multiline = "First line\nSecond line" | ||
| # 字符串拼接 | ||
| var greeting = "Hello, " + name + "!" |
| var greeting = "Hello, " + name + "!" | ||
| # 字符串长度 | ||
| var len = str.size() |
| ```covscript | ||
| # 结构体或类的指针访问 | ||
| var obj = new MyClass() |
There was a problem hiding this comment.
和其他语言不同,covscript是new申请正常对象,gcnew才是指针
There was a problem hiding this comment.
已添加说明:在 CovScript 中,new 创建普通对象(引用),gcnew 才创建指针。(commit 021bbad)
| ```covscript | ||
| # 基本 for 循环 | ||
| for var i = 0; i < 5; ++i |
There was a problem hiding this comment.
for后面不需要写var。而且在covscript中是for i=0,i<xxx,++i这种写法
There was a problem hiding this comment.
已修正所有 for 循环语法为 for i=0,i<5,++i 格式(不使用 var,使用逗号分隔)。(commit 021bbad)
| ```covscript | ||
| # 可变参数函数 | ||
| function sum(...args) |
There was a problem hiding this comment.
已添加说明:可变参数实际上是一个数组,包含所有传入的参数。(commit 021bbad)
| ## 2.5.6 函数参数类型标注 | ||
| CovScript 支持为函数参数添加类型标注(主要用于文档和可读性)。 |
There was a problem hiding this comment.
这里你再仔细看看文档。类型标注是ECS中的功能,作用是强制类型检查,会有一定的开销
There was a problem hiding this comment.
已修正:类型标注是 ECS 中的功能,用于强制类型检查,会有运行时开销。同时区分了 ECS 的类型标注语法和 CSC 中的注释文档方式。(commit 021bbad)
…perations, and type annotations Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>
…and cross-references Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>
已完成整合:
(commit b54c601)
已完成全面检查和修正,主要包括:
|
…nters (gcnew/&) Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>
There was a problem hiding this comment.
还是有很多不准确的地方,而且注释有点乱。请从头整理一下,我这里也给出详细的可以用于参考的例子(参考 .csc/.csp/.ecs):
https://github.com/covscript/covscript/tree/master/tests
https://github.com/covscript/covscript-example/tree/main/examples
https://github.com/covscript/covscript-gmssl
https://github.com/covscript/ecs
https://github.com/covscript/cspkg
https://github.com/covscript/covscript-network
https://github.com/covscript/covscript-imgui
https://github.com/covscript/covanalysis
https://github.com/covscript/picasso-ui
https://github.com/covscript/csdbc
文档:
https://manual.covscript.org.cn/
博客:
https://unicov.cn/2025/10/10/covscript-asyncio/
Uh oh!
There was an error while loading. Please reload this page.
| constant y = 20 | ||
| var z = 30 | ||
| # 注意:CovScript 不支持链式声明 |
| ## 2.1.5 语句结束规则 | ||
| CovScript 中,每个语句通常独占一行,不需要使用分号结束。 |
| var multiline = "First line\nSecond line" | ||
| # 字符串拼接 | ||
| var greeting = "Hello, " + name + "!" |
mikecovlee
commented
Dec 5, 2025
@copilot 我刚才更新了最新的review,请根据review内容进行修改,谢谢! |
….append clarification Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>
mikecovlee
commented
Dec 5, 2025
@copilot 让我们从头开始如何?现在有点乱了,请squash前面的更改,并标记所有的conversation为resolved |
我理解您希望重新开始并整理提交历史。不过,我无法直接在 GitHub 上执行 squash commits 或标记 conversations 为 resolved 的操作,这些需要通过 GitHub 界面或特定的 git 命令来完成。 我可以提供两种方案: 方案1: 我可以基于您提供的参考资料(tests、examples、文档)重新审查和改进现有文档内容,然后创建新的提交。 方案2: 您可以先在 GitHub 上 squash 现有的提交并标记对话为 resolved,然后我继续进行文档改进工作。 请告诉我您更倾向哪种方案,或者如果您有其他建议,我会按照您的指示进行。 |
mikecovlee
commented
Dec 5, 2025
我理解您希望基于提供的参考资料对文档进行全面审查和改进。 不过需要说明的是,我无法创建新的 PR,只能在当前分支上继续改进文档内容。 我的建议方案:
我现在开始对文档进行系统审查和改进吗?还是您希望我先等待您在 GitHub 上操作(比如 squash 提交)后再继续? |
mikecovlee
commented
Dec 5, 2025
@copilot 方案1嘛 |
好的,我将开始方案1:基于您提供的参考资料系统地审查和改进文档。 我的工作计划:
我会分阶段提交改进,便于您审查每一步的变更。现在开始工作。 |
Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>
* Initial plan * Fix iterator syntax: .begin, .end, .data are properties, not methods Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com> * Fix property syntax: .empty, .front, .back are properties without parentheses Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com> * Fix remaining iterator property usage in best practices section Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>
Systematic Documentation Review and Improvement
Phase 1: Critical Syntax Fixes
.size()→.size(20 instances fixed across 6 files).vs->)Phase 2: Code Example Accuracy (Next)
Phase 3: Documentation Structure
Phase 4: Style Consistency
Original prompt
目标
在
covscript/handbook-zh仓库中添加完整的 CovScript 语法指南文档,包括基础语法、数据类型、控制流、函数、面向对象编程等核心内容。需要创建的文件
1. 创建
syntax/目录并添加以下文件:syntax/README.md- 语法章节目录内容应包含:
syntax/01-basic.md- 基础语法包含以下内容:
#)var关键字)constant关键字)syntax/02-datatypes.md- 数据类型包含以下内容:
type()和typeid)syntax/03-operators.md- 运算符包含以下内容:
syntax/04-control-flow.md- 控制流包含以下内容:
syntax/05-functions.md- 函数包含以下内容:
...args)syntax/06-oop.md- 面向对象编程包含以下内容:
syntax/07-modules.md- 模块与包包含以下内容:
syntax/08-memory.md- 内存管理包含以下内容:
syntax/09-exceptions.md- 异常处理包含以下内容:
syntax/10-iterators.md- 迭代器包含以下内容:
syntax/11-stdlib.md- 标准库包含以下内容:
syntax/12-advanced.md- 高级特性包含以下内容:
2. 更新根目录的
README.md在目录部分添加新章节链接:
代码示例来源
所有代码示例应该来自以下实际项目文件:
covscript/covscript仓库的 tests/ 目录covscript/covscript-example仓库的 examples/ 目录covscript/covscript-gmssl仓库的相关文件文档风格要求
gsc 或covscript)参考资料
注意事项
This pull request was created as a result of the following prompt from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.