D dropped in favour of C# for PSP emulator

Manu turkeyman at gmail.com
Sat May 12 05:17:22 PDT 2012


On 12 May 2012 14:03, Jonathan M Davis <jmdavisProg at gmx.com> wrote:

> On Saturday, May 12, 2012 13:39:54 Manu wrote:
> > Awesome, although it doesn't end there. Local references are also very
> > important.
>
> Never going to happen. Walter doesn't like them (they also cause issues
> with
> the proposal to let ref take rvalues in D IMHO), but I don't remember the
> details. Regardless, I'd be shocked if they were ever introduced into D.
>

So what's the work around then?
Using pointers pollute your usage with pointer assignment problems,
and leads to many redundant instances of &, *, and parentheses all over the
place.

Another scenario to consider:
given: ref X someFunc();

ref X t = someFunc(); // fail

Without ref locals, there is no way to hold a local reference to something
returned by a function, which defeats the purpose...
And if ref is not a type constructor, auto and templates will never work
properly either.

Well, while I'm sure that your use cases are very important and may be
> normal
> in your industry, I don't think that they're normal in the programming
> world
> in general.


I've never met a C++ programmer (other than yourself apparently) that
doesn't pass structs/classes by ref.
That's generally considered absurd. And if you want evidence, just look at
the STL, Boost, or any other C++ library you care to pick.

Most programmers don't care one whit about registers. They want the
> compiler to be

effecient in what it does, but they don't usually worry about stuff like
> whether
> a particular variable will fit in a register or not.


That's true, and for that very reason, they were taught to ALWAYS use const
T& whenever passing any non-trivial type. I've never met a single
programmer who is an exception.
Universities teach this practise, books teach this practice, and every
major C++ library you can point at implements this practise.

This has nothing to do with my particular use case. I've never seen an
example of, or anyone advocating passing non-trivial data by value in C++.
One of my biggest criticisms of C++ is that people over-use ref's even in
the (rare) cases where they shouldn't (passing a single int/float by const
ref; relates back to my performance considerations), but that's certainly
far better/safer than passing everything by value all the time when used in
weak C++ templates (D could easily mitigate this problem).

If they were, languages like Java and C# would never have gotten
> anywhere in the first place. So, while D should definitely support what
> you're
> trying to do, it's not what the average programmer is trying to do. Most
> programmers don't care one whit about registers.They want the compiler to
> be

effecient in what it does, but they don't usually worry about stuff like
> whether

a particular variable will fit in a register or not.


They may not care, but the compiler does, and the compiler can't possibly
be efficient if it's being told to copy heaps of data around all over the
place.
There's nothing the compiler can do to magically make it go away, that's
why it's so important.

Java and C# only support my argument, they pass everything by ref all the
time, with the exception of C# structs, which behave exactly like in D. As
a result, they introduced 'ref' too, except it works as expected in all use
cases I presented above.
C# is the closest/best comparison here. C# is basically identical to D, but
with one exception, 'ref' works in all situations you expect.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120512/0c74629f/attachment.html>


More information about the Digitalmars-d mailing list