?

Log in

No account? Create an account
color cycle (slow)

Kistaro Windrider, Reptillian Situation Assessor

Unfortunately, I Really Am That Nerdy

Previous Entry Share Next Entry
On the pronunciation of C++ constructs
color cycle (slow)
kistaro
Something I was thinking about for no apparent reason was that my pronunciation of C++ operators and symbols, especially comparison operators, may not be entirely standard. (Especially my pronunciation of the not-equals operator, !=, as "ain't".) Most people figure out what I mean quite quickly, but I suspect- from quizzical looks I've gotten in the second between hearing and comprehension- that these aren't entirely standard.


=: equals
==: eqequals ("ee-keek-wulls")
<: less'n
<=: lequal
>: grat
>=: grequal
!=: ain't
(, [, {: paren, brack, curl
), ], }: unparen, unbrack, uncurl
*: star, times, deref, pointerto (okay, because I sound like I'm from Misourri because I am, "poinnerta")
#: thud
$: cash
\: backl ("backle", and I have no idea why)
/: over, or sometimes changes other pronunciation. Yes, I pronounce n/x as "n xths". Don't that just roll off the tongue?
//: slash-slash
%, +, -: mod, plus, minus
!: not, wham (sorta random which I use)
^: xor (weak X: "zor")
&: amp
&&: and
|: or
||: or (Interestingly, both sorts of or- bitwise and logical- get the same pronunciation. I'm not sure why I do that.)
~: wibble, weeble, or un- (as a prefix- the one's compliment of foo would be wibble foo, weeble foo, or unfoo)
<< shiffel, into (bit shift or iostream, respectively)
>> shiffer, outta
?, :: means, else (Makes more sense in context: x = a < b ? a : b; would be "x equals a less'n b means a, else b" which makes sense to me, anyway, as it half-explains what the trinary operator does. Note that ':' is silent when it's used as a label definition; it's only pronounced in the ?: operator.)
;: ... (Semicolons are silent. I do pronounce the code, however, as one would pronounce English words with a semicolon there!)
.: point (when in a double constant), dot (when the membership operator)
->: point
": strit, endstrit
': charlit (only first one pronounced- '0' is charlit zero, not charlit zero charlit)
'\0': nulxh (There's actually no letter that suffices where the "xh" is. Those of you who can pronounce baxil's name properly know what the ending should be, assuming that I'm pronouncing baxil's name properly. Sort of a cross between a 'k' and a German dude- like the "ch" in "Acht!".)


Programmers out there, for C++ or Java- what do y'all use? Not all of this applies to Java, but most of it still does.

  • 1
There are actually whole dictionaries of such.

Probably the ones that I mangle are

~: twiddle
#: pound
!: bang (but not usually in code; usually when referring to a Unix-y commmand)

And since when is $ a C/C++/Java operator?! :-P

That is *impressively* geeky. I must admit a bit of surprise, though, at the single pronunciation of the & operator given its multiple uses in the language - bitwise and, address-of, and reference variable declaration.

Also, when are you going to come out with your own speech-to-code utility?

My pronunciations of most of these things are woefully literal:

=: equals
==: equalsequals
[Error: Irreparable invalid markup ('<:>') in entry. Owner must fix manually. Raw contents below.]

That is *impressively* geeky. I must admit a bit of surprise, though, at the single pronunciation of the & operator given its multiple uses in the language - bitwise and, address-of, and reference variable declaration.

Also, when are you going to come out with your own speech-to-code utility?

My pronunciations of most of these things are woefully literal:

=: equals
==: equalsequals
<: less than
<=: less equal
>: greater than
>=: greater equal
!=: not equal
(, [, {: open paren, open bracket, open curly
), ], }: close paren, close bracket, close curly
*: star, times. I leave deref and pointerto out of my language because I assume somebody who has any capacity for understanding what I'm saying if I'm speaking code to them is going to get it in context. :)
#: pound
$: string. I'm dating myself here. And I also do not know where this operator is used in C++.
\: backslash
/: divided by, slash
//: slash slash
%, +, -: mod, plus, minus
!: not
^: xor (strong x: "eckzor")
&: bitwise-and, ref
&&: and
|: bitwise-or
||: or
~: tilde
<< left shift
>> right shift
?, :: I never use this operator, so at present it has no entry in my official C++ pronunciation guide. As "question mark" and "colon" are far too long to spit out around that, I would probably just call it "iif," pronounced "eye-if."
;: not pronounced
.: point (when in a double constant), dot (when the membership operator)
->: arrow
": quote
': single quote
'\0': null byte

$: string. I'm dating myself here. And I also do not know where this operator is used in C++.

It isn't. It is, however, used extensively in gvim, my editor of choice, as the general symbol for "end-of-line." I can't call it endl, as that's more than slightly ambiguous, so I take a more literal option.

As for your more normal term for << and >>, I consider myself to have a good reason to not use that. This is after the good laugh I had at James' expense at the ACM competition when, in the excitement, he prouounced << as "bitch shit lepf". It was then that it became truly apparent that my having a different pronunciation was probably a good plan.

For my verbal overload of the &... I'm not sure why, either. I used to use "ref" when appropriate, but then about half the people I talked to got confused as to why I was putting an asterisk there. So "amp" makes sure there's no confusion.

Mildly related - since you're obviously rather keen on the whole C++ thing, here's a fun little problem I ran into a while ago, thought you might enjoy solving it.

Implement the function:

int AddOne(int x)

Which returns, surprisingly enough, x + 1. The catch is that you are not allowed to use +, -, ++, --, or the inline assembly equivalents of any of these functions, anywhere in your code. Enjoy. :)

int addOne(int x){
   for(unsigned int k = 1; k > 0; k = k << 1){
      x = x^k;
      if(x & k) break;
   }
   return x;
}


I haven't tested that, but that aught to work correctly- including wraparound overflow- on a two's compliment machine.

It's probably not the most efficient way to do it, but it was the first way I thought of. It just hand-simulates the inital add, then the carries until it lands somewhere it can stop; since the if(x & k) occurs after the xor, it will be nonzero (and thus true) if and only if the original bit at the location "highlighted" by k was a zero (now a one).

Is my code correct?

I have no idea if the code is correct; I used a shifting recursion to solve it instead of using xor, but it operates on the same principles so I wouldn't be surprised if your code works too. Test it out?

Since ~x gives you maxint-x-1 = -x-1 (mod maxint), if you are allowed to use the unary - operator you can write
return -~x;

If you don't like having the - there, just observe that 0xffffffff = -1, so you can use multiplication with a positive number instead.
return ~x*0xffffffff;

Wow, one line, very nice. And I was thinking my recursion was clever. ;)

