2439905184 / 2439905184/Simple-language
关于变量默认值的设计
- Dominant language
- Java
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Simple语言中不存在Null这种值或者None或者null或者nil这种值。
所有的变量,如果声明时没有赋值,默认都是有值的
借鉴自zig语言
```
include stdlib.buildin //导入编程语言内置常用函数
var a
if ( has_value(a) )
{
print("变量为有值")
}
else
{
print("变量无值")
}
```
int 类型或者其他数字类型的默认值为0
string 类型的默认值为 ""
char 类型的默认值为 ''
array 类型的默认值为 []
标准库中
has_value的实现 nim语言
```nim
//伪代码
proc has_value(T SimpleObject): bool =
if SimpleObject is int:
if (SimpleObjectInt)SimpleObject.__buildin_value__ == 0:
return false
else:
return trye
```
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue describes default values for variables in the Simple language, referencing Zig and Nim. Start by examining the language's type system and variable declaration handling in the codebase. Look for where variables are initialized and how their default values are set. Implement has_value to check if a variable's built-in value equals its type's default (e.g., 0 for int). Test with the provided example to ensure correct behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100