change 'this' pointer for structs to reference type

Denis Koroskin 2korden at gmail.com
Sun Nov 2 11:27:01 PST 2008


On Sun, 02 Nov 2008 22:15:20 +0300, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Denis Koroskin:
>> I would drop the 'in' keyword altogether (opIn_r is horrible, imo).
>> I believe 'lookup' or 'find' methods are generally better.
>
> Okay, thank you all the people in this thread (Jarrett Billingsley too)  
> for helping me see things better.
> Dropping "in" for AAs? That's mad. Or making it return a boolean like in  
> Python? but D isn't Python. I don't want Python here, I already have  
> Python elsewhere.
>
> Removing something from D2 because of SafeD? What?  I don't like to  
> change D2 to suit SafeD (if safeD is wanted then you have to think of it  
> as another language with few differences, like the semantics of "in"  
> that returns a bool in safeD and returns a pointer in D2).
>
> Now I think "in" is fine as it is. I like pointers to refer to structs.  
> I like none of the proposed changes :-)
>
> The point of having a system language is to have a language that allows  
> me to be efficient, avoiding unnecessary AA lookups, and to use pointers  
> without doing strange things, and especially to have ways to control  
> memory exactly, so if I want a struct of 6 bytes I want it (D1 already  
> doesn't work fully this way, because the allocator allocates at powers  
> of two sizes and that's barely acceptable).
> If you make D2 become something different from a system language some  
> people will have to work hard to invent yet another language (D1? C2?)  
> to replace it.
> Pointers are dangerous, and I don't want to use them to use strings,  
> arrays, etc etc. But I don't like the idea of having to cast a struct  
> reference when I want to use them. Having control over how the memory is  
> used and how pointers are manages is probably the only real advantage  
> the D1 language has over Java (No, speed isn't an advantage, because you  
> can see that in practice HotSpot produces code that is often faster than  
> programs compiled with DMD for D1). So if you remove such things D2  
> becomes quite less useful.
>
> Bye,
> bearophile

It's just a matter of syntax. You don't loose an ability to use pointers,  
just make your lookup/find method return pointer (but what's the point of  
this?).



More information about the Digitalmars-d mailing list