www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Does opSliceAssign exist?

reply AJG <AJG_member pathlink.com> writes:
I've seen it in some files on the web. However, I don't think it works.

Or at any rate, is there a way to overload the following?

MyObject[] = 5;

Thanks,
--AJG.
Sep 21 2005
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"AJG" <AJG_member pathlink.com> wrote in message 
news:dgtfk9$2h4q$1 digitaldaemon.com...
 I've seen it in some files on the web. However, I don't think it works.

 Or at any rate, is there a way to overload the following?

 MyObject[] = 5;

Nope. I asked the same question a couple months ago, but never really got a satisfactory answer (i.e. one from Walter ;) ). There's really no good reason that I can see for the omission. I would even be happy if instead of having an explicitly overloadable opSliceAssign, it would simply call opIndexAssign on the given range of elements, as most of the time, that's all the code for a custom opSliceAssign would be. However this would lead to sticky situations when you had, say, an opIndexAssign(char[] index); it's just not possible for the compiler to create a range such as a["fork".."knife"].
Sep 22 2005