Hello !

I for the first time write to this list of dispatch. I would
like to offer one expansion for C/C ++. It is quite well entered
in an existing design of language. This expansion increases
expressive power of language since preconditions for reduction
of a role of macros and patterns are created. For some schemes
in which it is necessary to carry out reductions of type to
appear more logical alternative design.

Now in essence. Some time back I did not like a situation with
asymmetry dereferencing fields of structure. I.e. absolutely
easily it is possible to receive the address of memory almost
any element in structure (except for a bit field), but reversed
transformation, i.e. to the address of a field to receive the
beginning of all structure, is essentially more complex
operation in which some assignments of types are made. Not
strict typification in this case can arouse a mistake in a
code. Reduction of type very frequent operation for structures
at which in the beginning of structure appears other, heading
structure.

The first offer concerns additions of a symmetric design
concerning syntax dereferencing an element. On an example
dereferencing "init_ptr = *load_ptr-> field;" I shall describe
reversed syntax.

Current syntax C/C++:

 load_ptr = typeof(load_ptr)(((char *)init_ptr) - \
              offsetof(typeof(init_ptr), field);

The offered syntax:

 &load_ptr->field = init_ptr;

Where `load_ptr' and `init_ptr' should be indexes. In the index
`load_ptr' the address of the beginning of structure
`typeof(load_ptr)` with which the field field is placed to the
address of which specifies `init_ptr' will be placed.

It is possible to combine with definition. The name of type is
added only:

 struct some_struct &load_ptr->field = init_ptr;
 load_ptr->field = val;

Definition is similar to existing syntax of definition in C++.
But nevertheless syntax, and operation (I mean similarity of
operation, that the symbol '&' is used to the left of a sign on
giving) differs:

Definition is similar to existing syntax of definition in C++.
But differs both syntax, and action of operation. I mean
similarity of operation, that the symbol '&' is used to the
left of a sign '=' on giving.

C++:
 struct some_struct &link = other;
 link.field = val;

Assignment:

 link1 = &load_ptr->field = link2 = init_ptr;

It should be interpreted from right to left:

 link2 = init_ptr;
 &load_ptr->field = init_ptr;
 link1 = init_ptr;

If it is necessary to receive the beginning of structure on
a field of other structure, enclosed in given these fields
are specified through a symbol of a point:

 &load_ptr->substruct1.substruct2.field = init_ptr;

Sense in that if simply to change places the right and left
parts of operation of giving we receive operation, reversed
given.

At a physical level operation "init_ptr = &load_ptr-> field;"
initializes a variable `init_ptr' which the beginnings of
structure are defined by an increment to `load_ptr' sizes of
shift of a field `field' concerning. Operation
"*load_ptr-> field = init_ptr;" defines `load_ptr' by
reduction `init_ptr' on size of shift of a field `field'
concerning the beginning of structure.

In my opinion, this opportunity will promote development of
procedural programming. In some cases will make unnecessary
use of dangerous assignment of type.

Quite probably that the similar offer appeared earlier. If
it so I ask me to excuse.

Thanks.

Reply via email to