Actually, can you explain this? Two's complement arithmetic has always inexplicably fuddled me. Why is ~x == maxint - x - 1? Also, I would expect that negating the two's complement would just yield the number itself again, unless I'm not understanding how negation is implemented; is it a flip of the most significant bit, or just another internal two's complement?

~x toggles all the bits in x. For example ~00110111 = 11001000 if we're using 8 bit numbers. This means that each bit is set in either x or ~x, but not in both. So we have
x + ~x =
x | ~x =
11111111111111111111111111111111(base 2) =
2^32 - 1

Moving over the x you get that ~x = 2^32 - 1 - x, so -(~x) = x + 1 (mod 2^32).

I hope this clarifies the matter.

I'm a bit behind, heh

Yeah, it didn't occur to me that the ~ operator is just a binary inversion, not a two's complement. I also wasn't sure what exactly you meant by maxint originally - max unsigned, max positive, or all bits set to 1. maxint - x - 1 == -x - 1 (mod maxint) is still pretty brilliant in my freshly-humbled opinion, even though it seems pretty obvious now that you've pointed it out. :)

Perhaps, the letter χ would work for '\0' (i.e. nulχ). In modern Greek, it's pretty much an 'h' but back in the day it was more "-ch"-as-in-Bach ish.

=: equals
==: equals-equals
<: less than
<=: less than or {equal to, equals}
>: greater than
>=: greater than or {equal to, equals}
!=: {not equal to, doesn't equal}
(, [, {: open parenthesis, open bracket, open brace (They're braces on musical staves.)
), ], }: close parenthesis, close bracket, close brace
*: times, star (maybe even "asterisk" on occasion)
#: hash (or pound, when I forget about £: pound)
$: dollarsign
\: backslash
/: divided by, slash
//: slash-slash
%, +, -: mod, plus, minus
!: not
^: exor ("eck-zor")
&: and, ampersand
&&: and, ampersand-ampersand
|: or, pipe, bar
||: or, double-bar
~: tilde
<< less-than-less-than (even though that's not really the function)
>> more-than-more-than (It makes sense to me :))
?, :: (Uh... same if, then, else business of real if then and else)
;: Well, it's a semicolon, but I usually skip those.
.: point (for various floating-point numbers, unsurprisingly), dot (when the membership operator)
->: I would probably call it "arrow", were I ever to speak it. (Maybe even as "to" or "from" or "of", depending on the context...)
": quote, endquote
': single-quote
'\0': null (character)

I'm very much in favour of real English words. I can't say I typically go around reading code aloud, though. ...I wish there were an lj-cut for comments.

I didn't previously do a lot of verbal code reading, but then I joined the ACM team and it takes quite a bit of communication, so we had to develop some way we can understand each other. So that all sort of developed out of speed- speaking quickly yet intelligibly is a plus when in a sport involving three geeks freaking out over one computer. Although the "ain't" started out as a joke, but then I decided that there is no particular reason that != should not be "ain't" and it is, therefore, "ain't".

A general lack of real words- almost all of my terms are, if you will, reserved words- helps me. I can actually get slightly tripped up when trying to type or speak if I'm trying to express a symbol as a word that could be either- while I suspect knowing which is intended is automatic for most people, it's not for me, even if I know the only potential meaning is as a symbol. (It still has to be "cleared", if you will, with my concious.) Unique names let my subconcious do the work. Yes, I suspect this is related to my tendency to get tripped up in speech in general.

I do need to figure out something to separate | from ||, but I don't have any good ideas. My overloading of . and -> to "point" for both usually isn't a problem, although I do switch them more often than I should, so I'm seeking another word for that.

An amusing side effect of && as "and" is that I've had to stop myself from writing "&&" in the middle of a sentence. Actually, that happens with great regularity, and Dr. Wilburn noticed one that I scratched out and replaced with the correct word on my Present Moral Problems exam 2.

> Perhaps, the letter χ would work for '\0' (i.e. nulχ). In modern Greek, it's pretty much an 'h' but back in the day it was more "-ch"-as-in-Bach ish.

Yep. That's whence Baxil comes, as well.

  • 1