Conversation
Notices
-
Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Wednesday, 15-Jun-2022 11:21:26 UTC Haelwenn /элвэн/ :triskell: @koakuma @clacke @chjara Endianness is mostly just encoding/decoding for external data, so you want functions.
Types are for memory representations and safety features and endiannness is pretty much irrelevant there.-
Santa Claes 🇸🇪🇭🇰🎅 (clacke@libranet.de)'s status on Wednesday, 15-Jun-2022 11:21:25 UTC Santa Claes 🇸🇪🇭🇰🎅 @lanodan @koakuma @chjara Yeah, handle this kind of nonsense at the boundaries, just like text encodings, and internally just use opaque data types. -
Santa Claes 🇸🇪🇭🇰🎅 (clacke@libranet.de)'s status on Wednesday, 15-Jun-2022 11:23:00 UTC Santa Claes 🇸🇪🇭🇰🎅 @koakuma The conversion is in your network protocol adapter and doesn't affect your memory layout.
@lanodan @chjara -
Koakuma (koakuma@uwu.social)'s status on Wednesday, 15-Jun-2022 11:23:01 UTC Koakuma @lanodan @chjara @clacke In short, I'd like for the conversion routines to be only written in *one* place and then I can simply declare new variables without needing to remember to convert that variable again in the parser/serializer
e.g if I have a struct like:
struct a {
BigEndian<uint32_t> c1;
}And I want to add another data into it, like:
struct a {
BigEndian<uint32_t> c1;
BigEndian<uint32_t> c2;
}I don't want to have to not forget to add conversion calls when handling c2 :02lurk:
-
Koakuma (koakuma@uwu.social)'s status on Wednesday, 15-Jun-2022 11:23:02 UTC Koakuma @lanodan @chjara @clacke Eh I'd like to see it for other sequence-of-bytes <-> multibyte scalar types too honestly...
Or if your language has rich types you can define the wrapper container by yourself (e.g with generic classes or somesuch) - I'm not saying that it has to be hardcoded inside the lanugage :02lurk:
-
Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Wednesday, 15-Jun-2022 11:23:03 UTC Haelwenn /элвэн/ :triskell: @koakuma @chjara @clacke Endianness being a bit like text-encoding, programming languages aren't going to have a type per text encoding, but you're going to have functions to encode/decode in specific text encoding. -
Santa Claes 🇸🇪🇭🇰🎅 (clacke@libranet.de)'s status on Wednesday, 15-Jun-2022 11:46:26 UTC Santa Claes 🇸🇪🇭🇰🎅 @koakuma The solution is clearly to require people to write the network layer in ADA.
@lanodan @chjara -
Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Wednesday, 15-Jun-2022 11:46:27 UTC Haelwenn /элвэн/ :triskell: @koakuma @chjara @clacke To me what you want is a parser generator, just that you got a OOP brainworm which abstracts away the whole thing, typically with init/get/set/fini methods (that are really just normal functions).
Also:
struct a { BigEndian<uint32_t> c1; LittleEndian<uint32_t> c2; } a.c1 = 0x42; a.c2 = 0x24;What would c1 == c2 give? Type error? True? False? Would you have cycles eaten away with endian-conversion at each usage?
Santa Claes 🇸🇪🇭🇰🎅 likes this. -
Koakuma (koakuma@uwu.social)'s status on Wednesday, 15-Jun-2022 11:46:27 UTC Koakuma @lanodan @chjara @clacke I'd like that to be a type error, yes, and I don't really mean it in an OOP way?
> Would you have cycles eaten away with endian-conversion at each usage?
Maybe? Endianness conversion is really just one instruction ( or zero if you are on SPARCv9 and making use of those fun load/store ASI tags :02smile: ) and languages that have that facility (e.g Ada) seem to be doing fine, performance-wise? -
Koakuma (koakuma@uwu.social)'s status on Wednesday, 15-Jun-2022 11:46:57 UTC Koakuma @lanodan @chjara @clacke But yea parser generator would be okay too, I'd support anything that would make defining canonical endianness on datastreams easy and error-free :cirnouwu:
Santa Claes 🇸🇪🇭🇰🎅 likes this. -
Elias Mårtenson (loke@functional.cafe)'s status on Wednesday, 15-Jun-2022 11:47:55 UTC Elias Mårtenson @koakuma @lanodan @chjara @clacke at that point you have to consider padding as well, so just specifying endianness isn't enough. You'd need a way to describe binary structures, which some languages do have. Perl has pack for example.
Santa Claes 🇸🇪🇭🇰🎅 likes this. -
Koakuma (koakuma@uwu.social)'s status on Wednesday, 15-Jun-2022 12:20:35 UTC Koakuma @loke Ohhh that is interesting, lemme have a read about it~
-
Elias Mårtenson (loke@functional.cafe)'s status on Wednesday, 15-Jun-2022 12:20:35 UTC Elias Mårtenson @koakuma Another example is the lisp-binary package for Common Lisp. If you look at the documentation you can see an example using the DEFBINARY macro. https://quickdocs.org/lisp-binary
Santa Claes 🇸🇪🇭🇰🎅 likes this.
-