Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 5, 2025

The handbook incorrectly documented iterator and container APIs with method call syntax when they are properties. Based on official CovScript test files, .begin, .end, .data, .empty, .front, and .back are properties, not methods. Additionally, .next() modifies iterators in-place rather than returning new instances.

Changes

Iterator API corrections (syntax/10-iterators.md)

  • .begin().begin, .end().end, .data().data (45+ instances)
  • it = it.next()it.next() (40+ instances)
  • Removed confusing custom iterator example

Container property corrections (6 files)

  • .empty().empty (6 instances)
  • .front().front, .back().back (3 instances)

Example

Before:

var it = list.begin()
while it != list.end()
    system.out.println(it.data())
    it = it.next()  # Wrong: next() modifies in-place
end

After:

var it = list.begin
while it != list.end
    system.out.println(it.data)
    it.next()  # Correct: modifies iterator directly
end

All changes verified against covscript/covscript/tests and covscript/covscript-example.

Original prompt

请根据下面的资料(参考仓库中的 .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/


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits December 5, 2025 03:26
Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>
…entheses

Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>
Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>
Copilot AI changed the title [WIP] Review and enhance current changes in Covscript projects Fix iterator and container property syntax throughout handbook Dec 5, 2025
Copilot AI requested a review from mikecovlee December 5, 2025 03:35
@mikecovlee
Copy link
Member

@copilot 从你个人的建议来看,是否应当统一方法调用?现在这样有的时候需要(),有的时候又不需要,似乎有点confusing

Copy link
Contributor Author

Copilot AI commented Dec 5, 2025

@copilot 从你个人的建议来看,是否应当统一方法调用?现在这样有的时候需要(),有的时候又不需要,似乎有点confusing

这是个很好的设计问题。从语言设计角度看,当前的区分方式(属性用.property,方法用.method())是许多语言(如Python、C#)的常见模式,有以下优势:

  1. 语义清晰:属性表示状态(如.size.empty),方法表示动作(如.push_back().next()
  2. 性能提示:属性通常是O(1)访问,方法可能有计算开销
  3. API设计灵活性:可以用属性做延迟计算,用方法做带副作用的操作

不过您说得对,这确实会让初学者感到困惑。如果要统一调用方式,需要在CovScript解释器层面做改动,不是手册能解决的。手册现在记录的是实际API行为。

如果考虑改进,可能的方向:

  • 允许属性也可以加()调用(向后兼容)
  • 或在文档中更明确地说明这个设计原则

您觉得哪个方向更合适?

@mikecovlee mikecovlee marked this pull request as ready for review December 5, 2025 05:36
@mikecovlee mikecovlee merged commit 94fcb63 into copilot/add-covscript-syntax-guide Dec 5, 2025
1 check passed
@mikecovlee mikecovlee deleted the copilot/review-and-improve-current-changes branch December 5, 2025 05:37
mikecovlee added a commit that referenced this pull request Dec 5, 2025
* Initial plan

* Add syntax documentation files (README, basic, datatypes, operators, control flow, functions, OOP, modules)

Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>

* Complete syntax documentation with all chapters and update root README

Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>

* Fix syntax errors: correct for loop syntax, .size property, pointer operations, and type annotations

Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>

* Integrate intro and syntax chapters: complete hello.md with examples and cross-references

Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>

* Fix pointer/reference consistency: use . for objects, -> only for pointers (gcnew/&)

Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>

* Fix reviewer comments: ECS direct execution, statement ending, string.append clarification

Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>

* Fix all .size() to .size - properties don't need parentheses (20 fixes)

Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>

* Fix iterator and container property syntax throughout handbook (#2)

* 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>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mikecovlee <16332179+mikecovlee@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants