Skip to content

Commit

Permalink
Update content/post/2024-04-06-zig-cpp.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 authored Apr 8, 2024
1 parent ff82327 commit f2f4c00
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion content/post/2024-04-06-zig-cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ date: 2024-04-06T19:57:49+08:00

尽管Zig社区宣称Zig语言是一个更好的C (better C),但是我个人在学习Zig语言时经常会“触类旁通”C++。在这里列举一些例子来说明我的一些体会,可能会有一些不正确的地方,欢迎批评指正。

# Zig和C++,“元能力” vs “元类型”
# “元能力” vs “元类型”

在我看来,C++的增强方式是希望赋予语言一种“元能力”,能够让人重新发明新的类型,使得使用C++的程序员使用自定义的类型,进行一种类似于“领域内语言”(DSL)编程。一个通常的说法就是C++中任何类型定义都像是在模仿基本类型`int`。比如我们有一种类型T,那么我们则需要定义T在以下几种使用场景的行为:

Expand Down

0 comments on commit f2f4c00

Please sign in to comment.