Whence came UFCS?
Simen Kjærås
simen.kjaras at gmail.com
Fri Jul 27 11:24:22 UTC 2018
On Friday, 27 July 2018 at 10:30:07 UTC, Jonathan M Davis wrote:
> It evolved out of D's member function call syntax for arrays -
> basically, for years before we had UFCS in D, we had UFCS for
> arrays. However, when and how that was added to arrays, I don't
> know. I don't recall it ever not being in the language, but I
> never used D1, and I don't know if it had it. At minimum, it's
> been in D since early D2, if not much earlier. I'd have to do a
> lot of spelunking through old releases to figure out when it
> was added.
>
> Certainly, the origins of UFCS in D do not come from making it
> possible to extend user-defined types with member functions. It
> comes from wanting member function call syntax when using
> arrays (probably aimed primarily at strings, but I don't know).
> It's just that later it was proposed to extend it so that it
> would work with any type and thus make the member function call
> syntax universal.
This compiles in DMD 0.50 (oldest version on the download page,
nov 20, 2002), so I think it's safe to say it's been around for a
while:
void fun(int[] arr) {}
void main() {
int[] a;
a.fun();
}
Arrays' .reverse, .sort and others were added in 0.24, but I
can't find a download for anything before 0.50.
--
Simen
More information about the Digitalmars-d
mailing list