By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,654 Members | 936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,654 IT Pros & Developers. It's quick & easy.

Suggestion for C++ language extensions

P: n/a

Hi all,

I'd like to suggest the following features for future standards of the C++
programming language. I have not read the more recent standard documents, so
I'm not sure whether some are already in the standard, so tell me if so.

1. The addition of the BCPL valof (value of) expression syntax.
valof-expr := 'valof' type '{' statement-block '}' .
It would be notated like " int c = valof int { return 3+5; } "
2. The addition of at least standard headers, if not new types, for
bit-size-specific types, like "uint32_t".
3. The addition of optional range checking for standard array types.
array-dim-def := '[' expr [ 'range' [ expr '..' expr ]
'checked' ] ']' .
this could look like "int a[3 range checked 0..2]" or "int a[3
range checked]" for example.
4. The addition of dynamic arrays.
array-dim-def := '[' expr | 'dynamic' ']'
this could look like "int a[dynamic];"
5. The addition of optionally checked pointer types.
pointer-def := 'checked' type '*'; // or similar
this could look like "checked int* p;"
a pointer like this would be checked during runtime before usage
(like, at the first use in every block scope or something, or during every
operation).
6. The addition of value range checking for integral or floating-point base
types.
range-checked-base-type := [ 'range' [ expr '..' expr ]
'checked' ] base-type .
This could look like "range 0..2 checked int a;"
A check would be performed before every assignment to such a
variable.
A default range-checked variable, like "range checked int a;"
would be checked for overflows in arithmetic operations also.
7. The addition of an optional byte ordering syntax for integral or
floating-point base types.
ordered-base-type := [ ( 'msblsb' | 'lsbmsb' ) 'ordered' ]
base-type .
This would look like 'msblsb ordered int a = 0x12345678;'.
This would permit setting the byte ordering for structure
members, for example. The compiler would generate code to read and write
such variables properly, for example.
This way, reading and writing such fields from and to permanent
storage or streams would be a piece of cake without any programming
overhead.
8. The definition of anonymous classes.
class-decl := ( 'anonymous' 'class' | 'class' identifier )
class-decl-body .
this would look like "A* a = new anonymous class : public A {
.... }"
Constructors and destructors could use "anonymous()" then.

(I'll implement these features in my new Q2 (working title) programming
language, but it'd be great to find them in C++ as well.)

Regards,
Ekkehard Morgenstern.
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Ekkehard Morgenstern" <ek******************@onlinehome.de> wrote...
I'd like to suggest the following features for future standards of the C++
programming language. [...]


Wrong newsgroup. Try comp.std.c++.
Jul 19 '05 #2

P: n/a

Hi Victor Bazarov,

"Victor Bazarov" <v.********@comAcast.net> schrieb im Newsbeitrag
news:Zkctb.148496$mZ5.1009847@attbi_s54...
Wrong newsgroup. Try comp.std.c++.


Thanks! :-)

Regards,
Ekkehard Morgenstern.
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.