Line numbers in code: useful or useless ?

Hi all,

I had a crazy idea: add a comment in my code with a “read code in line 12”. Then… I added two lines before that line 12 and line 12 became line 14.

In that case, line numbering is useless.

Of course, adding comments to code and publish (or send to co-worker…) that code can be useful… (until some line will be added as said above).

When you had hole punch cards it was.

If you’re communicating with any other person, at all, for any reason, line numbers are incredibly useful.
“To fix, change line 56 to…”

Or “look at line 24, does that look right?”

But referring to line numbers in comments? No.

I dont put line numbers in comment due to line numbers can change (you add/remove code).
but I do refer to code line numbers when talking to others.

Isn’t there a # button in the code editor to turn this on & off?

there is.

I only find the line numbers useful when doing IDE scripts and there is an error. Now the error messages just need to have the name of the scripts that throws the error…

Incredibly useful when communicating with others, either people or software.
Except for those who speak RegEx of course :slight_smile:
Not so much in comments.

We all agree, thank you all.

Ah…, Regex, the Vulcan mind-meld of Klingon and Greek in one language…

lugh qaH 

Klingon for “you are correct sir”