Top-level constants (in a library or call function) would be uppercase as they are there to ensure capacity of use for the space they live in, and that . For instance, your create_deck( num_cards ) one would be better as a variable or simply a literal numeric value such as 52, 54, 128 or so on. Or it would be function called as a higher order function, eg
where it's a constant; but it really is only used for one task and could be replaced with a match statement. This just avoids allocations in inlined code.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I've never understood why constants should be uppercase? I see no valuable semantic difference between these two forms of code:
create_deck( num_cards )
create_deck( NUM_CARDS )
The second form adds a visual clutter which provides no useful information to the reader.
I'd agree - but I think the convention is so widespread that I'd be surprised if it wasn't followed. Principal of least astonishment and all that.
I've seen normal casing on constants used on many projects.
It's something that nobody would notice about, nor complain about. Nobody would miss the uppercase constants.
OK, you've convinced me! I'm removing it now as it's really not that important.
Top-level constants (in a library or call function) would be uppercase as they are there to ensure capacity of use for the space they live in, and that . For instance, your
create_deck( num_cards )
one would be better as a variable or simply a literal numeric value such as 52, 54, 128 or so on. Or it would be function called as a higher order function, egA better example would be
where it's a constant; but it really is only used for one task and could be replaced with a
match
statement. This just avoids allocations in inlined code.