On Friday, 8 July 2016 at 20:57:39 UTC, Walter Bright wrote:
On 7/7/2016 7:25 PM, Andrew Godfrey wrote:
"static" is a terribly non-descriptive name

That's why it's the go-to keyword for any functionality we can't think of a good name for, or if the name would be too long such as "launch_nucular_missiles".

For a moment I thought Walter was being comical. But then I looked at the Index in TDPL, and I see static class constructor, static class destructor, static if, static import, static this, and just plain static.

Also, Andrei, if you're listening, I've spotted another TDPL errata. On page 459, the Index entry for "static, obligatory joke about overuse of" lists page 345, but in fact the joke is in the footnote at the bottom
of page 68.

As for me, the main thing I dislike about static if is that it blends in visually a bit too well with run-time code segments. C's #if structure
has its own problems, but I like the distinctiveness.

An earlier comment about wanting a different name got me to thinking. For naming variables, I own two copies of a high-quality thesaurus. One copy I keep at work, one copy I keep at home. It's invaluable when you get stuck at naming things. Why not apply that same tool to naming keywords as well? So I looked. I didn't see anything precisely on
target; maybe these come closest:

    constant if
    durable if
    persistent if
    adamant if
    unalterable if
    immutable if

Okay, that last one is a joke, considering that we're talking about keyword overloading. But the effort did spark some other brain cells
to fire.  So we could have had any of these:

    exactly if
    strictly if
    only if

I do like the creative use of an adverb instead of an adjective in these choices; the code reads like standard English instead of a clunky made-up phrase. I also especially like the briefness and precision of "only if", and that may become my favorite way to think about this in the future. (Is there some way I can "#define only static" to get this effect?) In fact, it is presaged on page 48 of TDPL, from whence I quote: "the basic plot is simple -- static if evaluates a compile-time expression and compiles the controlled statement only if the expression is true". So you the language designers had the idea in hand, but then sadly overlooked it.

Reply via email to