Top 5
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Fri Oct 10 14:05:38 PDT 2008
Steven Schveighoffer wrote:
> "Andrei Alexandrescu" wrote
>>> typeof(d) == char[15]*
>> just char[15].
>
> What is the point of that? Why wouldn't you just say:
>
> char[15] d;
Only uniformity. In general Type() creates an instance of Type. Easy!
>> S * pS = allocate!(S)(... optional args ...);
>
> Ugh. How many extra 'wrapper' functions are built into the code because of
> this? I suppose it probably would be inlined.
Performance is not to worry about. allocate does only a call to
gc.allocate, the requisite initialization, and a cast. The cost of call
to gc.allocate dwarfs the call overhead even in absence of inlining.
> If new is abolished as a keyword, couldn't we use it instead of allocate?
>
> S * pS = new!(S)(...);
Yah. Just don't want to surprise anyone.
> The proposal makes sense, I'd be concerned that syntax like this is
> ambiguous:
>
> auto x = X();
> auto y = Y();
>
> You don't know if those are value or reference types, so you don't know how
> they are used. As opposed to:
>
> auto x = new X();
> auto y = Y();
>
> Where you see that x is a reference type.
>
> It might be more confusing to someone who cares about the value semantics.
That's a benefit in fact. Uniformity is good. Structs don't have value
semantics unless designed to, and that means you only count on value
semantics only when you know the type.
Andrei
More information about the Digitalmars-d
mailing list