Please remove ?:

pragma pragma_member at pathlink.com
Fri Jun 2 10:06:53 PDT 2006


In article <e5pjto$1bdj$1 at digitaldaemon.com>, Lionello Lunesu says...
>
>It's sugar, nothing more. 

This is not entirely true.  The result of an if/else cannot be used as an
rvalue, whereas '?' can.  As it suits a very particular use scenario, it's no
more sugar than it is an alternate way to express if/else with this added
*advantage*. 

uint foobar = gorf() ? foo : bar;

-vs-

uint foobar;
if(gorf()){
foobar = foo;
}
else{
foobar = bar;
}

Being more direct and to the point leads to more readable and thus maintainable
code.  Its really a good thing to have, provided its used responsibly (as with
all of D's language constructs).

> D should be RISC :)

In principle, this is a grand idea.  It means easy compiler construction, and an
easy to understand language format.  Everybody wins, and there's no more debate
on what gets added to the language since simple is king - if anything, there's
debate on what should be taken out in favor of a more rudimentary syntax.

In practice it fails miserably*, since coders are *always* in the game of
creating shortcuts.  This is why we write libraries, adopt design principles
like encapsulation and OOP, and press for more concise ways to express common
idioms in the D language itself.  So we choose classes over structs
w/func-pointers and switch() over elaborate if/else statements where
appropriate, even though they're functionally equivalent.

We're also in the game of being very elaborate and "poetic" in a sense, in order
to achive some cosmetic or practical effect.  This is where templates, mixins
and interfaces help make library users' lives a little easier.

So ultimately you have all kinds of functional overlap in D *everywhere*,
because every bit of overlap is done with some additional features that cover
yet more use-cases and idioms.  Please understand that I'm not advocating that D
become this bloated monster mismash of features, but I hold onto the certainty
that there is a balance point that allows for some healthy redundancy.


*- Lisp is probably the only good example of a high-level language that has a
RISC philosophy to its design.  It also has some rather impressive achievements
under its belt but its anything but "widely used" when compared to C or Java.  I
still file it under the 'failed' category only for this reason: it hasn't
displaced other languages despite having been around for so long.  

- EricAnderton at yahoo



More information about the Digitalmars-d mailing list