constness for arrays
Chad J
gamerChad at _spamIsBad_gmail.com
Tue Jul 18 21:57:12 PDT 2006
Andrew Fedoniouk wrote:
>
> If you will define it as
>
> alias array short[]
> {
> ...
> void someNewOp(self) { }
> }
>
> then 1) you can use this someNewOp with it and 2)
>
> void gimmeAnArray( short[] foo )
> {
> array bar = foo; // ok
> ...
> }
>
> Extended alias allows to extend base types.
> Extended typedef allows to extend and to reduce operations of base types.
>
> Andrew Fedoniouk.
> http://terrainformatica.com
>
I suppose that means I could do something like
alias array short[]
{
...
short[] opAdd( short[] other )
{
...
}
}
short[] gimmeAnArray( short[] foo )
{
short[] newArray;
for ( int i = 0; i < foo.length; i++ )
newArray ~= i;
return foo + newArray; // usage of extension on short[]
}
That would be cool. Though it would be nice if it didn't also stick an
"array" type out there (does it?). Is there anywhere I can find a
complete look at what you're proposing?
More information about the Digitalmars-d
mailing list