[Y-devel] Proposal for a minor change in the Y-protocol
Andreas Karafyllis ankar at homodigitalis.net
Sun Apr 11 16:03:47 BST 2004
Damn, I have a lot of errrors in the examples. Sorry about this...
Here is the email again with the errors (hopefully) corrected:
On Sunday 11 April 2004 14:51, Andreas Karafyllis wrote:
> Hi everybody,
>
> If am currently implementing Eiffel-bindings for Y and I noticed thet the
> way strings are serialized as message-members can be improved.
>
> Currently (I am talking about the latest version after patch 33), a string
> is serialized as following:
> 00 - 03: Member length without this field
> 04 - 07: Type information (0 for strings)
> 08 - XX: The string including the 0 character.
>
> XX is the value of "Member length" + 3
> Example: The string "Hello" will be serialized as following:
>
> 00 - 03: 10
> 04 - 07: 0
> 08 - 11: 'H', 'e', 'l', 'l'
> 12 - 13: 'o', '\0'
>
> In the comments in the libYc is written thet the '\0' may be not used in
> the future. I go for it. The '\0' is not needed. You should depend to
> "member length" field find how big the string is. And null terminated
> strings are a bad idea anyway. A very nice article about this topic is the
> following: https://www.joelonsoftware.com/articles/fog0000000319.html
>
> With or without the null character there is still a small problem. The next
> field could start in an address which is not 4-byte aligned. If the next
> member is for example an integer, all its field wills be stored in no
> 4-bytes aligend addresses. There are to reason I do not like it:
> 1) It is ugly :-)
> 2) Most modern RISC processors do not work very happily with not-aligned
> values. We should try to make serialization - deserialization as fast as
> possible
>
> Therefore, I suggest the following format:
> 00 - 03: Member length without this field
> 04 - 07: Type information (0 for strings)
> 08 - 11: String length
> 12 - XX: The string padded with zeros in case string_length modulo 4 not
> equal to zero
>
> XX in like before "Member length" + 3
> Using this format the above example will be serialized like this:
> 00 - 03: 16
> 04 - 07: 0
> 08 - 11: 5
> 12 - 15: 'H', 'e', 'l', 'l'
> 16 - 19: 'o', '\0', \0','\0'
>
> I suggest that a similar approach is followed in the future for all fields
> that have a variable size
>
> Bye
>
> Andreas
More information about the Y-devel mailing list
2026 © www.Y-Windows.Org - All Rights Reserved