当前位置:网站首页>spicy(一)基本定义
spicy(一)基本定义
2022-07-30 03:43:00 【一只tobey】
unit
spicy通过unit类型来解析数据单位,unit类型类似于我们所熟知的struct或者是record类型。它里面定义了一系列的具有顺序的字段,每个字段都有name和type,在运行的时候会存放对应的值。unit可以实例化,将值分配给各个字段,并且这些字段值可以被检索。
module Test;
public type Foo = unit {
# 定义一个32位的整数
version: uint32 &default=56; # 可以添加&default属性来添加默认值,否则不会设置默认值
};
# 实例化为f
global f:Foo;
# 你可以赋值,来覆盖默认值56
# f.version=60;
print f; # 注意如果里面的字段没有赋值,即使有默认值也不会读取默认值。显示的是not set
print "version is %s" % f.version; # 注意,访问字段,如果没有赋值,但是有默认值则会读取默认值


unit是解析数据的起点或者说入口。如果要使得unit被当前模块外部(即其他文件想要使用该文件定义的unit)需声明为public,仅仅内部访问则可不写。
默认,spicy以network byte的顺序。可
边栏推荐
- Organizations Going Online: A New Trend in Organizational Digital Transformation
- 小程序毕设作品之微信积分商城小程序毕业设计成品(5)任务书
- Overview of Federated Learning (1) - Background, Definition and Value of Federated Learning
- QT based on the third day (3) widget, dialog and mainwindow
- Redis (ten) - Redission principle and practice
- 论坛管理系统
- WPF引入 ttf 图标文件使用记录
- C# 一周入门之《C#-类和对象》Day Six
- Nacos namespace
- OA项目之待开会议&历史会议&所有会议
猜你喜欢
随机推荐
Nacos集群分区
vscode 调试和远程
Ansible introduction (detailed) features + advantages + design concept + application field + system architecture + working principle + task execution process
Answer these 3 interview questions correctly, and the salary will go up by 20K
Solve The problem of Google browser cross-domain has had been blocked by CORS policy: The request The client is not a secure context and The resou
The most important transport layer
[C Supplement] Conversion of Integer to String
阿里云EasyNLP中文文图生成模型带你秒变艺术家
redis的学习_基础部分
First acquaintance with the web
【C补充】整数与字符串的转换
BindingExpression path error: ‘selectMenusList‘ property not found on ‘object‘ ‘‘ViewModel“
SQL Server中如何在date类型中提取年、月、日数据
进程优先级 nice
Ansible简介(详细)特性+优点+设计理念+应用领域+系统架构+工作原理+任务执行流程
NLP自然语言处理(二)
Nacos Configuration Center
三年经验只会点点点(功能测试),辞职后你可能连工作都找不到了。
联邦学习综述(一)——联邦学习的背景、定义及价值
历经5面的阿里实习面经篇~









