properties

Bill Baxter wbaxter at gmail.com
Tue Jul 28 10:51:11 PDT 2009


On Tue, Jul 28, 2009 at 10:20 AM, Steven
Schveighoffer<schveiguy at yahoo.com> wrote:
> On Tue, 28 Jul 2009 12:30:00 -0400, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>
>> Steven Schveighoffer wrote:

> What if the compiler allowed you to call functions as long as what you
> typed was an unambiguous prefix of the function name
> why don't we have a
> wonderful time-saving feature like this?  Because it would be a nightmare to
> read.
...
>> So now C# has two ways of providing a readonly field. Doesn't quite look
>> like an example to follow.
>
> Just like D!
>
> Yes, that's right.  readonly is analogous to const.
...
>> That's what I'm saying: if it could do anything, at least don't pretend
>> it's anything special. It's a function!
> ...
>  So would you argue that C# or D with operator overloading isn't
> better because operators are just functions, why call them something else?


Bravo!  Fine, rational arguments, Steve.


>>>> Well maybe you could change TimeSpan.
>>>
>>>  Lovely.  Force the developer to rename his functions because D is too
>>> weak to allow defining a correct interface.
>>
>> Or maybe because her use of name was too ambiguous.
>
> I want to use the parentheses or lack thereof as part of the human meaning
> for the function/property.  Making them optional means I can't do that.

I think Andrei's right here.
.seconds() really was too ambiguous a name to begin with.   Even if we
had properties I would be inclined to think that was just something
you forgot to mark as a property because a property-like meaning is
all that makes sense to me.   The meaning of .fromSeconds() is much
more obvious.

The example of adjectives or nouns that are also verbs is much better
--- .empty  vs .empty().    Others that come to mind:  clean, dirty,
end, begin.  (begin isn't really a noun but it's been used that way
for so long in STL that C++ people think of it as a synonym for
"beginning".)


--bb



More information about the Digitalmars-d mailing list