D Beginner Trying Manual Memory Management
jmh530 via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jan 12 15:06:16 PST 2015
I had seen some stuff on alias thing, but I hadn't bothered to
try to understand it until now. If I'm understanding the first
example <a href="http://dlang.org/class.html#AliasThis">here</a>,
alias this let's you refer to x in s by writing either s.x (as
normally) or just s. That didn't seem that interesting, but then
I found <a href="http://3d.benjamin-thaut.de/?p=90">example</a>
where they alias this'ed a struct method. That's pretty
interesting.
OOP seems like a good idea, but every time I've written a bunch
of classes in C++ or Python, I inevitably wonder to myself why I
just spent 5 times as long doing something I could do with
functions. Then there's endless discussion about pimpl.
On Monday, 12 January 2015 at 21:54:51 UTC, ketmar via
Digitalmars-d-learn wrote:
> On Mon, 12 Jan 2015 21:37:27 +0000
> aldanor via Digitalmars-d-learn
> <digitalmars-d-learn at puremagic.com>
> wrote:
>
>> On Monday, 12 January 2015 at 20:30:45 UTC, ketmar via
>> Digitalmars-d-learn wrote:
>> > it even has `RefCounted!`, but it doesn't play well with
>> > classes yet
>> > (AFAIR).
>> I wonder if it's possible to somehow make a version of
>> refcounted that would work with classes (even if
>> limited/restricted in some certain ways), or is it just
>> technically impossible because of reference semantics?
> it's hard. especially hard when you considering inheritance
> (which is
> not playing well with templates) and yes, ref semantics.
>
> on the other side i found myself rarely using classes at all. i
> mostly
> writing templates that checks if a passed "thing" has all the
> neccessary methods and properties in place and just using that.
> with D
> metaprogramming abilities (and `alias this` trick ;-)
> inheritance
> becomes not so important. and so classes too. sometimes i'm
> using
> structs with delegate fields to simulate some sort of "virtual
> methods"
> 'cause i tend to constantly forgetting about that `class`
> thingy. ;-)
>
> OOP is overrated. at least c++-like (should i say
> "simula-like"?)
> OOP. ;-)
More information about the Digitalmars-d-learn
mailing list