Skip to content

Commit 1c223c9

Browse files
committed
zz
1 parent 99696b9 commit 1c223c9

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

docs/smalltalk/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ title: 碎碎念
66

77
“碎碎念”是本站发布日常随笔的栏目,内容包括项目进展、小点子、有趣的讨论等。
88

9+
- 2024-04-20: [凹语言支持embed特性](st0041.md)
910
- 2024-04-13: [凹语言支持运算符重载](st0040.md)
1011
- 2024-04-03: [PLOC社区参加OS2ATC大会纪录](st0039.md)
1112
- 2024-03-29: [凹语言支持函数重载](st0038.md)

docs/smalltalk/st0041.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# 凹语言支持embed特性
2+
3+
- 时间:2024-04-20
4+
- 撰稿:凹语言 开发组
5+
- 转载请注明原文链接:[https://wa-lang.org/smalltalk/st0041.html](https://wa-lang.org/smalltalk/st0041.html)
6+
7+
---
8+
9+
在新发布的 [v0.12.0](https://gitee.com/wa-lang/wa/releases/tag/v0.12.0) 版本中实验性地引入了`embde`特性。比如[`apple`](https://gitee.com/wa-lang/wa/tree/master/waroot/src/apple)标准库有以下代码:
10+
11+
```wa
12+
// 版权 @2023 凹语言 作者。保留所有权利。
13+
14+
#wa:embed logo.txt
15+
const WaLogo: string
16+
```
17+
18+
其中`WaLogo`字符串常量通过`#wa:embed logo.txt`标注的同目录下的`logo.txt`文件来初始化。
19+
20+
可以像下面代码这样使用:
21+
22+
```wa
23+
import "apple"
24+
25+
func main {
26+
println(apple.WaLogo)
27+
}
28+
```
29+
30+
执行效果如下:
31+
32+
```
33+
$ wa run hello.wa
34+
+---+ +---+
35+
| o | | o |
36+
| +----+ |
37+
| |
38+
| \/\/ |
39+
| |
40+
+------------+
41+
```
42+
43+
目前这是一个实验性的特性,未来开发组将根据真实开发场景做调整和完善,也欢迎社区同学参与讨论。

0 commit comments

Comments
 (0)