Reddit: why aren't people using D?
Bill Baxter
wbaxter at gmail.com
Fri Jul 24 12:29:35 PDT 2009
On Fri, Jul 24, 2009 at 12:21 PM, Steven
Schveighoffer<schveiguy at yahoo.com> wrote:
> On Fri, 24 Jul 2009 15:12:10 -0400, Ary Borenszweig <ary at esperanto.org.ar>
> wrote:
>
>> Maybe what scares Walter is a whole new syntax for properties. If at least
>> you could say which functions are properties and which are not, that would
>> be a small change and it'll make it possible for other things. Something
>> like:
>
> His point is that there are no benefits to the semantic meaning of the code
> by declaring something a property. It's still a function, still gets
> implemented by a function.
>
> It's like if you say functions can now be called like this:
>
> foo^arg
>
> But he's not getting that the compiler isn't the only one reading the code,
> and D isn't the only language being used. You are also using a person's
> knowledge of math (x = y) and a person's native language. At least the
> native language, the compiler knows and cares nothing about, but the
> developer and user care greatly (and want the conventions enforced).
Another example: arrays are just functions too. So there's no real
need for a distinct a[i] syntax. a(i) would work just fine (and is
exactly what's used in Fortran and Matlab for array indexing).
But we kind of like being able to see right away that something is
intended to be indexing. It give the reader of the code a hint about
the intended semantics. But of course the compiler can't enforce that
every opIndex overload conforms to that. You could write an opIndex
overload that prints to stdout. But generally people don't do that
because that would be sending the wrong signal. Generally the opIndex
overloads offer index-ing like behavior.
--bb
More information about the Digitalmars-d
mailing list