DMD 0.177 release
Chris Miller
chris at dprogramming.com
Wed Dec 13 09:21:37 PST 2006
On Wed, 13 Dec 2006 12:02:37 -0500, Jarrett Billingsley
<kb3ctd2 at yahoo.com> wrote:
> "Walter Bright" <newshound at digitalmars.com> wrote in message
> news:elnv14$r2d$1 at digitaldaemon.com...
>
>> For whatever the merits of opCall vs this(), efficiency is NOT a problem
>> with either, and is not a reason to choose one or the other. The
>> generated
>> code is the same.
>>
>> Under the hood, they are the same. Both take a hidden pointer to where
>> the
>> result is stored. The rest is window dressing.
>
> Alright then. All I've got then is the orthogonality argument. But you
> won't listen to that either.
>
> People will come to D from C++ and C# and ask "where are constructors in
> structs?" and we'll say "you have to use static opCall." And they'll ask
> "why?" And all we'll be able to do is shake our heads, sigh, and say "I
> don't know."
>
> For the last time, even though you don't care: we have been using static
> opCall as a WORKAROUND. As in *we never intended for that to be the
> canonical method of constructing a struct*. I don't think anyone would
> complain if they were given a consistent, logical method of initializing
> any
> aggregate type.
>
For the record, I'm fine with static opCall. Structs don't have
constructors and destructors, but the language just so happens to allow us
to have something that looks like a constructor. We could use Foo.create()
to initialize new Foo`s but since opCall is available and looks nice to
us, we can go with it. If opCall didn't exist, would we even be having
this argument? We would know structs weren't meant to have true
constructors and destructors. We have an aesthetically pleasing way to
initialize structs, so what's the problem. If your friend asks if structs
have constructors, you say no, but since the langauge is so expressive,
you have this feature called opCall that makes it just as nice to
initialize.
P.S. I actually don't want a defensive response to this, I'm just stating
my view; thanks.
More information about the Digitalmars-d-announce
mailing list