|
Boost : |
Subject: Re: [boost] [boost::endian] Request for comments/interest
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2010-06-01 08:38:36
Terry Golubiewski wrote:
> Tomas Puverle wrote:
>
> > I definitely see the elegance of this code and as I said
> > before, I am not opposed to implementing the typed
> > interface. Having said that, I do have several concerns
> > with how this gets actually read from/sent to a device
> > and additionally, as mentioned in another post, I think
> > this "neat" code may be a little opaque for someone not
> > familiar with it.
>
> I think the "opaqueness" is a major feature of this approach.
Opacity is good when you want high level abstract behavior, but shouldn't preclude the (potentially) higher efficiency low level API.
> The user of the higher-level classes has no idea about the
> underlying endianness of the message fields or if they've
> been byte-swapped yet or not.
Either the typed endian values store an extra bit to determine whether the external to host swapping has already occurred, in which case they cannot be written out as is, or the swapping must occur *each time* the value is read. I presume the latter to be the case. When the external and host order match, this isn't a big deal, but imagine code that ignorantly loops over such objects repeatedly reading values when the external and host don't match. The overhead can be significant. That's where the opacity can be problematic and the user of such a library must be warned clearly about this potential.
> It just works.
Yes, but it just works inefficiently in some uses cases, unless I missed something.
> And if the systems engineers later decided to change some of
> the endianness of some of the message fields, the message
> definition code would change, but none of the code that uses
> the messages would have to change at all.
I see the value of that, but presuming that the code that reads such a message from the external device is encapsulated, the reading and swapping likely is done together once per message, so changes to endianness are localized without the special types. There is danger of writing code in which reading and swapping is not localized, so it would be appropriate to alter users to the value of doing so.
_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk