digitalmars.D - Constness Naming Proposal
- Chad J (36/36) Aug 25 2007 Perhaps we should name head constness and tail constness as such:
- Paul (45/59) Aug 25 2007 I kept nominating hconst for const(head) and tconst for const(tail) but ...
- Daniel Keep (9/9) Aug 25 2007 The problem is that they all mean (roughly) the same thing.
- Paul Anderson (3/17) Aug 25 2007 I wasn't seriously suggesting them -- but that is the heart of the probl...
- BCS (4/19) Aug 25 2007 how about for head const use "bound": the thing is permanently 'bound' t...
- Robert Fraser (4/17) Aug 25 2007 I'd love to have "stubborn" variables that refuse to change their type w...
- nobody (6/10) Aug 26 2007 Just rename them to:
Perhaps we should name head constness and tail constness as such: hiro = Head Is Read Only tiro = Tail Is Read Only Where "hiro" and "tiro" are new keywords for constness. These names are made to reflect the notions of constness presented in the "Future of D, Part 2" talk at the D conference. The only problem with it that I can think of is that the meanings of these algorithms aren't clear. To that, I say that nothing short of a very jargon laden sentence would give a clear meaning of this concept. The advantages: - Very unlikely these are used much as variable names, if at all. Almost no code refactoring for adding these keywords. - To newbies they should scream "Read the reference!" - Allows us to reserve "const" for things that are truly CONSTANT*. - Also not confusable with constant things (sorta same as above one). - You can also make other keywords from the paradigm, ex: biro = body is read only, airo = all is read only (or aaro?). - Short 4 characters, easy to type :) Remember this will likely be used a lot (here a const, there a const). * In the "Future of D, Part 2" talk there was also mention of functions that take constant parameters. The proposed syntax was like so: void foo( static int bar, int baz ) { // bar is a compile time constant, baz is runtime variable } If we freed up const from constness, we could have this: void foo( const int bar, int baz ) { ... } thus it is clear to non-C/C++ users that bar is constant. The C/C++ users will get compile time errors if they use it incorrectly; nothing too insane. Definitely worth it to drop the horrid "const" naming from C/C++ IMO. Another note on this use of abbreviation, for those of us who are like me and usually don't like obfuscated abbreviations at all: There is no english/technical word for constness. We are condensing a few sentences or paragraphs of technical writing and meaning into a keyword or two. We might as well make new words up.
Aug 25 2007
Chad J Wrote:Perhaps we should name head constness and tail constness as such: hiro = Head Is Read Only tiro = Tail Is Read Only Where "hiro" and "tiro" are new keywords for constness. These names are made to reflect the notions of constness presented in the "Future of D, Part 2" talk at the D conference.</snip>Another note on this use of abbreviation, for those of us who are like me and usually don't like obfuscated abbreviations at all: There is no english/technical word for constness. We are condensing a few sentences or paragraphs of technical writing and meaning into a keyword or two. We might as well make new words up.I kept nominating hconst for const(head) and tconst for const(tail) but I was unable to sway the discussion. BTW, the const(head) and const(tail) notation was Andre's -- it's very clear, just a little verbose. As for English words for constness, I made a list using a thesaurus. Plenty of words, although few are technical: Invariant Invariable Fixed Unvarying Inflexible Rigid Unremitting Persistent Dependable Consistent Irrevocable Definitive Absolute Unconditional Permanent Enduring Everlasting Eternal Stable Undeviating Durable Unwavering Established Steady Staunch Resolute Unswerving Faithful Trustworthy Loyal Trusted Obstinate Determined Resolved Rigid Stubborn Hardheaded Unyielding Intransigent Lots of words, some technical. I'm voting for 'resolute' for head const and 'intransigent' for tail const. paul dot d dot anderson at comcast dot net
Aug 25 2007
The problem is that they all mean (roughly) the same thing. I mean, *why* is 'resolute' head const whilst 'intransigent' tail const? I think the current words being used are fine since, let's face it, I don't think there *are* English words for "head is read-only" and "tail is read-only". In the end, we'll have to pick a set of words arbitrarily and *assign* them that meaning. const(head) and const(tail) wouldn't go down too well since, as Chad noted, they're too long and a pain to type. -- Daniel
Aug 25 2007
Daniel Keep Wrote:The problem is that they all mean (roughly) the same thing. I mean, *why* is 'resolute' head const whilst 'intransigent' tail const? I think the current words being used are fine since, let's face it, I don't think there *are* English words for "head is read-only" and "tail is read-only". In the end, we'll have to pick a set of words arbitrarily and *assign* them that meaning. const(head) and const(tail) wouldn't go down too well since, as Chad noted, they're too long and a pain to type. -- DanielI wasn't seriously suggesting them -- but that is the heart of the problem. When Walter and Andre first presented the head-const/tail-const slides they were using 'final' for one and 'const' for the other. I can't remember which was which, but that, again, is the problem. Paul
Aug 25 2007
Reply to Daniel,The problem is that they all mean (roughly) the same thing. I mean, *why* is 'resolute' head const whilst 'intransigent' tail const? I think the current words being used are fine since, let's face it, I don't think there *are* English words for "head is read-only" and "tail is read-only". In the end, we'll have to pick a set of words arbitrarily and *assign* them that meaning. const(head) and const(tail) wouldn't go down too well since, as Chad noted, they're too long and a pain to type. -- Danielhow about for head const use "bound": the thing is permanently 'bound' to something (but that something might not be const as for tail const... Don't know
Aug 25 2007
Chad J Wrote:hiro = Head Is Read Only tiro = Tail Is Read Only - Very unlikely these are used much as variable names, if at all. Almost no code refactoring for adding these keywords.I guess I'll have to scrap my idea for a Snow Crash game...Obstinate Determined Resolved Rigid Stubborn Hardheaded Unyielding IntransigentI'd love to have "stubborn" variables that refuse to change their type without it being cast away. All kidding aside, I think the way it is right now is arbitrary, but not that bad. "final" = head-const, const=tail-const, invariant=tail-invariant
Aug 25 2007
Chad J Wrote:Perhaps we should name head constness and tail constness as such: hiro = Head Is Read Only tiro = Tail Is Read OnlyJust rename them to: hiro = Head Is Read Only ando = Tail Is Read Only Every Heroes fan will know who uses the head and who follows the tail. Ja ja. {{{(>.<)}}} (o.o) \(^o^)/
Aug 26 2007