Yet another variant-style type, and boost inter-library dependencies

I have written a union-style type similar to boost::variant which allows single values, and multiple types. This type is called a union-list ( ul ) and is described at http://www.codeproject.com/useritems/union_list.asp I will be honest, there are several disadvantages of the union-list when compared to boost::variant 1. Declaration style is uglier : typdef ul<int, ul<char, ul<float, ul<string, ul_end> > > > my_union_list; 2. the data size is huge = summation of the size of the individual types plus sizeof(bool) * #types. 3. union-list has very few features The advantages (and my motivation for creating it) of the union-list is that it requires no other boost libraries and has a very tiny code base. Another difference ( but not neccessarily an advantage ) of the union-list is that it uses and provides an index to access the type of its contents. I don't know if this is sufficient to warrant eventual submission as a boost mini-library. Any comments? In general I am curious about how other boosters feel about boost library sizes and inter-library couplings. For me this is a big obstacle to using boost in many circumstances. It doesn't seem to be a concern at all for the boost community, but I wonder if other programmers have similar sentiments and find themselves often seeking out simpler alternatives. Christopher Diggins http://www.cdiggins.com http://www.heron-language.com

On 01/04/2005 11:52 AM, christopher diggins wrote: [snip]
The advantages (and my motivation for creating it) of the union-list is that it requires no other boost libraries and has a very tiny code base. Another difference ( but not neccessarily an advantage ) of the union-list is that it uses and provides an index to access the type of its contents. These same advantages (AFAICT) are provided by the code reference by:
http://thread.gmane.org/gmane.comp.lib.boost.devel/115072 More specifically, by the sum.hpp code. In addition, that code shares almost the same code with product.hpp and doesn't use any extra memory. I'm still developing the code and the successors are in the same indexed_types directory in files: composite_sum composite_product However, as you can see by the above thread, there's some question about the advantages vs. the existing boost tuple and variant types. So for, I can't see how there could be since the memory is minimal and access time (AFAICT) can't be much faster since accesses are simply done by directly naming the supertype (via the Index template argument) containing the required tuple or variant member. My understanding is that Joel will answer the question when he has the time.

On 01/04/2005 03:21 PM, Larry Evans wrote:
These same advantages (AFAICT) are provided by the code reference by:
Sorry, that link is to start of thread. The post containing a link to the code is: http://article.gmane.org/gmane.comp.lib.boost.devel/115083 but I might as well give a direct link: http://cvs.sourceforge.net/viewcvs.py/boost-sandbox/boost-sandbox/boost/inde... Of course, feedback is welcome. Regards, Larry

christopher diggins wrote:
In general I am curious about how other boosters feel about boost library sizes and inter-library couplings. For me this is a big obstacle to using boost in many circumstances. It doesn't seem to be a concern at all for the boost community, but I wonder if other programmers have similar sentiments and find themselves often seeking out simpler alternatives.
It's good to reduce coupling. It's good to keep libraries small. That said... The point of code libraries is to do things once well, rather than a thousand times poorly. Library designers and application programmers alike should avail themselves of that resource. I wouldn't forego using a boost library in another library just for the sake of avoiding a dependency, especially if it meant I was duplicating functionality. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

At 01:52 PM 1/4/2005, christopher diggins wrote:
In general I am curious about how other boosters feel about boost library
sizes and inter-library couplings. For me this is a big obstacle to using
boost in many circumstances. It doesn't seem to be a concern at all for the boost community, but I wonder if other programmers have similar sentiments and find themselves often seeking out simpler alternatives.
Boost has an unusual characteristic when it comes to coupling. Because a number of Boost libraries that have proven widely useful have been accepted as part of the C++ Standard Library (via TR1), coupling involving these libraries will change from Boost coupling (which could be seen as negative) to standard library coupling (which is usually seen as far less negative). The C++ committee is starting work on a second library technical report. I assume that more Boost libraries will be proposed for TR2. So the reduction of coupling between Boost libraries will probably continue. Secondly, when Boost developers use someone else's Boost library, they have a long history of identifying problems and suggesting improvements. This is part the reason that Boost libraries are of relatively high quality. I don't think we want to do anything to discourage that. Boost libraries should continue to use other Boost libraries where useful, IMO. Excess coupling only becomes "excess" when it serves little useful purpose. --Beman

