It could be extended too so that we can do this to a structure, where all endian dependent members are automatically taken care of:
data_header = LittleEndian (data_header);
Where data_header is an aggregate like an array/structure or both, this would impact numeric fields, floats and pointers/offsets even...
The version working on a single, not structured, variable is best suited to a default library, it should not be part of the
language, same goes with the endianness check.
The extended version, though, looks a bit too 'magic'.
I clarify: would a
user of the language be able to implement a similar
fully generic function using the language itself?
It seems that some deep introspection capabilities would be needed, I don't think you mentioned them before (I might have missed them).
If not, it should be clear for the reader that this is not a regular function (BTW: I hated I could not write a write() in Pascal).
The same goes with passing arguments of different types (and this is valid also for the simple version!): the type model of this now language is totally unclear to me, as are the memory model and the execution model*.
Also: how modules are handled, though this too might have escaped my attention.
In this thread I have mostly seen syntax (not a fan, but to each their own - and not a problem unless it's obnoxious) which I think should be a lesser concern and random bits and pieces.
*Apart from the "constant cycle duration switch", which is impossible to achieve if not in the trivial cases, even forgetting about modern HW, unless someone has disproved Turing's halting theorem.