Suggestion for C++ language extensions

  • Thread starter Ekkehard Morgenstern
  • Start date
E

Ekkehard Morgenstern

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.
 
V

Victor Bazarov

Ekkehard Morgenstern said:
I'd like to suggest the following features for future standards of the C++
programming language. [...]

Wrong newsgroup. Try comp.std.c++.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top