www.digitalmars.com         C & C++   DMDScript  

D - array initialization in a strongly typed language

reply scott tara.mvdomain (Scott Robinson) writes:
The design of the language is very strongly typed. void x() being a
prominent example. (the lack of C/C++'s second 'void')

However, the syntax of a complete array initialization seems to break this
trend.

    array[] = 0x0;  // Fill an array with NULLs.

I wonder if an alternative is possible? I worked in languages previously
where, essentially, the syntax:

    array[0..array.length] = 0x0;  // Fill an array with NULLs.

could be shortened to:

    array[0..$] = 0x0;  // Fill an array with NULLs.

I wonder if something like the "$" symbol could be added to D...

Scott.

-- 
jabber:quad jabber.org         - Universal ID (www.jabber.org)
http://dsn.itgo.com/           - Personal webpage
robhome.dyndns.org             - Home firewall

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GAT dpu s: a--- C++ UL+++ P++ L+++ E- W++ N+ o+ K w
O M V- PS+ PE Y+ PGP+++ t++ 5 X R tv b++++ DI++++ D++
G+ e+ h! r- y
------END GEEK CODE BLOCK------
Aug 17 2001
parent "Walter" <walter digitalmars.com> writes:
It should be:
    array[] = null;


Scott Robinson wrote in message ...
The design of the language is very strongly typed. void x() being a
prominent example. (the lack of C/C++'s second 'void')

However, the syntax of a complete array initialization seems to break this
trend.

    array[] = 0x0;  // Fill an array with NULLs.

I wonder if an alternative is possible? I worked in languages previously
where, essentially, the syntax:

    array[0..array.length] = 0x0;  // Fill an array with NULLs.

could be shortened to:

    array[0..$] = 0x0;  // Fill an array with NULLs.

I wonder if something like the "$" symbol could be added to D...

Scott.

--
jabber:quad jabber.org         - Universal ID (www.jabber.org)
http://dsn.itgo.com/           - Personal webpage
robhome.dyndns.org             - Home firewall

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GAT dpu s: a--- C++ UL+++ P++ L+++ E- W++ N+ o+ K w
O M V- PS+ PE Y+ PGP+++ t++ 5 X R tv b++++ DI++++ D++
G+ e+ h! r- y
------END GEEK CODE BLOCK------
Aug 18 2001