当前位置:网站首页>spicy (1) basic definition
spicy (1) basic definition
2022-07-30 03:43:00 【a tobey】
unit
spicy parses data units through the unit type, which is similar to the well-known struct or record type.It defines a series of sequential fields, each of which has a name and a type, and stores the corresponding value at runtime.Units can be instantiated, assigned values to various fields, and those field values can be retrieved.
module Test;public type Foo = unit {# define a 32-bit integerversion: uint32 &default=56; # You can add the &default attribute to add a default value, otherwise the default value will not be set};# instantiate as fglobal f:Foo;# You can assign a value to override the default value of 56# f.version=60;print f; # Note that if the field inside is not assigned a value, the default value will not be read even if there is a default value.shows not setprint "version is %s" % f.version; # Note that when accessing the field, if there is no assignment, but there is a default value, the default value will be read
A unit is the starting point or entry for parsing data.If you want to make the unit outside the current module (that is, other files want to use the unit defined by the file), you need to declare it as public, and you can only write it for internal access.
By default, spicy is in network byte order.Can
边栏推荐
猜你喜欢
Overview of Federated Learning (2) - Classification, Framework and Future Research Directions of Federated Learning
SDL player in action
Awesome, Tencent technical experts handed Redis technical notes, and the download volume has exceeded 30W
WPF引入 ttf 图标文件使用记录
HCIP experiment (05) OSPF comprehensive experiment
[C Supplement] Conversion of Integer to String
Three years of experience will only be a little bit (functional testing), and you may not even be able to find a job after resigning.
MyCat中对分库分表、ER表、全局表、分片规则、全局序列等的实现与基本使用操作
Stimulsoft ReportsJS and DashboardsJS. 2022.3.3
SQL Server中如何在date类型中提取年、月、日数据
随机推荐
小程序毕设作品之微信二手交易小程序毕业设计成品(7)中期检查报告
基于全志D1-H和XR806的名贵植物监控装置
Transformation of traditional projects
MySQL之数据查询(分类汇总与排序)
联邦学习综述(二)——联邦学习的分类、框架及未来研究方向
un7.29: How to install and configure redis in Linux-centos?
SDL播放器实战
nSoftware.PowerShell.Server.2020
Nacos配置中心
Is the snowflake the same question?
【无标题】
Ansible introduction (detailed) features + advantages + design concept + application field + system architecture + working principle + task execution process
Testers, what else do you need to know besides testing?
NLP Natural Language Processing (1)
解决编译安装gdb-10.1 unistd.h:663:3: error: #error “Please include config.h first.“ 问题
The relationship between the number of Oracle processes and the number of sessions
Nacos achieves high availability
小程序毕设作品之微信积分商城小程序毕业设计成品(5)任务书
sql中 exists的用法
Overview of Federated Learning (1) - Background, Definition and Value of Federated Learning