Topic: what is "convertible" ?
Author: markus.mauhart@nospamm.chello.at ("Markus Mauhart")
Date: Thu, 7 Nov 2002 02:29:47 +0000 (UTC) Raw View
The standard library, especially its tables, frequently
uses the term 'convertible' whithout more context than ..
(1) "expression e is convertible to bool" (very often)
(2) "expression e is convertible to type T" (often)
(3) "type U is convertible to type T" (often)
(4) "type Size is convertible to integral type (4.7,12.3)".
(2 or 3 times)
Does 'convertible' in (1-3) refer to ..
4., par 3: An expression e can be implicitly converted to a
type T if and only if the declaration "T t=e;" is wellformed,
for some invented temporary variable t (8.5).
... ?
Or what else ?
What about (4), "type Size is convertible to integral type (4.7,12.3)" ?
(4.7 is [conv.integral], "Integral conversions")
(12.3 is [class.conv], "Conversions", describing "user-defined conversions")
Does it mean that for (4) only combinations of "Integral conversions"
and "user-defined conversions" are allowed ?
Or is it equivalent to "type size is convertible to at least one integral type"
-> (3)
Or is it equivalent to "type size is convertible to any integral type".
-> (3)
Any help appreciated !
Markus.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: kuyper@wizard.net ("James Kuyper Jr.")
Date: Thu, 7 Nov 2002 03:50:52 +0000 (UTC) Raw View
Markus Mauhart wrote:
> The standard library, especially its tables, frequently
> uses the term 'convertible' whithout more context than ..
>
> (1) "expression e is convertible to bool" (very often)
>
> (2) "expression e is convertible to type T" (often)
>
> (3) "type U is convertible to type T" (often)
>
> (4) "type Size is convertible to integral type (4.7,12.3)".
> (2 or 3 times)
>
>
> Does 'convertible' in (1-3) refer to ..
>
> 4., par 3: An expression e can be implicitly converted to a
> type T if and only if the declaration "T t=e;" is wellformed,
> for some invented temporary variable t (8.5).
>
> ... ?
>
> Or what else ?
The standard defines "implicitly converted" in 4p3. It uses "converted"
with the adverbs "implicitly" and "explicitly", which implies that the
term "converted" without either adverb can refer to both types of
conversion. This would seem to imply that "convertible" includes both
"implicitly convertible" and "explicitly convertible". However, I'm not
sure that's what was actually intended. "implicitly convertible" seems
more appropriate in every context where the standard uses "convertible".
> What about (4), "type Size is convertible to integral type (4.7,12.3)" ?
> (4.7 is [conv.integral], "Integral conversions")
> (12.3 is [class.conv], "Conversions", describing "user-defined conversions")
> Does it mean that for (4) only combinations of "Integral conversions"
> and "user-defined conversions" are allowed ?
> Or is it equivalent to "type size is convertible to at least one integral type"
> -> (3)
> Or is it equivalent to "type size is convertible to any integral type".
> -> (3)
I would read that as "at least one" rather than "any".
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: markus.mauhart@nospamm.chello.at ("Markus Mauhart")
Date: Thu, 7 Nov 2002 17:50:50 +0000 (UTC) Raw View
"James Kuyper Jr." <kuyper@wizard.net> wrote ...
Thanks for your analysis !
> Markus Mauhart wrote:
> > The standard library, especially its tables, frequently
> > uses the term 'convertible' whithout more context than ..
> >
> > (1) "expression e is convertible to bool" (very often)
> >
> > (2) "expression e is convertible to type T" (often)
> >
> > (3) "type U is convertible to type T" (often)
> >
> > (4) "type Size is convertible to integral type (4.7,12.3)".
> > (2 or 3 times)
> >
> >
> > Does 'convertible' in (1-3) refer to ..
> >
> > 4., par 3: An expression e can be implicitly converted to a
> > type T if and only if the declaration "T t=e;" is wellformed,
> > for some invented temporary variable t (8.5).
> >
> > ... ?
> >
> > Or what else ?
>
> The standard defines "implicitly converted" in 4p3. It uses "converted"
> with the adverbs "implicitly" and "explicitly", which implies that the
> term "converted" without either adverb can refer to both types of
> conversion. This would seem to imply that "convertible" includes both
> "implicitly convertible" and "explicitly convertible". However, I'm not
> sure that's what was actually intended. "implicitly convertible" seems
> more appropriate in every context where the standard uses "convertible".
My reasoning was quite similar, but before I had (the pleasure ;-) to
spend hours with the standard.
Q: What is the relation between 'implicitly convertible' and 'explicitly
convertible' ? Or is this question irrelevant to stdc++ ?
Naive answer would be implicitely => explicitely. But actually I dont know
whether they are related, disjoint or overlap or even apply to the same
domain.
Try it with definitions:
* Expression e 'implicitly convertible' to type T
<=> T t = (e); is wellformed for some invented temporary variable t (8.5).
* Expression e 'explicitly convertible' to type T
<=> (T)(e); is wellformed (5.4).
(hope this is OK; are these now "my definitions" or "stdc++ definitions" ?)
Then both properties would apply to the same domain {(expression e,type T)},
and we'd have ..
implicitly(e,T)
<=> T t = (e);
=> T t = (T)(e); ????
=> (T)(e)
<=> explicitly(e,T)
> > What about (4), "type Size is convertible to integral type (4.7,12.3)" ?
> > (4.7 is [conv.integral], "Integral conversions")
> > (12.3 is [class.conv], "Conversions", describing "user-defined conversions")
> > Does it mean that for (4) only combinations of "Integral conversions"
> > and "user-defined conversions" are allowed ?
> > Or is it equivalent to "type size is convertible to at least one integral type"
> > -> (3)
> > Or is it equivalent to "type size is convertible to any integral type".
> > -> (3)
>
> I would read that as "at least one" rather than "any".
Does that mean that you would interpret "(4.7,12.3)" only as an informal
hint or note, cause the normative parts would be "convertible to"
+ "at least one/any" + "integral type[s]" ?
(and depending on 'convertible's interpretation, "at least one" and
"any" could be the same)
One addon to bool ..
> > (1) "expression e is convertible to bool" (very often)
... could also refer strictly to "[conv.bool] 4.12 Boolean conversions".
IMHO there is a need to move the knowledge about all that 'convertible'
from informal or oral history into the written standard;
(that was a request on all people currently feeling responsible for
some underspecified 'convertible' in the library)
Ideally the result would be one place in the core language (e.g. 4.0,
3.9; + index) introducing all the necessary terms, like ..
Type U/Expression e is [implicitly/explicitly] convertible to type T := ..
Usefull terminology not only for the library but also for other work.
Now back to ISO+IEC+14882-1998.pdf ...
Markus.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: kuyper@wizard.net ("James Kuyper Jr.")
Date: Fri, 8 Nov 2002 03:19:28 +0000 (UTC) Raw View
Markus Mauhart wrote:
> "James Kuyper Jr." <kuyper@wizard.net> wrote ...
....
>>Markus Mauhart wrote:
....
> Q: What is the relation between 'implicitly convertible' and 'explicitly
> convertible' ? Or is this question irrelevant to stdc++ ?
> Naive answer would be implicitely => explicitely. But actually I dont know
> whether they are related, disjoint or overlap or even apply to the same
> domain.
If one type is implicitly convertible to another type, it's certainly
explicitly convertible to that type.
> Try it with definitions:
> * Expression e 'implicitly convertible' to type T
> <=> T t = (e); is wellformed for some invented temporary variable t (8.5).
> * Expression e 'explicitly convertible' to type T
> <=> (T)(e); is wellformed (5.4).
> (hope this is OK; are these now "my definitions" or "stdc++ definitions" ?)
That's pretty much what I'd say. Except that I'd also include
dynamic_cast<T>(e) as another way a type can qualify as explicitly
convertible.
....
>>>What about (4), "type Size is convertible to integral type (4.7,12.3)" ?
>>>(4.7 is [conv.integral], "Integral conversions")
>>>(12.3 is [class.conv], "Conversions", describing "user-defined conversions")
>>>Does it mean that for (4) only combinations of "Integral conversions"
>>>and "user-defined conversions" are allowed ?
>>>Or is it equivalent to "type size is convertible to at least one integral type"
>>>-> (3)
>>>Or is it equivalent to "type size is convertible to any integral type".
>>>-> (3)
>>
>>I would read that as "at least one" rather than "any".
>
>
> Does that mean that you would interpret "(4.7,12.3)" only as an informal
> hint or note, cause the normative parts would be "convertible to"
I read "(4.7,12.3)" as a cross-reference to the relevant conversions,
and not as anything that directly affects the question of whether this
phrase means "at least one" or "any". I'm just using my
"well-read, well-educated, native speaker of English" skills to conclude
that it should mean "at least one". Unfortunately, those same skills tag
this as the kind of situation where reasonable people can disagree with
that conclusion.
....
>>>(1) "expression e is convertible to bool" (very often)
>>
> ... could also refer strictly to "[conv.bool] 4.12 Boolean conversions".
>
>
> IMHO there is a need to move the knowledge about all that 'convertible'
I think a type is "implicitly convertible" to another type, if the first
type can be "implicitly converted" (a term which is explicitly defined
in 4p3) to the second type.
I think a type is "convertible" to another type, if it can be converted
to that other type, and sections 4, 5.2, 5.4, and 12.3 define pretty
precisely what that means.
I don't think there's anything missing from the standard in this regard;
I just have a suspicion that the phrase "convertible" was often used in
the standard in contexts where what was actually meant was "implicitly
convertible". I can't confirm this suspicion, however, unless one of the
original authors cares to comment.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: markus.mauhart@nospamm.chello.at ("Markus Mauhart")
Date: Fri, 8 Nov 2002 15:25:41 +0000 (UTC) Raw View
"James Kuyper Jr."" <kuyper@wizard.net> wrote ...
>
> If one type is implicitly convertible to another type, it's certainly
> explicitly convertible to that type.
I hope so, but I'm not sure.
> > * Expression e 'explicitly convertible' to type T
> > <=> (T)(e); is wellformed (5.4).
>
> That's pretty much what I'd say. Except that I'd also include
> dynamic_cast<T>(e) as another way a type can qualify as explicitly
> convertible.
good point (also w.r.t. the previous question)
> > IMHO there is a need to move the knowledge about all that 'convertible'
>
> I think a type is "implicitly convertible" to another type, if the first
> type can be "implicitly converted" (a term which is explicitly defined
> in 4p3) to the second type.
> I think a type is "convertible" to another type, if it can be converted
> to that other type, and sections 4, 5.2, 5.4, and 12.3 define pretty
> precisely what that means.
>
> I don't think there's anything missing from the standard in this regard;
> I just have a suspicion that the phrase "convertible" was often used in
> the standard in contexts where what was actually meant was "implicitly
> convertible". I can't confirm this suspicion, however, unless one of the
> original authors cares to comment.
I fear we need comments from all authors, to be discussed with the
implementers of current libraries.
The resulting knowledge should be copied into stdc++, core or library;
like adding to [17 Library introduction] that 'convertible' generally
means 'implicitly convertible'.
That is as few as possible changes/additions, but enough to provide the
necessary term[s] to the library and any other library.
IMHO it is important enough to add a paragraph to the core, 3.9 Types
or 4.0 Std Conversions, and the index.
I'd be happy to donate my time and work, but with so many LWG experts
necessary for this issue I'm surely more than redundant.
Thanks,
Markus.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]