Re: [boost] Formal review: Optional library

2002-12-09 Thread William E. Kempf
Douglas Gregor said: > The formal review of Fernando Cacciola's Optional library begins today > and runs until the end of Wednesday, December 18. > > The Optional library provides a class template "optional" that either > contains a value of type "T" or contains no value (i.e., having a value >

Re: [boost] Formal review: Optional library

2002-12-09 Thread Fernando Cacciola
"William E. Kempf" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Douglas Gregor said: > > The formal review of Fernando Cacciola's Optional library begins today > > and runs until the end of Wednesday, December 18. > > > > The Optional library provides a cla

RE: [boost] Formal review: Optional library

2002-12-09 Thread Glen Knowles
Title: RE: [boost] Formal review: Optional library From: Fernando Cacciola [mailto:[EMAIL PROTECTED]] >> >> * I'm unsure about the presence of "initialized()".  On the one hand, the >> duplication in features (compared to "get/peek() == 0") is so

Re: [boost] Formal review: Optional library

2002-12-09 Thread Fernando Cacciola
- Original Message - From: "Glen Knowles" <[EMAIL PROTECTED]> To: "'Boost mailing list'" <[EMAIL PROTECTED]> Sent: Monday, December 09, 2002 6:42 PM Subject: RE: [boost] Formal review: Optional library > From: Fernando Cacciola [mailto:[EMAIL

Re: [boost] Formal review: Optional library

2002-12-09 Thread William E. Kempf
Fernando Cacciola said: > "William E. Kempf" <[EMAIL PROTECTED]> wrote in message >> * I believe there should be an "optional& operator=(T const& v)". >> > This would break the pointer-semantics: > > optional opt ; > > opt = 3 ; > > instead of > > *opt = 3 ; > > as it is currently the required syn

Re: [boost] Formal review: Optional library

2002-12-10 Thread Peter Dimov
From: "Fernando Cacciola" <[EMAIL PROTECTED]> > The conversion to bool for a smart pointer unambiguously refers to the > NULL state of the pointer wrapped. > In the case of optional, a conversion to bool will be ambiguous in those > cases were the wrapped T in optional<> is bool itself. On the oth

Re: [boost] Formal review: Optional library

2002-12-10 Thread Anthony Williams
Fernando Cacciola writes: > > - Original Message - > From: "Glen Knowles" <[EMAIL PROTECTED]> > To: "'Boost mailing list'" <[EMAIL PROTECTED]> > Sent: Monday, December 09, 2002 6:42 PM > Subject: RE: [boost] Formal r

Re: [boost] Formal review: Optional library

2002-12-10 Thread William E. Kempf
OK, I've been thinking about the interface a bit more and want to voice some other opinions. First, why were pointer semantics chosen at all? Why couldn't you have gone with value semantics? optional foo() { //... } void bar(int value) { //... } optional res = foo(); if (res.initialized(

Re: [boost] Formal review: Optional library

2002-12-10 Thread Fernando Cacciola
- Original Message - From: "William E. Kempf" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, December 09, 2002 7:48 PM Subject: Re: [boost] Formal review: Optional library > > Fernando Cacciola said: > > "William E. Kempf" <[EMAI

Re: [boost] Formal review: Optional library

2002-12-10 Thread Fernando Cacciola
- Original Message - From: "Peter Dimov" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Tuesday, December 10, 2002 9:23 AM Subject: Re: [boost] Formal review: Optional library > From: "Fernando Cacciola" <[EMAIL PR

Re: [boost] Formal review: Optional library

2002-12-10 Thread Peter Dimov
From: "Fernando Cacciola" <[EMAIL PROTECTED]> > > I don't think that optional is an important use case (outside of > > generic contexts) since optional is simply a tri-state type with an > > inconvenient interface. > > > Good point. I've been using optional long before tribool existed. > Now I migh

Re: [boost] Formal review: Optional library

2002-12-10 Thread Fernando Cacciola
- Original Message - From: "Anthony Williams" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Tuesday, December 10, 2002 9:46 AM Subject: Re: [boost] Formal review: Optional library > Fernando Cacciola writes: > > &g

Re: [boost] Formal review: Optional library

2002-12-10 Thread Fernando Cacciola
- Original Message - From: "Peter Dimov" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Tuesday, December 10, 2002 3:33 PM Subject: Re: [boost] Formal review: Optional library > From: "Fernando Cacciola" <[EMAIL PRO

Re: [boost] Formal review: Optional library

2002-12-10 Thread William E. Kempf
Fernando Cacciola said: >> Fernando Cacciola said: >> > "William E. Kempf" <[EMAIL PROTECTED]> wrote in message >> >> * I believe there should be an "optional& operator=(T const& v)". >> >> >> > This would break the pointer-semantics: >> > >> > optional opt ; >> > >> > opt = 3 ; >> > >> > instead

Re: [boost] Formal review: Optional library

2002-12-10 Thread Peter Dimov
From: "Fernando Cacciola" <[EMAIL PROTECTED]> > I understand your reasoning, but what do you suggest? I suggest that we need not give much weight to optional when designing optional's interface. > Leaving optional inherently unsafe? Unsafe? The conversion from optional to bool might be confusing

Re: [boost] Formal review: Optional library

2002-12-10 Thread Joel de Guzman
- Original Message - From: "Fernando Cacciola" <[EMAIL PROTECTED]> > optional<> is trying to model using C++ a concept that > it is not really covered by the language, that of uninitialzed values. > It uses pointer semantics *just* because pointers are the only sort of > C++ objects wh

Re: [boost] Formal review: Optional library

2002-12-10 Thread Fernando Cacciola
- Original Message - From: "William E. Kempf" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, December 10, 2002 12:43 PM Subject: Re: [boost] Formal review: Optional library > OK, I've been thinking about the interface a bit more and want

Re: [boost] Formal review: Optional library

2002-12-10 Thread Fernando Cacciola
- Original Message - From: "Peter Dimov" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Tuesday, December 10, 2002 4:26 PM Subject: Re: [boost] Formal review: Optional library > From: "Fernando Cacciola" <[EMAIL

Re: [boost] Formal review: Optional library

2002-12-10 Thread Fernando Cacciola
- Original Message - From: "Joel de Guzman" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Tuesday, December 10, 2002 5:21 PM Subject: Re: [boost] Formal review: Optional library > > - Original Message - > Fr

Re: [boost] Formal review: Optional library

2002-12-10 Thread David Abrahams
"Joel de Guzman" <[EMAIL PROTECTED]> writes: > - Original Message - > From: "Fernando Cacciola" <[EMAIL PROTECTED]> > > > >> optional<> is trying to model using C++ a concept that >> it is not really covered by the language, that of uninitialzed values. >> It uses pointer semantics *just*

Re: [boost] Formal review: Optional library

2002-12-10 Thread Joel de Guzman
- Original Message - From: "Fernando Cacciola" <[EMAIL PROTECTED]> > - Original Message - > From: "Joel de Guzman" <[EMAIL PROTECTED]> > > Hi, > > > > Probably a dumb question but allow me to ask anyway: > > > > Wouldn't a more generic variant class do what the > > optional is t

Re: [boost] Formal review: Optional library

2002-12-10 Thread William E. Kempf
Fernando Cacciola said: > From: "William E. Kempf" <[EMAIL PROTECTED]> >> OK, I've been thinking about the interface a bit more and want to >> voice some other opinions. First, why were pointer semantics chosen >> at all? Why couldn't you have gone with value semantics? >> >> optional foo() >> {

Re: [boost] Formal review: Optional library

2002-12-10 Thread Joel de Guzman
- Original Message - From: "David Abrahams" <[EMAIL PROTECTED]> > "Joel de Guzman" <[EMAIL PROTECTED]> writes: > > > - Original Message - > > From: "Fernando Cacciola" <[EMAIL PROTECTED]> > > > > > > > >> optional<> is trying to model using C++ a concept that > >> it is not re

Re: [boost] Formal review: Optional library

2002-12-10 Thread Joel de Guzman
- Original Message - From: "Joel de Guzman" <[EMAIL PROTECTED]> > - Original Message - > From: "David Abrahams" <[EMAIL PROTECTED]> > > optional captures the zero/one distinction, which, as its analogy to > > pointers makes clear, is a very useful one. A type which can contai

Re: [boost] Formal review: Optional library

2002-12-10 Thread Fernando Cacciola
- Original Message - From: "Joel de Guzman" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Tuesday, December 10, 2002 7:04 PM Subject: Re: [boost] Formal review: Optional library > > - Original Message - >

Re: [boost] Formal review: Optional library

2002-12-10 Thread Joel de Guzman
- Original Message - From: "Fernando Cacciola" <[EMAIL PROTECTED]> > > > optional captures the zero/one distinction, which, as its analogy to > > > pointers makes clear, is a very useful one. A type which can contain > > > any number of different types would have a much more complicated

Re: [boost] Formal review: Optional library

2002-12-10 Thread Fernando Cacciola
- Original Message - From: "William E. Kempf" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, December 10, 2002 4:18 PM Subject: Re: [boost] Formal review: Optional library > [snipped] > > But I do see reasons to want to keep with a sm

Re: [boost] Formal review: Optional library

2002-12-10 Thread Fernando Cacciola
- Original Message - From: "Joel de Guzman" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Tuesday, December 10, 2002 6:47 PM Subject: Re: [boost] Formal review: Optional library > > - Original Message - > Fr

Re: [boost] Formal review: Optional library

2002-12-10 Thread Joel de Guzman
- Original Message - From: "Fernando Cacciola" <[EMAIL PROTECTED]> > > Hmmm, I'm not sure if I agree with this. T can very well be > > uninitialized in the variant when nil_t is in effect. Then > > nil_t can just be struct nil_t {}; which costs nothing to initialize. > > Why is optional

Re: [boost] Formal review: Optional library

2002-12-10 Thread David Abrahams
"Joel de Guzman" <[EMAIL PROTECTED]> writes: > - Original Message - > From: "Fernando Cacciola" <[EMAIL PROTECTED]> > >> > > optional captures the zero/one distinction, which, as its analogy to >> > > pointers makes clear, is a very useful one. A type which can contain >> > > any number

Re: [boost] Formal review: Optional library

2002-12-10 Thread David Abrahams
"Fernando Cacciola" <[EMAIL PROTECTED]> writes: > I still don't like to think of optional<> as a container, so I still > don't like this reset. Do you really think of auto_ptr and shared_ptr as containers? They seem to have little or nothing in common with any of the standard containers. > My m

Re: [boost] Formal review: Optional library

2002-12-10 Thread Tanton Gibbs
> > > That's why it hands you a pointer to the value, because you can test the > > > pointer > > > for NULL; but that's it. > > > IOWs, the pointer returned by optional is conceptually a handle, not a > > > pointer. > > > That's why I like the member function peek() much better than get(). > > > >

Re: [boost] Formal review: Optional library

2002-12-11 Thread Peter Dimov
From: "Joel de Guzman" <[EMAIL PROTECTED]> > > Or perhaps, optional is just a limited add-on API over the variant? Or perhaps optional is just a limited API over a container? ___ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/b

Re: [boost] Formal review: Optional library

2002-12-11 Thread Peter Dimov
From: "Fernando Cacciola" <[EMAIL PROTECTED]> > I still don't like to think of optional<> as a container, so I still don't > like this reset. I don't see why. reset() has nothing to do with containership; it's a generic shorthand for reconstructing an object in place. void X::reset(args) Effects

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
- Original Message - From: "Joel de Guzman" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Tuesday, December 10, 2002 8:53 PM Subject: Re: [boost] Formal review: Optional library > > - Original Message - > Fr

Re: [boost] Formal review: Optional library

2002-12-11 Thread Peter Dimov
From: "Fernando Cacciola" <[EMAIL PROTECTED]> > > value() is there just because the proxy() fails to convert to T&; > and the proxy is needed by the deep-constantess, What is wrong with T & operator*(); T const & operator*() const; ? > Of course, it can be argued that if you wanted > to convey

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
- Original Message - From: "David Abrahams" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Tuesday, December 10, 2002 9:53 PM Subject: Re: [boost] Formal review: Optional library > [SNIP] > > "Joel de Guzman" &l

Re: [boost] Formal review: Optional library

2002-12-11 Thread David Abrahams
"Fernando Cacciola" <[EMAIL PROTECTED]> writes: > Currently, the non-POD case implementation goes like this: > > (this is a sketch actually) > > template > class optional1 > { > optional1 ( T const& v ) { p = new (buffer.address()) T(v) ; } > > T const& operator *() { return *p; } // Dereferen

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
- Original Message - From: "David Abrahams" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Tuesday, December 10, 2002 10:00 PM Subject: Re: [boost] Formal review: Optional library > "Fernando Cacciola" <[EMAIL P

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
- Original Message - From: "Tanton Gibbs" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Tuesday, December 10, 2002 10:10 PM Subject: Re: [boost] Formal review: Optional library > > > > That's why it hands you a

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
- Original Message - From: "William E. Kempf" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, December 10, 2002 7:04 PM Subject: Re: [boost] Formal review: Optional library > > Fernando Cacciola said: > > > But if I wrote: > > > &

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
- Original Message - From: "David Abrahams" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Wednesday, December 11, 2002 11:14 AM Subject: Re: [boost] Formal review: Optional library > "Fernando Cacciola" <[EMAIL

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
- Original Message - From: "Peter Dimov" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Wednesday, December 11, 2002 10:21 AM Subject: Re: [boost] Formal review: Optional library > From: "Fernando Cacciola" <[EMAI

Re: [boost] Formal review: Optional library

2002-12-11 Thread Peter Dimov
From: "Fernando Cacciola" <[EMAIL PROTECTED]> > > > Currently, you can change the value of the optional directly without any > > > performance > > > penalty like this: *opt = new_val, so I don't see any real need for > > reset(). > > > > Not correct, *opt has undefined behavior when opt is uninitia

Re: [boost] Formal review: Optional library

2002-12-11 Thread William E. Kempf
Fernando Cacciola said: >> As did I in the interface I proposed elsewhere. My complaint wasn't >> actually the lack of an operator=(), but of the lack of any way to >> reassign the value in an efficient and uniform manner. >> > But what's wrong with: *opt = new_value? > This is as efficient and a

Re: [boost] Formal review: Optional library

2002-12-11 Thread David Abrahams
"Fernando Cacciola" <[EMAIL PROTECTED]> writes: >> >> There's no need to store p. You can just use >> static_cast(buffer.address()) >> > Yes.. I just shown the pointer explicitely. > The result of the static_cast<> is a pointer, so to obtain a reference (for > the operator*) you need to 'actually'

Re: [boost] Formal review: Optional library

2002-12-11 Thread William E. Kempf
Fernando Cacciola said: > From: "William E. Kempf" <[EMAIL PROTECTED]> >> Fernando Cacciola said: >> > Eventually, I realized that value semantics are not really >> appropiate to deal >> > with unininitialized states since it blurs the distinction between >> testing against other values and testin

Re: [boost] Formal review: Optional library

2002-12-11 Thread William E. Kempf
Fernando Cacciola said: > From: "Joel de Guzman" <[EMAIL PROTECTED]> >> From: "Fernando Cacciola" <[EMAIL PROTECTED]> >> >> > > Hmmm, I'm not sure if I agree with this. T can very well be >> > > uninitialized in the variant when nil_t is in effect. Then >> > > nil_t can just be struct nil_t {}; wh

Re: [boost] Formal review: Optional library

2002-12-11 Thread David Abrahams
"Fernando Cacciola" <[EMAIL PROTECTED]> writes: > - Original Message - > From: "David Abrahams" <[EMAIL PROTECTED]> > To: "Boost mailing list" <[EMAIL PROTECTED]> > Sent: Tuesday, December 10, 2002 10:00 PM > Subject: Re: [b

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
These are some conclusions from the review so far: (A) There is particular (mis) feature in optional which is wrongly documented (as Peter and William showed me), but which is also incorrect. The expression *opt=x; is currently always well defined regardless the initialization state of 'opt'. I

Re: [boost] Formal review: Optional library

2002-12-11 Thread William E. Kempf
Fernando Cacciola said: > These are some conclusions from the review so far: > > (A) > There is particular (mis) feature in optional which is wrongly > documented (as Peter and William showed me), but > which is also incorrect. > > The expression > > *opt=x; > > is currently always well defined re

Re: [boost] Formal review: Optional library

2002-12-11 Thread Peter Dimov
From: "Fernando Cacciola" <[EMAIL PROTECTED]> [...] > Conclusion: I will adopt William's reset, leaving operator*() return > a reference to the optional value *only* if it is initialized > (independently of whether opt is const or not). > > Therefore, the proxy is not needed. And so value() isn't n

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
- Original Message - From: "William E. Kempf" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, December 11, 2002 2:00 PM Subject: Re: [boost] Formal review: Optional library > > [snipped] > > I like what this is sounding like, but think

Re: [boost] Formal review: Optional library

2002-12-11 Thread Tanton Gibbs
> However, I'm still unconvinced that uninitialized optionals should compare > false, > and even though, you can always compare optional values (via operator*), so > I see no benefit in defining relational operators directly (thus these > operators > will be poisoned) Shouldn't unitialized optiona

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
- Original Message - From: "David Abrahams" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Wednesday, December 11, 2002 12:46 PM Subject: Re: [boost] Formal review: Optional library > "Fernando Cacciola" <

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
Based on the coments made by reviewers, this is the new interface: template class optional { optional () ; explicit optional ( T const& val ) ; optional ( optional const& rhs ) ; ~optional() ; // This is provided ONLY to allow implicit conversions from // optional to op

Re: [boost] Formal review: Optional library

2002-12-11 Thread Joel de Guzman
- Original Message - From: "Fernando Cacciola" <[EMAIL PROTECTED]> > > It's trivial to make that a free function like get. Or further, to make > > a subset API for optional. > > > You can certainly do the same with variant. The point is that with > optional<> it is *easier*. > With optio

Re: [boost] Formal review: Optional library

2002-12-11 Thread Tanton Gibbs
> optional opt0(1); > optional opt1(2); > (opt0 == opt1) // true I would not have any problem with this returning false. In the normal ptr world: char c, d; char* p, *q; p = &c; q = &d; if( p == q ) // false People expect it to compare memory locations, not initialization status. Therefore, I w

Re: [boost] Formal review: Optional library

2002-12-11 Thread Joel de Guzman
- Original Message - From: "William E. Kempf" <[EMAIL PROTECTED]> > >> It's trivial to make that a free function like get. Or further, to > >> make a subset API for optional. > >> > > You can certainly do the same with variant. The point is that with > > optional<> it is *easier*. > > Wi

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
- Original Message - From: "Peter Dimov" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Wednesday, December 11, 2002 2:22 PM Subject: Re: [boost] Formal review: Optional library > From: "Fernando Cacciola" <[EMAIL

Re: [boost] Formal review: Optional library

2002-12-11 Thread William E. Kempf
Tanton Gibbs said: >> optional opt0(1); >> optional opt1(2); >> (opt0 == opt1) // true > > I would not have any problem with this returning false. In the normal > ptr world: > char c, d; > char* p, *q; > p = &c; > q = &d; > > if( p == q ) // false > > People expect it to compare memory locations,

Re: [boost] Formal review: Optional library

2002-12-11 Thread Peter Dimov
From: "Fernando Cacciola" <[EMAIL PROTECTED]> [...] > (1) deep-constantness: > > I Followed David Abraham's suggestion and decoupled > constantness of the optional<> object with that of > the value being wrapped. > This is how pointers and most smart pointers work, so > the pointer semantic should

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
- Original Message - From: "Joel de Guzman" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Wednesday, December 11, 2002 5:18 PM Subject: Re: [boost] Formal review: Optional library > - Original Message - > From:

Re: [boost] Formal review: Optional library

2002-12-11 Thread Peter Dimov
From: "Fernando Cacciola" <[EMAIL PROTECTED]> > > > > You should consider providing operator<<(std::ostream&, optional), too. > > > Interesting... > The idea is that if the optional is uninitialized, it outputs something like > "[NULL]", > else forwards to T::operator <<(), right? > > I agree it is

Re: [boost] Formal review: Optional library

2002-12-11 Thread David Abrahams
"William E. Kempf" <[EMAIL PROTECTED]> writes: > Tanton Gibbs said: >>> optional opt0(1); >>> optional opt1(2); >>> (opt0 == opt1) // true >> >> I would not have any problem with this returning false. In the normal >> ptr world: >> char c, d; >> char* p, *q; >> p = &c; >> q = &d; >> >> if( p == q

Re: [boost] Formal review: Optional library

2002-12-11 Thread David Abrahams
"Peter Dimov" <[EMAIL PROTECTED]> writes: > From: "Fernando Cacciola" <[EMAIL PROTECTED]> > [...] >> (1) deep-constantness: >> >> I Followed David Abraham's suggestion and decoupled >> constantness of the optional<> object with that of >> the value being wrapped. >> This is how pointers and most s

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
- Original Message - From: "Peter Dimov" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Wednesday, December 11, 2002 5:49 PM Subject: Re: [boost] Formal review: Optional library > From: "Fernando Cacciola" <[E

Re: [boost] Formal review: Optional library

2002-12-11 Thread Joel de Guzman
- Original Message - From: "Fernando Cacciola" <[EMAIL PROTECTED]> > > And my point, again, is that you can easily add an *easier* API > > that does exactly like your optional API *over* the variant. My > > concern is primarily about redundancy of code. I don't see any > > reason why the

Re: [boost] Formal review: Optional library

2002-12-11 Thread Tanton Gibbs
> optional a(); > optional b(); > optional c(1); > optional d(2); > optional e(2); > > assert(a == b); // both uninitialized > assert(a != c); // one uninitialized > assert(c != d); // both initialized to different values > assert(d == 3); // both initialized to same value > > However, not all

Re: [boost] Formal review: Optional library

2002-12-11 Thread William E. Kempf
David Abrahams said: > "William E. Kempf" <[EMAIL PROTECTED]> writes: > >> Tanton Gibbs said: optional opt0(1); optional opt1(2); (opt0 == opt1) // true >>> >>> I would not have any problem with this returning false. In the >>> normal ptr world: >>> char c, d; >>> char* p, *q; >>>

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
- Original Message - From: "Tanton Gibbs" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Wednesday, December 11, 2002 5:22 PM Subject: Re: [boost] Formal review: Optional library > > optional opt0(1); > > optional opt

Re: [boost] Formal review: Optional library

2002-12-11 Thread William E. Kempf
David Abrahams said: > "Peter Dimov" <[EMAIL PROTECTED]> writes: > >> From: "Fernando Cacciola" <[EMAIL PROTECTED]> >> [...] >>> (1) deep-constantness: >>> >>> I Followed David Abraham's suggestion and decoupled >>> constantness of the optional<> object with that of >>> the value being wrapped. >>>

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
- Original Message - From: "Peter Dimov" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Wednesday, December 11, 2002 5:47 PM Subject: Re: [boost] Formal review: Optional library > From: "Fernando Cacciola" <[EMA

Re: [boost] Formal review: Optional library

2002-12-11 Thread Fernando Cacciola
- Original Message - From: "William E. Kempf" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, December 11, 2002 6:45 PM Subject: Re: [boost] Formal review: Optional library > David Abrahams said: > > "Peter Dimov" <[EMAIL

RE: [boost] Formal review: Optional library

2002-12-12 Thread Iain K.Hanson
> [mailto:[EMAIL PROTECTED]]On Behalf Of William E. Kempf > Sent: 11 December 2002 20:42 > [ snip ...] > > I agree with this. The optional<> concept takes some type and extends > it's possible values to include a new "uninitialized" value. It seems > wholly logical to me for this: > > optiona

RE: [boost] Formal review: Optional library

2002-12-12 Thread Iain K.Hanson
> [mailto:[EMAIL PROTECTED]]On Behalf Of Iain K.Hanson > Sent: 12 December 2002 10:15 > To: 'Boost mailing list' > Subject: RE: [boost] Formal review: Optional library > > > > assert( a == b ) // pointer semantics. > if this used value semantics the

Re: [boost] Formal review: Optional library

2002-12-12 Thread Peter Dimov
From: "Fernando Cacciola" <[EMAIL PROTECTED]> > > Let me check if I followed your logic: > > optional opt(v) does a 'copy' of the 'v'; it does not hold onto the > 'v' itself as if it were given a handle. So it clearly has deep copy > semantics. > Your argument is that since it has deep copy semanti

Re: [boost] Formal review: Optional library

2002-12-12 Thread Fernando Cacciola
- Original Message - From: "Iain K.Hanson" <[EMAIL PROTECTED]> To: "'Boost mailing list'" <[EMAIL PROTECTED]> Sent: Thursday, December 12, 2002 8:20 AM Subject: RE: [boost] Formal review: Optional library > > > > [mailto:[EMAIL PROTE

Re: [boost] Formal review: Optional library

2002-12-12 Thread Fernando Cacciola
- Original Message - From: "Peter Dimov" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Thursday, December 12, 2002 9:41 AM Subject: Re: [boost] Formal review: Optional library > From: "Fernando Cacciola" <[EMAI

Re: [boost] Formal review: Optional library

2002-12-12 Thread William E. Kempf
Fernando Cacciola said: > From: "Peter Dimov" <[EMAIL PROTECTED]> >> From: "Fernando Cacciola" <[EMAIL PROTECTED]> >> > Perhaps this could be called get_pointer() as shared_ptr<> does. >> >> get_pointer() would be... less objectionable. :-) >> > This particular free function is precisely intended t

Re: [boost] Formal review: Optional library

2002-12-12 Thread Fernando Cacciola
- Original Message - From: "William E. Kempf" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, December 12, 2002 12:18 PM Subject: Re: [boost] Formal review: Optional library > Fernando Cacciola said: > > From: "Peter Dimov" <[EMA

Re: [boost] Formal review: Optional library

2002-12-12 Thread Peter Dimov
From: "Fernando Cacciola" <[EMAIL PROTECTED]> > > Yes, I thought about that, too. But if the current swap semantics are > > retained, it should simply be removed. Otherwise optional::swap must > > offer at least swap(T&, T&)'s guarantee. > > > I'm not sure I follow. > What are swap(T&, T&) guarante

Re: [boost] Formal review: Optional library

2002-12-12 Thread David Abrahams
"Peter Dimov" <[EMAIL PROTECTED]> writes: > From: "Fernando Cacciola" <[EMAIL PROTECTED]> >> > Yes, I thought about that, too. But if the current swap semantics are >> > retained, it should simply be removed. Otherwise optional::swap must >> > offer at least swap(T&, T&)'s guarantee. >> > >> I'm n

RE: [boost] Formal review: Optional library

2002-12-12 Thread Iain K.Hanson
> [mailto:[EMAIL PROTECTED]]On Behalf Of Peter Dimov > Optional does not have pointer semantics. Two optionals can > never alias each > other. "Consistent with pointer semantics" doesn't make > sense. Optional is > not a pointer. Don't try to make it into one; you'll arrive > at shared_ptr.

Re: [boost] Formal review: Optional library

2002-12-12 Thread Peter Dimov
From: "Iain K.Hanson" <[EMAIL PROTECTED]> > > :-) true. But it also does not have container semantics either. > I prefered your analogy with a special valued INT. Given that we > have > *opt1 == *opt2 > for ordinary value comparisons But this doesn't work when one of the optionals is uninitialized

RE: [boost] Formal review: Optional library

2002-12-12 Thread Iain K.Hanson
> [mailto:[EMAIL PROTECTED]]On Behalf Of Peter Dimov > Sent: 12 December 2002 17:09 > > From: "Iain K.Hanson" <[EMAIL PROTECTED]> > > > > :-) true. But it also does not have container semantics either. > > I prefered your analogy with a special valued INT. Given that we > > have > > *opt1 == *opt

Re: [boost] Formal review: Optional library

2002-12-12 Thread Peter Dimov
From: "Iain K.Hanson" <[EMAIL PROTECTED]> > > Given the above, I can't see the utility of defining rel-ops with container > semantics. I did not say that there is utility in the "equivalence" semantics (although they do make specifying and testing postconditions easier.) I am saying that these are

Re: [boost] Formal review: Optional library

2002-12-12 Thread David Abrahams
"Iain K.Hanson" <[EMAIL PROTECTED]> writes: >> [mailto:[EMAIL PROTECTED]]On Behalf Of Peter Dimov >> Sent: 12 December 2002 17:09 >> >> From: "Iain K.Hanson" <[EMAIL PROTECTED]> >> > >> > :-) true. But it also does not have container semantics either. >> > I prefered your analogy with a special va

Re: [boost] Formal review: Optional library

2002-12-12 Thread Fernando Cacciola
- Original Message - From: "Peter Dimov" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Thursday, December 12, 2002 1:00 PM Subject: Re: [boost] Formal review: Optional library > From: "Fernando Cacciola" <[EMAIL

RE: [boost] Formal review: Optional library

2002-12-12 Thread Iain K.Hanson
> [mailto:[EMAIL PROTECTED]]On Behalf Of David Abrahams > Sent: 12 December 2002 18:16 > >1. The contained value is part of the state. Pretending otherwise >just confuses everything. Whether it is initialised is orthaganal to its contained value. As Bill Kempf said "if it walks like a du

Re: [boost] Formal review: Optional library

2002-12-12 Thread David Abrahams
"Fernando Cacciola" <[EMAIL PROTECTED]> writes: > - Original Message - > From: "Peter Dimov" <[EMAIL PROTECTED]> > To: "Boost mailing list" <[EMAIL PROTECTED]> > Sent: Thursday, December 12, 2002 1:00 PM > Subject: Re:

Re: [boost] Formal review: Optional library

2002-12-12 Thread Peter Dimov
From: "Fernando Cacciola" <[EMAIL PROTECTED]> > From: "Peter Dimov" <[EMAIL PROTECTED]> > > True, swap()'s guarantees depend on the type. If T provides a > > nothrow/strong/basic swap, optional::swap should be at least > > nothrow/strong/basic, respectively. I think that this can be done provided >

Re: [boost] Formal review: Optional library

2002-12-12 Thread David Abrahams
"Iain K.Hanson" <[EMAIL PROTECTED]> writes: >> [mailto:[EMAIL PROTECTED]]On Behalf Of David Abrahams >> Sent: 12 December 2002 18:16 >> > >>1. The contained value is part of the state. Pretending otherwise >>just confuses everything. > > Whether it is initialised is orthaganal to its contai

RE: [boost] Formal review: Optional library

2002-12-12 Thread Iain K.Hanson
> [mailto:[EMAIL PROTECTED]]On Behalf Of David Abrahams > Sent: 12 December 2002 19:03 > >But it doesn't, really. If you're going to have deep constness and >deep assignment, the only thing remaining that makes it pointer-like >is the operator*/operator-> interface. At that point, it's just a

Re: [boost] Formal review: Optional library

2002-12-12 Thread Fernando Cacciola
- Original Message - From: "David Abrahams" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Thursday, December 12, 2002 3:45 PM Subject: Re: [boost] Formal review: Optional library > > > > In order to achieve this, I cons

Re: [boost] Formal review: Optional library

2002-12-12 Thread Fernando Cacciola
- Original Message - From: "Peter Dimov" <[EMAIL PROTECTED]> To: "Boost mailing list" <[EMAIL PROTECTED]> Sent: Thursday, December 12, 2002 3:59 PM Subject: Re: [boost] Formal review: Optional library > From: "Fernando Cacciola" <[E

Re: [boost] Formal review: Optional library

2002-12-12 Thread Peter Dimov
From: "Fernando Cacciola" <[EMAIL PROTECTED]> > From: "Peter Dimov" <[EMAIL PROTECTED]> [...] > > if(both uninitialized) > > { > > // do nothing, nothrow > > } > > else if(one initialized, one not) > > { > > lhs.reset(*rhs); // strong > > rhs.reset(); // nothrow > > } > > else // both initi

Re: [boost] Formal review: Optional library

2002-12-12 Thread William E. Kempf
Fernando Cacciola said: > From: "Peter Dimov" <[EMAIL PROTECTED]> >> From: "Fernando Cacciola" <[EMAIL PROTECTED]> >> > From: "Peter Dimov" <[EMAIL PROTECTED]> >> > optional<> is not intended to replace _all_ situations were optional >> values >> > are used. >> > It is itended to be used on those

Re: [boost] Formal review: Optional library

2002-12-12 Thread Peter Dimov
From: "Peter Dimov" <[EMAIL PROTECTED]> Oops, > Yes it will. :-) > > optional m; should have been optional m(t); > foo(m, m); // comparison inside yields false > > T * p; and this should have been T * p = &t; > foo(p, p); // comparison inside yields true _

Re: [boost] Formal review: Optional library

2002-12-12 Thread Fernando Cacciola
Due to some significant changes to the optional<> class, I had to upload a new version so that the review can continue based on the revised class. http://groups.yahoo.com/group/boost/files/optional.zip The new zip contains the new code, new test and new documentation. NOTE: The header optional_d

  1   2   >