The International Simutrans Forum

 

Author Topic: Unification of CamelCase and snake_case in datfiles  (Read 596 times)

0 Members and 1 Guest are viewing this topic.

Offline Leartin

  • Oh no, not him again!
  • Devotee
  • *
  • Posts: 1573
  • PAK-DEV P192C
  • Languages: DE, EN
Unification of CamelCase and snake_case in datfiles
« on: February 06, 2021, 05:56:15 PM »
Writing the tutorial, it once again hits me how inconsistent Simutrans is in naming parameters. Most of the time, a parameter consisting of two words is just written as one word (eg. backimage) and since Simutrans doesn't care for case sensitivity in them, I usually see those written in CamelCase (eg. BackImage - each word starts with a capital letter). But there are some that use snake_case (eg. electricity_boost or has_snow, with underscores)

It's impossible by now to remove one of those two, as all kinds of dat-files would need to be rewritten. But I'm wondering if it might be beneficial if makeobj could just 'ignore' all underscores in parameters, just like it ignores uppercase letters (by turning them into lowercase), and we change all parameters with underscores to the same words without underscore internally. That is, make "has_snow" equal to "HasSnow" equal to "H_a_S_s_N_o_W", since makeobj would read them all just as "hassnow" anyway.

I know the benefit is minimal, but it just seems right to do it - a bit akin to translating German in the code. I only know how easy it would be to get makeobj to get rid of underscores and don't know how spread out the parameter definitions are in the code though.

Offline Isaac Eiland-Hall

  • Benevolent Dictator
  • Administrator
  • *
  • Posts: 3908
  • Providing hosting for Simutrans projects
    • pc2.io
  • Languages: EN
Re: Unification of CamelCase and snake_case in datfiles
« Reply #1 on: February 07, 2021, 05:08:11 AM »
Not that it is the slightest bit important to the discussion at hand… but camelCase is different from PascalCase. https://en.wikipedia.org/wiki/Camel_case :)

Offline Leartin

  • Oh no, not him again!
  • Devotee
  • *
  • Posts: 1573
  • PAK-DEV P192C
  • Languages: DE, EN
Re: Unification of CamelCase and snake_case in datfiles
« Reply #2 on: February 07, 2021, 06:44:21 AM »
Except the very article you link pretty much says that both PascalCase and dromedaryCase are (C/c)amelCase and only some people restrict camelCase to lower letter. Camels have two humps after all (unless they are dromedarys). Makes me wonder if some nerd calls it BactrianCamelCase xD

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10544
  • Languages: De,EN,JP
Re: Unification of CamelCase and snake_case in datfiles
« Reply #3 on: February 07, 2021, 12:58:01 PM »
Originally the pak64  text was backimage ... But ignoring underscores will require a new routine for string matching, which ignores underscores (and then replace all uses of the STRICMP in the writer routines, so it is not too big effort, just tedious.