DMD 0.170 release

Tom S h3r3tic at remove.mat.uni.torun.pl
Tue Oct 17 20:16:51 PDT 2006


Bill Baxter wrote:
>> Actually I meant foo.reverse. It compiles and runs fine on .169
> 
> Ok, sure it compiles, but if you're just going to reverse the array 
> in-place, then you don't need all that reverse__ stuff up there.  I'm 
> confused... :-?   But anyway the reverse__ stuff *is* what I was looking 
> to do and it does compile, too, and it does manage to iterate over the 
> array without modifying it.

Hey, I said I was sorry in a more recent post :P


> Any array type, or anything that has a .length property and overloads 
> opIndex, right?

Hmmm... yup, that should be enough



> Seriously?  Is there no way to write the function below so that the 
> program prints out the same value twice?
> 
> void print_addr( ??? arg )
> {
>    writefln(&arg);
> }
> 
> void main()
> {
>     int[] arr = [1,2,3,4,5];
>     writefln(&arr);
>     print_addr(arr);
> }

Sure it's possible, but in the earlier case, you were trying to access 
stack variables after returning from the function. In the same manner, 
'arg' is no longer a valid variable after print_addr returns, you'd be 
referencing junk on the stack. You could store it in a static variable, 
but I consider it hackish, as it's not thread safe :)



More information about the Digitalmars-d-announce mailing list