Does D really need something like const&?
deadalnix
deadalnix at gmail.com
Sat Mar 2 01:14:49 PST 2013
On Saturday, 2 March 2013 at 08:56:04 UTC, Namespace wrote:
> On Saturday, 2 March 2013 at 00:49:55 UTC, Era Scarecrow wrote:
>> If 'auto ref' gets accepted for non-template functions, it
>> goes away. With M as you show, returning ref doesn't work so
>> that example I was going to suggest doesn't work.
>
> auto ref will in all probability never work for non-template
> functions, as I said before.
>
> Steven Schveighoffer:
> I understand, that you like to have rvalue references for
> structs but I still don't understand why.
> Despite yesterday's discussion, I still do not understand the
> reason to use a struct instead of a class, when it comes to a
> massive amount of data.
> structs are copied or moved, structs have no polymorphism and
> no interfaces, so why you should use a struct instead of a
> class, if your struct is very massive? I don't get it.
1/ Generic code. You may not know that the data are big after
starting conglomerating more and more stuff.
2/ Data may be small, but with an expensive copy mecanism.
3/ A class would require to create the proper routines to
duplicate itself.
4/ Classes imply indirections. Which may be a problem (think
about array of such item for instance).
5/ Value type have great benefice in regard to the GC. LRU cache
is a very good way to kill Java's GC, because it generate plenty
of old garbages. The same thing in C# using value types don't
cause that much GC trashing.
And I can go on and on.
More information about the Digitalmars-d
mailing list