[RC5] Golomb stuff/Void souls

Joe Zbiciak j-zbiciak1 at ti.com
Thu Mar 5 03:41:40 EST 1998

'Ryan Anderson' said previously:

| "With this word of power, I cast thy soul into the void: void(soul)"


| Anyone who truly
| knows, please respond and settle the question...

<BODY MODE="language lawyer">

Ok, I'm at home now, and I have a copy of _The C++ Programming
Language_, 2nd Ed., by Bjarne Stroustrup himself.  :-)  I'd hope it'd
be close to being a definitive reference.  :-)  Sure, the
standardization effort takes precedence, but I'd dare say Stroustrup is
pretty reliable.  (Notational note:  Words written /like this/ are in

>From section r.5.2.3, pg 495:

    r.5.2.3 Explicit Type Conversion

    A /simple-type-name/ followed by a parenthesized /expression-list/
    constructs a value of the specified type given in the expression
    list.  If the expression list specifies more than a single value,
    the type must be a class with a suitably declared constructor.

    A /simple-type-name/ followed by a (empty) pair of parentheses
    constructs a value of the specified type.  If the type is a class
    with a suitably declared constructor that constructor will be
    called; otherwise the result is an undefined value of the specified
    type.  See also Section r.5.4.

In layman's terms, typename(expression-list) peforms type conversion by
suitably calling the constructor for the resulting type.  This is not,
however, a cast.  Cast expressions are described in Section r.5.4.

>From section r.5.4, pg 500:

    r.5.4 Explicit Type Conversion

    An explicit type conversion can be expressed using either
    functional notation (r.5.2.3) or the /cast/ notation.

                ( /type-name/ ) /cast-expression/

    The /cast/ notation is needed to express conversion to a type that
    does not have a /simple-type-name/.


    Any type conversion not mentioned below and not explicitly defined
    by the user (r.12.3) is an error.

In other words,  (typename)expression is a cast, and it performs
explicit type conversion.  typename(expression) is the functional
notation for explicit type conversion, and it works only when typename
is a simple-type-name.  But, it is not a cast, insofar as "cast"
describes the old C style syntax.  The new syntax appears to exist to
support multi-argument constructors -- eg.  complex(x,y) might
construct an object of type "complex", accepting the values "x" and "y"
as the real and imaginary components.

So, to say you're "casting thy soul into the void", you'd need to write
it as "(void)soul".  The alternate syntax merely means you're
explicitly converting thy soul to void, which isn't nearly as
humorous.  :-)


 +----------- Joseph Zbiciak ----------+  Eliminate idle cycles!
 | - - - -  j-zbiciak1 at ti.com  - - - - |  http://www.distributed.net/
 |- http://www.primenet.com/~im14u2c/ -| 
 | - - -Texas Instruments, Dallas- - - |  "Give them a light, and they'll
 +-----#include "std_disclaimer.h"-----+   follow it anywhere." -- Firesign
To unsubscribe, send 'unsubscribe rc5' to majordomo at lists.distributed.net
rc5-digest subscribers replace rc5 with rc5-digest

More information about the rc5 mailing list