The D Programming Language (was: Still more new operators)

Mark Brader msb at sq.uucp
Sat Mar 5 11:43:25 AEST 1988


Dave Decot (decot at hpisod2.HP.COM) writes:
> Array first-class-ness and aggregate constants could be easily provided
> within C (not that I want to discourage D-zigners; it's a meritorious idea).
> 
> The basic ideas are that "a[]" is an array lvalue, and that aggregate
> constants are natively typeless and must always be either cast or assigned
> to the appropriate type.  Two examples follow.

The a[] syntax isn't needed, any more than you need a special syntax
for struct assignment.  Dave's first example revised:

    int thing(i, a, b)[2]
    int i, a[2], b[2];
    {
       int val[2];
	...
       return val;
    }

Since the type to be returned is int[2], the value "val" is left as an
int[2] type item and not converted to int *.

The one thing that would have to change, of course, is the present rule
that the formal parameter declaration int a[2] means int *a.  As I have
said before, this rule change could be introduced into the language along
with prototype syntax.

Mark Brader, utzoo!sq!msb, msb at sq.com		C unions never strike!



More information about the Comp.lang.c mailing list