16 ms·
To go even further, how much is it different from C# or C++? There you'd just declare the appropriate structs and bitcast.
by lostmsu 4y ago
To go even further, how much is it different from C# or C++? There you'd just declare the appropriate structs and bitcast.
- superdisk 4y agoThat works okay only for fixed-sized structs that don't require any transformation of their members-- otherwise you'll need to write a traditional parser.
- lostmsu 4y agoIt is there in Prolog version too. Search for "FileSize" on the page.
- superdisk 4y agoWhat I mean is that if you need to parse a format that has variable-sized structures, you can't just memcpy them into a struct because structs have a fixed size. Additionally sometimes you need to parse a value into a more tractable representation, for example those octal ASCII strings in the tar format, which requires some additional processing that isn't possible with loading/serializing a struct.
- lostmsu 4y agoWhich is also there in the Prolog code.
- Filligree 4y agoSorry, isn't that undefined behaviour?
- lostmsu 4y agoNot in C# for sure. Not a C++ expert, but I believe reinterpret_cast behavior is defined too.
- pjmlp 4y agoYou can have it as part of unsafe code, hence why the bytecode verifier won't validate Assemblies with unsafe code. https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/unsafe-code https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...
- lostmsu 4y agoI believe verifier is fine with unsafe code. Also not sure what does it have to do with defined/undefined behavior. Even if it is not verifiable, the behavior is still defined.