On 01/04/2005 06:54 PM, Beman Dawes wrote: [snip]
Boost libraries should continue to use other Boost libraries where useful, IMO. Excess coupling only becomes "excess" when it serves little useful purpose.
So if variant or tuple can be implemented without coupling to other Boost libraries and with no disadvantage w.r.t. the current Boost variant and tuple, then the coupling to other Boost libraries in the current Boost variant and tuple is "excessive". Since there does exist other variant (and tuple) implementations without this coupling, the only remaining question is "is there any disadvantage w.r.t. the current Boost variant and tuple?". Agreed?

On 01/04/2005 06:54 PM, Beman Dawes wrote: [snip]
Boost libraries should continue to use other Boost libraries where useful, IMO. Excess coupling only becomes "excess" when it serves
At 12:13 AM 1/5/2005, Larry Evans wrote: little
useful purpose.
So if variant or tuple can be implemented without coupling to other Boost libraries and with no disadvantage w.r.t. the current Boost variant and tuple, then the coupling to other Boost libraries in the current Boost variant and tuple is "excessive". Since there does exist other variant (and tuple) implementations without this coupling, the only remaining question is "is there any disadvantage w.r.t. the current Boost variant and tuple?". Agreed?
That's really a decision for the developers of those libraries. They are in the best position to judge the impact pro and con of removing the coupling. --Beman

On 01/04/2005 11:52 AM, christopher diggins wrote:
I have written a union-style type similar to boost::variant which allows [snip] 2. the data size is huge = summation of the size of the individual types plus sizeof(bool) * #types.
Could you use the method for our_storage_size in: http://cvs.sourceforge.net/viewcvs.py/boost-sandbox/boost-sandbox/boost/indexed_types/composite_sum.hpp?rev=1.2&view=auto To calculate the maximum of the individual sizes and then just allocate storage for this max size? [snip]
union-list is that it uses and provides an index to access the type of its contents.
This, IMHO, is important. In the above indexed_types directory, there's typemap_unsigned.hpp which allows using unsigned indices instead of enumerations to access the elements. This was designed to allow the convenience of mpl's sequences; however, it also requires the possibly time consuming use of mpl's at_c and size. I don't know if it's really a significant time consumer, but it'd be nice if your method could somehow be adapted to avoid this. I've tried to think of a way to use mpl's inherit_linearly; however, I think it can't be done because, in order to use indexed accesss, all the type arguments of the inherited classes have to be identical except for the index. Maybe someone else can think of a workaround?

On 01/04/2005 11:52 AM, christopher diggins wrote:
I have written a union-style type similar to boost::variant which allows [snip] single values, and multiple types. This type is called a union-list ( ul ) and is described at http://www.codeproject.com/useritems/union_list.asp This code has specializations of nested classes, and, at least according to compile errors in comments to the example code in:
http://boost-sandbox.sourceforge.net/vault/class_scope_specialization.cpp this wouldn't be accepted by gcc.

----- Original Message ----- From: "Larry Evans" <cppljevans@cox-internet.com> To: <boost@lists.boost.org> Sent: Wednesday, January 05, 2005 12:45 PM Subject: [boost] Re: Yet another variant-style type,and boost inter-library dependencies
On 01/04/2005 11:52 AM, christopher diggins wrote:
I have written a union-style type similar to boost::variant which allows [snip] single values, and multiple types. This type is called a union-list ( ul ) and is described at http://www.codeproject.com/useritems/union_list.asp This code has specializations of nested classes, and, at least according to compile errors in comments to the example code in:
http://boost-sandbox.sourceforge.net/vault/class_scope_specialization.cpp
this wouldn't be accepted by gcc.
Thanks for the head's up. I factored the nested template class out. It should work on gcc now. Christopher Diggins http://www.cdiggins.com http://www.heron-language.com
participants (4)
-
Beman Dawes
-
christopher diggins
-
David Abrahams
-
Larry Evans