-
Notifications
You must be signed in to change notification settings - Fork 206
Description
summary
allow some way to specify type-aliases for elemental types
details
current situation:
- kaitai allows specifying subtypes, but not "type aliases"
- with type-alias, i mean the parsing specification (e.g.
type,size,enum,valid,encoding, etc.) for single field value as against the subtype (defined intypes.<id>.seq) which is for multiple fields
use scenario:
-
on using
typesconstruct to define single-field type-aliases, -
... it gets needlessly parsed as a subtype (thus, redundant sub-attribute / children node etc) with name
_unnamedX -
this looks ugly, increases output's size, & require meaningless unfolding / exapnding
-
screenshots:
.ksy samples:
-
small example:
types: {my_type_alias: {seq: [{type: u1, enum: my_enum}]}} -
working sample with multiple aliases:
types: my_type_alias_a: seq: - {type: u1, enum: my_enum} my_file_name: # alias for elemental type "string" seq: - {type: str, size: 10, encoding: utf-8} # why does ksc complain about utf-8's lower-case? my_validation: seq: - {type: u4le, valid: {min: 10}}
additional info:
type aliases are used in a lot of places:
- as above schema example shows: for specifying
enum,size,valid, or any myriad of attributes - for reusing same specification at multiple places i.e. DRY
for these uses, there really is no need of any sequence, as all the definition is for single value only.
also, these two features (type-alias, and sequence-def) are fairly orthogonal i think, and can be easily composed on user's end if the need arises.
solutions
- i am not sure at the moment regarding what the details of implementation (even for syntax) can be, considering the cross-language exports.
- i thought about instances, but it seems it requires explicitly specifying
pos, and it's purpose seems something else too.
versions
Kaitai WebIDE version: 0.1-SNAPSHOT-a02d396 (2025-09-06 13:13:49, license)
Kaitai compiler version: 0.11.0 (2025-09-07T18:59:46Z)
meta
i tried searching for existing duplicates with following queries:
Add a 👍 reaction to issues you find important.

