当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
一直空、一直爽,继续抄顶告捷!
Record NLP various resource URLs
Microservice CAP Principles
SDL播放器实战
Testers, what else do you need to know besides testing?
小程序毕设作品之微信二手交易小程序毕业设计成品(4)开题报告
微服务CAP原则
MySQ死锁
[Flink] How to determine the cluster planning size from development to production launch?
Transformation of traditional projects
redis的学习_基础部分
SDL player in action
MySQ deadlock
联邦学习综述(一)——联邦学习的背景、定义及价值
Drools(7):WorkBench
What is the difference between mission, vision and values?
JUC (5): Problems caused by sharing
flutter 记录学习不一样的动画(二)
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.
Introduction to management for technical people 1: What is management