Naming style poll: how do you capitalize identifiers?

Go down

Naming style poll: how do you capitalize identifiers?

· #1

Following the begin thread, a calmer question. How do you write your names?

Style Example
Pascal case CustomerCount
Camel case customerCount
All lowercase customercount
Shouting CUSTOMERCOUNT

Since Pascal doesn't care about case, all four are the same identifier. That's the fun part.

Re: Naming style poll: how do you capitalize identifiers?

· #2

Pascal case, because it's in the name of the language and I respect a hint.

Pete · thirty years of begin and end "It compiled on my machine."

Re: Naming style poll: how do you capitalize identifiers?

· #3

SHOUTING

obviously. sorry

SORRY ABOUT THE CAPS

Re: Naming style poll: how do you capitalize identifiers?

· #4

i AlTeRnAtE bEtWeEn UpPeR aNd LoWeR cAsE fOr EaCh LeTtEr

pascal
pRoGrAm HeLlO;
vAr
  cUsToMeRcOuNt: iNtEgEr;
bEgIn
  cUsToMeRcOuNt := 3;
  wRiTeLn('cUsToMeRs: ', CuStOmErCoUnT);
eNd.

iT cOmPiLeS. i ChEcKeD.

Re: Naming style poll: how do you capitalize identifiers?

· #5

I refuse to believe this compiles.

Re: Naming style poll: how do you capitalize identifiers?

· #6

It compiles. I tried it so nobody else has to.

text
Free Pascal Compiler version 3.3.1 for x86_64
Compiling hello.pas
Linking hello
7 lines compiled, 0.1 sec

Note that cUsToMeRcOuNt and CuStOmErCoUnT are spelled differently in the two places and the compiler still considers them the same variable. The language is working exactly as designed. I have never been less happy about that.

Re: Naming style poll: how do you capitalize identifiers?

· #7

As the newcomer: is this a thing people do, or is this a cry for help?

Re: Naming style poll: how do you capitalize identifiers?

· #8

iT iS a LiFeStYlE

Re: Naming style poll: how do you capitalize identifiers?

· #9

Useful lesson hiding in here, for anyone coming from C or JavaScript:

  • Count, count and COUNT are one identifier in Pascal.
  • You cannot have a variable customer and a type Customer. That's why types get a T in front: TCustomer.
  • String contents are still case-sensitive. 'Hello' = 'hello' is False. Use SameText when you want to ignore case.

Read the error message. Then read it again.

Re: Naming style poll: how do you capitalize identifiers?

· #10

does the alternating make it run faster

Re: Naming style poll: how do you capitalize identifiers?

· #11

yEs

Re: Naming style poll: how do you capitalize identifiers?

· #12

No.

demo_wave, I can't lock you, you haven't broken a rule. I checked twice. I'm adding one.

  1. Identifiers are written in a case a person would choose on purpose.

Carry on, everyone except demo_wave.

Forum rules 1 to 10 apply. Yes, to you.

Re: Naming style poll: how do you capitalize identifiers?

· #13

oK

Go up

Sign in to reply