Author Topic: Don't exit on losing all lemmings (feature development)  (Read 6590 times)

Proxima and 2 Guests are viewing this topic.

Online Simon

  • Administrator
  • Posts: 3897
    • View Profile
    • Lix
Re: Don't exit on losing all lemmings (feature development)
« Reply #120 on: May 13, 2024, 05:11:04 PM »
I'm sitting in Mumble. Join anytime.

BRB in 20 minutes (17:30 UTC). Back.

-- Simon
« Last Edit: May 13, 2024, 05:34:08 PM by Simon »

Offline Dullstar

  • Posts: 2094
    • View Profile
    • Leafwing Studios Website (EXTREMELY OUTDATED)
Re: Don't exit on losing all lemmings (feature development)
« Reply #121 on: May 13, 2024, 07:55:33 PM »
I understand your desire for the singular option, but there are benefits to keeping them separate (and, identified by strings rather than numbers). My instinct on this one is, let's keep it as it is at least for now.

I agree with Simon here regarding the use of an enum. There *should* always be one and exactly one of the options active, but an enum will consistently enforce it across the entire codebase. Even if everything's correct now, this has maintenance benefits long-term. It shows that it's intended that exactly one of the options is true, and you won't have to worry about any bad behavior as a result of attempting to run multiple options at once (sure, maybe setting them all to true doesn't misbehave for now... until some other change happens and it no longer gets handled gracefully but nobody checked).

You can still identify them with strings in the options file, and the enum values have names so it's not like you need to remember that "OptionA" is 0, "OptionB" is 1... keeping track of that is the compiler's responsibility.

Offline WillLem

  • Posts: 3458
  • Unity isn't sameness, it's togetherness
    • View Profile
Re: Don't exit on losing all lemmings (feature development)
« Reply #122 on: May 13, 2024, 09:58:26 PM »
I'm sitting in Mumble. Join anytime.

Hi Simon, I've ended up being super busy this evening with IRL stuff. If you're free another evening this week I'll make sure to get it in the calendar. I could try to do the PR by myself, but would much prefer to do it with your guidance.

I agree with Simon here regarding the use of an enum. There *should* always be one and exactly one of the options active, but an enum will consistently enforce it across the entire codebase. Even if everything's correct now, this has maintenance benefits long-term.

OK, I'll give it a try. Can't promise anything, because I currently have no idea what an enum is, let alone how it works or how to properly implement it. With that said, lack of prior knowledge hasn't exactly stopped me so far ;P

I'll aim to get something done before Simon and I next meet.

Online Simon

  • Administrator
  • Posts: 3897
    • View Profile
    • Lix
Re: Don't exit on losing all lemmings (feature development)
« Reply #123 on: May 13, 2024, 10:42:22 PM »
All right, leaving Mumble and going to bed.

another evening this week I'll make sure to get it in the calendar.

Wednesday, 16th, from 16:00 UTC is good. I'll have time until 21:00 UTC. Please choose a definite starting time beforehand, and I'll confirm it.

-- Simon

Offline Dullstar

  • Posts: 2094
    • View Profile
    • Leafwing Studios Website (EXTREMELY OUTDATED)
Re: Don't exit on losing all lemmings (feature development)
« Reply #124 on: May 14, 2024, 04:47:31 AM »
OK, I'll give it a try. Can't promise anything, because I currently have no idea what an enum is, let alone how it works or how to properly implement it. With that said, lack of prior knowledge hasn't exactly stopped me so far ;P

The syntax will of course vary by language, but I think an example will be the easiest way to show it:

Note that this example isn't Delphi, as it's not a language I've worked with. This is more about the concept of enums in general, not how to write them in your language of choice.
Code: [Select]
enum Colors
{
    Red,
    Orange,
    Yellow,
    Green,
    Blue,
    Purple
}

Basically we've just created a new type* that can only hold these values**. Internally, they're probably just ints where Red = 0, Orange = 1... Purple = 5, but code that wants a Color doesn't need to care about that. When saving/loading from a file, we can convert them to/from strings as needed; some languages offer features to do this automatically, but if not, well, if we had to do some if/else to read/write anyway without the enums, we can do it with enums too. Many languages allow you to explicitly choose an underlying type and assign your own values, but there will usually be sensible defaults.

*Well, symbolically anyway. Languages vary in whether their type system considers enums to be different from their underlying types.

**Among languages that consider it to be a separate type, they also vary in whether or not you can force it to convert a value from the underlying type to the enum type even if that value isn't part of the enum, but fortunately in many (most?) languages it's difficult to do this accidentally.


---

Well, there's also the somewhat more complex Rust enums which basically merge unions and enums into one feature, but let's not worry about those.

Online Simon

  • Administrator
  • Posts: 3897
    • View Profile
    • Lix
Re: Don't exit on losing all lemmings (feature development)
« Reply #125 on: May 14, 2024, 10:39:54 AM »
what an enum is

Like a Boolean, but with 3 values instead of 2 (true, false), and you get to name the 3 values yourself.

https://en.wikibooks.org/wiki/Pascal_Programming/Enumerations#Declaration

-- Simon

Offline WillLem

  • Posts: 3458
  • Unity isn't sameness, it's togetherness
    • View Profile
Re: Don't exit on losing all lemmings (feature development)
« Reply #126 on: May 14, 2024, 03:26:40 PM »
Wednesday, 16th, from 16:00 UTC is good. I'll have time until 21:00 UTC. Please choose a definite starting time beforehand, and I'll confirm it.

I assume you mean Weds 15th? I should be able to make 1900 GMT (so, 1800 UTC?) that day, possibly even earlier. I've added it to the calendar. W

Online Simon

  • Administrator
  • Posts: 3897
    • View Profile
    • Lix
Re: Don't exit on losing all lemmings (feature development)
« Reply #127 on: May 14, 2024, 06:46:50 PM »
Yes, Wednesday, 15th, not 16th, sorry. All right, 18:00 UTC it is, i.e., 19:00 English daylight savings.

See you tomorrow!

-- Simon

Offline WillLem

  • Posts: 3458
  • Unity isn't sameness, it's togetherness
    • View Profile
Re: Don't exit on losing all lemmings (feature development)
« Reply #128 on: May 14, 2024, 09:46:50 PM »
Yes, Wednesday, 15th ... 18:00 UTC it is, i.e., 19:00 English daylight savings.

See you tomorrow!

Confirmed, see you then! :lemcat:

Offline WillLem

  • Posts: 3458
  • Unity isn't sameness, it's togetherness
    • View Profile
Re: Don't exit on losing all lemmings (feature development)
« Reply #129 on: Today at 07:22:04 PM »
NL 12.13 Exp V8 (commit a9709ba)