You could do a lot worse. If the type of i was an object, you could overload the negation operation to have side-effects for the third snippet, for example.
- 0 Posts
- 123 Comments
I don’t know what I was thinking.
But, if you borrow C’s semantics, you are allowed to “optimize” away side-effect-less loops, even if they would never terminate. But that would require the random method to be pure.
I feel like an idiot. Also, in the “Good” example, no underflow occurs. i goes from 0 to -10, and x is assigned to -i every loop.
It might still be possible to optimize away the random number example, if the random function were made a magic language item, but it would not be even remotely close to being worth the effort.
The compiler should be able to optimize all of them to the same machine code.
- This is already good.
- Easily optimized by constant folding.
This one depends on the semantics of signed underflow, so it may not do what you want.The loop can only exit ifx==10, so as long as thenextInt()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.
ferric_carcinization@lemmy.mlto
Asklemmy@lemmy.ml•Why do some people try to humanize the wealthy and people in positions of power?English
7·15 days agoDepends on your religion, I guess. The Flying Spaghetti Monster seems pretty edible.
one could argue this is a harmless way for people who suffer from this to get their fix.
I don’t know how many people get off from drawings. I think that AI-generated child porn might be better?
I’ve never understood the complaints about that. It’s not like real children are hurt by those drawings.
Also Ireland, Norway & Sweden.
ferric_carcinization@lemmy.mlto
Asklemmy@lemmy.ml•You have an unlimited budget to make the worlds first tactical umbrella. What does your umbrella do?English
4·2 months agoIf you make it amphibious and go fast enough, it will plane.
ferric_carcinization@lemmy.mlto
Open Source@lemmy.ml•Employment contract that allows for open source projects, advice neededEnglish
3·2 months ago- do not use ANY company resources. This could put you at risk of theft.
- do not do it on company time or make it look like it’s on company time. See point 2.
Did you mean “See point 1.”?
ferric_carcinization@lemmy.mlto
Open Source@lemmy.ml•Open source GZDoom community splinters after creator inserts AI-generated code - Ars TechnicaEnglish
4·2 months agoI mostly agree with you, but this is not quite true:
XDG implementation (which is also only used as a fallback when the three DE-specific implementations fail, even though all of them actually support XDG so having separate implementations is pointless)
Yes, the DE-specific implementations is pointless (as far as I know, I use a WM), but the XDG implementation is actually used first, and the function returns true if any impl returns true, like
xdg() || gnome() || gnome_old() || kde().rework the code so that there is a difference between “this DE wants light mode” and “couldn’t figure out of this DE is in light or dark mode” - both of these are now represented by the “false” return value.
This isn’t that bad? Yes, having an enum with three variants would be better and more readable, but the code just defaults to light mode if nothing wants dark mode, and prefers dark mode even if separate impls want both light and dark mode.
With multiple impls, you have to resolve conflicts somehow. You could, for example, match on current DE/WM name, only using the current DE’s impl, defaulting to XDG, avoiding the problem entirely or just use first impl that doesn’t return “default” or “error”.
I don’t like AI generated code, having reviewed some disgusting slop before. But it’s better to criticize the code’s actual faults, like the incorrect impls (which you listed) or failing the Linux CI.
ferric_carcinization@lemmy.mlto
Linux@lemmy.ml•Linux github repo is now a dating boardEnglish
9·3 months agoWhat about “I’ll accept your pull request if you accept my merge request”?
Their vision is based on movement, stay perfectly still.
You’re thinking of a different kind of predator. I don’t think that would work against sexual predators.
ferric_carcinization@lemmy.mlto
Asklemmy@lemmy.ml•What prevailing theory in scientific circles do you think is likely to be replaced with a new understanding by 2050?English
3·3 months agoThe theory of everything?
ferric_carcinization@lemmy.mlto
Linux@lemmy.ml•Debian, encrypted boot, how to increase password attempts?English
3·4 months agoI meant the following:
- Find out the Debian package is too old
- Create Arch Live USB
- Boot Arch Live USB
- Copy GRUB config from the Debian install to the current Arch live system
- 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.
emerge --ask cake ... [ebuild N ] dev-dotnet/cake-5.0.0 USE="-debug"Huh. Seems like Gentoo really has a cake recipe.
ferric_carcinization@lemmy.mlto
Linux@lemmy.ml•Debian, encrypted boot, how to increase password attempts?English
4·4 months agoAs 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.
ferric_carcinization@lemmy.mlto
Linux@lemmy.ml•Debian, encrypted boot, how to increase password attempts?English
5·4 months agoBut bootloaders are distro/OS agnostic. Why wait for Debian, when you could, for example, boot an Arch live ISO to install a newer GRUB?
I don’t use GRUB, but have done the same thing with SystemD Boot before. As GRUB’s configuration system is a bit more complex, you might have to mount your main install to get the correct config file.
ferric_carcinization@lemmy.mlto
Linux@lemmy.ml•[SOLVED] how come yt-dlp on a terminal returns bash: yt-dlp: command not found even though I installed it with wget? debian 13English
5·4 months agoUnlike Windows, on Linux you need to run
./<command>instead of just<command>for executables in you current directory.


If it were a magic lang item, you could treat the resulting value in a special way. Then, you could create an optimization pass for this situation: if a variable is assigned random in a loop and the loop can only be exited with a certain value, the compiler can coerce the magic rand value to it.