• 0 Posts
  • 17 Comments
Joined 9 months ago
cake
Cake day: March 12th, 2025

help-circle




  • The compiler should be able to optimize all of them to the same machine code.

    1. This is already good.
    2. Easily optimized by constant folding.
    3. This one depends on the semantics of signed underflow, so it may not do what you want.
    4. The loop can only exit if x==10, so as long as the nextInt() method doesn’t have side effects, the loop should be eliminated. But, again, language semantics can affect this.

    Edit: Very wrong for 3 & 4, see replies.


  • I meant the following:

    1. Find out the Debian package is too old
    2. Create Arch Live USB
    3. Boot Arch Live USB
    4. Copy GRUB config from the Debian install to the current Arch live system
    5. Install the up-to-date GRUB while in the Arch environment

    The bootloader installer package is distro dependent, the bootloader the package installs isn’t. You can boot Debian no matter if the GRUB is installed from Debian stable, Debian Sid, Arch, Fedora or even FreeBSD. Otherwise, dual booting wouldn’t work.

    Like I said, I’ve done that before, though with SystemD Boot instead of GRUB, which was a bit simpler due to how the bootloader is configured.



  • As it’s a bootloader, it should make almost no difference which distribution was used to install it. (I’m not sure if Debian patches their GRUB.) I just used Arch as an example, as it is famous for being up to date. And, no matter where it’s installed from, if you’ve made changes to GRUB’s configuration, you’ll have to copy it over to the live distribution to keep your changes.

    Yes, Debian Sid might be more familiar for Debian users, but that’s it.

    Edit: You said “get the grub debs from Debian sid”, but installing Sid packages on non-Sid systems isn’t something that you should do.




  • Lemmy is not GPLv2, but AGPLv3.

    So, the game would have to be (A)GPLv3. (The licenses are fairly interoperable. IIRC you can use AGPL components in GPL software if you abide by the terms of the AGPL.)

    Viral licenses are nice and all, but they’re not without their drawbacks. I caught GPL recently (the slightly rarer Affero v3 strain) and now no DNA testing companies want me as a customer. I can no longer write MIT or BSD licensed code. Whenever I open a project, a LICENSE file appears within ~15 minutes of contact. I hope to recover soon.




  • I hope that the language’s ints are at most 32 bits. For 8 bits it could even be written by hand & the source code for a 32 bit version would only take up avg_line_len * 4GiB space for the source code of the function. But it might take a bit of time to compile a version that supports the full range of 64 or 128 bit ints.



  • What’s disgusting about it? The only thing I can think of is the implicit return, which felt a bit icky at first.

    Also, as the if expression is an expression, you can call methods on it like so:

    if 1 > 2 {
        3
    } else {
        4
    }.min(5)
    

    (the above is still an expression, so it could be used, for example, as part of a condition for another if)

    Of course, you can write horrible code in any language, but the ability to use blocks where expressions are expected can be great sometimes.