ufcs and integer params
Chris NS
ibisbasenji at gmail.com
Mon Jul 16 20:43:50 PDT 2012
On Monday, 16 July 2012 at 23:13:54 UTC, Timon Gehr wrote:
> On 07/16/2012 10:55 AM, Chris NS wrote:
>> Having been around long enough to remember when the ability to
>> call
>> "foo()" as "foo" first appeared, I feel it necessary to point
>> out that
>> this was *not* in fact a deliberate design, but rather a sort
>> of
>> "accident" that arose out of D's first attempt at properties.
>
> Afaik this first attempt was implemented roughly as designed.
> It is my
> understanding that @property was added later in order to fix the
> introduced ambiguities.
Effectively yes, this is why I put "accident" in quotes. The
accidental part was that it was inadvertently extended to
functions that it should not have been. Free functions, for
example, were not really supposed to be callable in that way...
it has turned out to sometimes be a nice and useful thing, of
course, but it wasn't exactly the goal at the time. The goal was
simply class/struct/union member functions that could be swapped
out for exposed fields, or vice versa, without any change in user
code.
>> It was the same "accident" loaded compiler release that gave
>> us pseudo-members --
>> the precursors to UFCS.
>>
>
> I still wonder how that could possibly happen.
You, me, and everyone else. I recall even Walter being a bit
surprised by it and reviewing his code afterward. The oddity was
identified, but at the same time (almost-) everyone rather liked
it and it stuck. At the time I was maintaining an extensive
library of array extensions, a spiritual ancestor to today's
std.algorithm and std.range. (None of that code is in Phobos,
mind you, but it served a similar purpose.) It was sort of like
finding a peppermint in an old coat pocket.
>
>> The community discovered that these things were accepted by
>> the compiler
>> -- which was actually against the language spec at the time --
>> and
>> further that the resulting code did the intuitively correct
>> thing.
>> Response to the "accidents" being generally positive, it was
>> decided to
>> work toward making them legitimate language features. Some
>> flavor of
>> @property (or of a certain other proposal which was a mimicry
>> of C#
>> properties... I was in that camp)
>
> That would certainly be more pretty -- OTOH it is hard to think
> of a
> way to extend this to UFCS that is as natural as what happens if
> everything is conflated in functions.
As I recall, that was essentially how the discussion went back
then, too. I still like the C# style, personally, but I've found
@property to be plenty usable, and even admittedly a bet more
terse.
>> has been in the plan ever since.
>>
>> I find the ongoing debate/discussion of @property and
>> -property to be...
>> well, moot. But hey, I'm just one crazy among an army of
>> crazies.
>>
>
> Well, this newsgroup has the property that the stuff that is
> actually
> important is usually unilaterally agreed upon rather quickly.
> :o)
Yeah... usually. ;) I rarely speak up anymore, since I just
don't have the time to commit to proving concepts and whatnot
anymore. "I'm old, Dean. So very old." I remember proposing a
foreach statement (opApply was Walter's idea, though). I also
remember the horror that was the 'instance' keyword... man do I
ever love that beautiful !() operator now, no matter what anyone
else says about it. Ultimately, I am quite satisfied with it
all, even if the occasional dead horse takes a beating. I just
find it strange that there's such heated debate over something
that had seemed so settled. Which, I suppose, might just be an
indicator that it isn't settled after all, eh?
-- Chris NS
More information about the Digitalmars-d-learn
mailing list