?
=?iso-8859-2?B?SmFuIFJpbmdvuQ==?=
Hello everybody,
this is my first post to a newsgroup at all.
I would like to get some feedback on one proposal I am thinking about:
--- begin of proposal ---
Proposal to add
signed/unsigned modifier to class declarations
to next revision of C++ programming language
Abstract
This document describes proposed syntax that enable signed/unsigned
modifiers on base classes in order to allow signed/unsigned versions
of the same class with only minor behavioral changes. This will allow
much simpler implementation of advanced numeric classes that are about
to be accepted for TR1 (and TR2).
Semantics
The class can be declared either to be signed, to be unsigned or
none. When neither signed or unsigned is specified an signed/unsigned
specifier cannot be used to create an object.
When either signed nor unsigned modifier is used to create an object,
the default semantics is used (signed/unsigned specified in class
declaration).
Member functions can be specified to be either signed or unsigned or
none. This overloads the member function specificaly for signed or
unsigned version of the class. When none of these modifiers is used,
the method is available for both signed and unsigned types.
When only single member function, explicitly declared as signed or
unsigned is used, the other type cannot use this member function.
See Synatx.
When signed/unsigned specification is not used on the class declaration
the normal behavior retains. No member function can be declared
signed/unsigned and the class name cannot be used with signed/unsigned
modifier in order to create an object.
The signed/unsigned flexibility is not derived. Using modifier other
than default yields in different type.
Syntax
The class declaration is extended of _ability_ to specify it either
as signed or unsigned:
class C signed { ... };
or
class C unsigned { ... };
The object's methods then can be overloaded for signed or unsigned
version:
class C signed {
void M () signed;
void M () unsigned;
};
class C signed {
void M (); // the same as if "signed" was used here
void M () unsigned;
};
class C signed {
void M ();
void M () signed; // error: signed version already declared
};
class C signed {
void M (); // one version for both signed and unsigned
};
class C signed {
void M () unsigned; // unable to call M from signed type
};
class C signed {
void M () signed; // unable to call M from unsigned type
};
Object creation:
class C signed { ... };
C c; // the same type as "signed C c"
signed C c; // the same type as "C c"
unsigned C c; // has different type than "signed C c"
class C unsigned { ... };
C c; // the same type as "unsigned C c"
signed C c; // has different type than "unsigned C c"
unsigned C c; // the same type as "C c"
class C { ... };
C c;
signed C c; // syntax error
unsigned C c; // syntax error
Problems
None known. No problems with current conforming code is seen because
"signed" and "unsigned" are not allowed at proposed places.
--- end of proposal ---
I know that the terminology is not correct and that it would need a proper
wording, but this is just for initial consideration.
So what do you think? Is it worth trying to submit?
this is my first post to a newsgroup at all.
I would like to get some feedback on one proposal I am thinking about:
--- begin of proposal ---
Proposal to add
signed/unsigned modifier to class declarations
to next revision of C++ programming language
Abstract
This document describes proposed syntax that enable signed/unsigned
modifiers on base classes in order to allow signed/unsigned versions
of the same class with only minor behavioral changes. This will allow
much simpler implementation of advanced numeric classes that are about
to be accepted for TR1 (and TR2).
Semantics
The class can be declared either to be signed, to be unsigned or
none. When neither signed or unsigned is specified an signed/unsigned
specifier cannot be used to create an object.
When either signed nor unsigned modifier is used to create an object,
the default semantics is used (signed/unsigned specified in class
declaration).
Member functions can be specified to be either signed or unsigned or
none. This overloads the member function specificaly for signed or
unsigned version of the class. When none of these modifiers is used,
the method is available for both signed and unsigned types.
When only single member function, explicitly declared as signed or
unsigned is used, the other type cannot use this member function.
See Synatx.
When signed/unsigned specification is not used on the class declaration
the normal behavior retains. No member function can be declared
signed/unsigned and the class name cannot be used with signed/unsigned
modifier in order to create an object.
The signed/unsigned flexibility is not derived. Using modifier other
than default yields in different type.
Syntax
The class declaration is extended of _ability_ to specify it either
as signed or unsigned:
class C signed { ... };
or
class C unsigned { ... };
The object's methods then can be overloaded for signed or unsigned
version:
class C signed {
void M () signed;
void M () unsigned;
};
class C signed {
void M (); // the same as if "signed" was used here
void M () unsigned;
};
class C signed {
void M ();
void M () signed; // error: signed version already declared
};
class C signed {
void M (); // one version for both signed and unsigned
};
class C signed {
void M () unsigned; // unable to call M from signed type
};
class C signed {
void M () signed; // unable to call M from unsigned type
};
Object creation:
class C signed { ... };
C c; // the same type as "signed C c"
signed C c; // the same type as "C c"
unsigned C c; // has different type than "signed C c"
class C unsigned { ... };
C c; // the same type as "unsigned C c"
signed C c; // has different type than "unsigned C c"
unsigned C c; // the same type as "C c"
class C { ... };
C c;
signed C c; // syntax error
unsigned C c; // syntax error
Problems
None known. No problems with current conforming code is seen because
"signed" and "unsigned" are not allowed at proposed places.
--- end of proposal ---
I know that the terminology is not correct and that it would need a proper
wording, but this is just for initial consideration.
So what do you think? Is it worth trying to submit?