Boost logo

Boost :

Subject: Re: [boost] [Library idea] Type-safe Flagsets
From: degski (degski_at_[hidden])
Date: 2018-06-27 04:42:21


On 27 June 2018 at 02:37, Gavin Lambert via Boost <boost_at_[hidden]>
wrote:

> On 27/06/2018 01:41, degski wrote:
>
>> Once one has adopted the idea of "flags" to possibly not exist, i.e. not
>> to
>> be either true or false, a natural extension is to adopt "fuzzy flags" as
>> well, i.e. use floats. Some bike-shedding: I think the word flags is not
>> sufficiently general.
>>
>
> At this point you've sufficiently departed the "bitwise operations" model
> to make it fairly meaningless.

 You would implement trits with bitwise operations using BCT (Binary Coded
Ternary: implementation
<http://homepage.divms.uiowa.edu/~jones/ternary/libtern.shtml>). Ternaries
have some interesting mathematical properties as well, which is explained
here <https://en.wikipedia.org/wiki/Redundant_binary_representation>. There
are also pratical applications
<https://en.wikipedia.org/w/index.php?title=Ternary_numeral_system&action=edit&section=4>.

You'd probably be better served with a regular structure or with
> Boost.ProgramOptions instead.

Did you read the G.O.A.P. link I posted (here's one from MIT
<http://alumni.media.mit.edu/%7Ejorkin/goap.html>)? Because if you had, you
would not suggest to solve this problem with Boost.ProgramOptions.

As to the fuzzy idea, bits are not necessarily digital, think analog
computers.

Personally, I think the flags proposal is an instance of over-engineering
and is making things that are fairly simple (and why not use bitfields, the
compiler does the work, certainly better than any had-coded solution)
complicated. It is also a well-known and understood idea.

degski


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk