Opened 17 months ago

Last modified 17 months ago

#26184 new task

Think about using `const` as much as possible in Torbutton code

Reported by: gk Owned by: tbb-team
Priority: Medium Milestone:
Component: Applications/Tor Browser Version:
Severity: Normal Keywords: tbb-torbutton
Cc: igt0, arthuredelstein Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


While working on #24309, the idea got brought up to use const as much as possible in Torbutton code (see: for an actual patch for the circuit display).

We should summarize the pros and cons for this idea and then make a decision on what to do and do it.

Child Tickets

Change History (2)

comment:1 Changed 17 months ago by mcs

I am not sure if we should use const everywhere we can. Is Mozilla doing this? Here is an article that makes for interesting reading; especially look at the "Liberal let" and "Constantly const" sections:

What to do probably comes down to personal preference, but as a team it would be good to adopt some guidelines.

Last edited 17 months ago by mcs (previous) (diff)

comment:2 Changed 17 months ago by igt0

Hi I also like this article (TL;DR const doesn't allow rebinding [it is not about immutability]).

I agree with mcs about in the end the technical advantages are small, however for new contributors it reduces the cognitive load, because they know that variable will not change in that scope.

E.g Every time I see a let in the beginning of the file, I assume that variable can change and it can be undefined or null!

Note: See TracTickets for help on using tickets.