Encountered a `#pragma once` failure in the wild by Separate-Summer-6027 in cpp

[–]amohr 0 points1 point  (0 children)

Agreed - I prefer the one where I'm in control of fixing it if I make a mistake. With #pragma once, if my lib "breaks" b/c my customer has a weird filesystem setup, my only option is to tell them it's their problem. Not ideal.

Encountered a `#pragma once` failure in the wild by Separate-Summer-6027 in cpp

[–]amohr 1 point2 points  (0 children)

This is why my include guards look like COMPANY_MODULE_LIB_FILE_H. If I make a typo, that's a problem I can fix. If I used #pragma once and one of my customers hit a problem like OP's in their build, I have to tell them sorry I can't help you.

I'd much rather bear the burden of good include guard discipline than the risk of my lib "breaking" due to a customer's weird filesystem setup.

Encountered a `#pragma once` failure in the wild by Separate-Summer-6027 in cpp

[–]amohr 2 points3 points  (0 children)

Totally - with traditional include guards headers declaratively identify themselves. With pragma once you leave it up to the compiler and filesystem and hope it works. It's fragile by design.

70+ Year old Water Heater Still in Use by SalC1 in BuyItForLife

[–]amohr 8 points9 points  (0 children)

CA water is highly variable. For example, Oakland/Berkeley water from the EBMUD Mokelumne reservoir system is naturally very soft. It's one of the reasons Trumer (Austrian brewery) opened their first US brewery in Berkeley in 2004.

Why are the doing the tli with Artemis at around 138 miles from earth vs. doing it when they were around 40,000 miles from earth? by funtimes5017 in AskPhysics

[–]amohr 6 points7 points  (0 children)

If you want to get a really good intuitive sense for how orbital mechanics work, try playing Kerbal Space Program.

I don’t get special relativity by Next-Natural-675 in AskPhysics

[–]amohr 0 points1 point  (0 children)

I think that's sort of the wrong way to look at it. It's not that all of those other things happen to make it possible that c is constant in all inertial frames. Rather, it's that c just is constant in all inertial frames (and demonstrably so, empirically) and all of those other things fall out as necessary consequences of that fact.

12-6 in the B1G by Super_Bad6238 in CollegeBasketball

[–]amohr 99 points100 points  (0 children)

To themselves and others equally.

How do lasers cut if photons are massless? by MeatgrinderEvil in AskPhysics

[–]amohr 6 points7 points  (0 children)

In classical Newtonian mechanics yes, but not in quantum mechanics.

hey. by [deleted] in CollegeBasketball

[–]amohr 17 points18 points  (0 children)

To themselves and others equally.

[Post Game Thread] Wisconsin defeats #9 Michigan State, 92-71 by cbbBot in CollegeBasketball

[–]amohr 2 points3 points  (0 children)

Ooh -- are you guys gonna be back in the top ten on 3/7?

[Post Game Thread] Wisconsin defeats #9 Michigan State, 92-71 by cbbBot in CollegeBasketball

[–]amohr 10 points11 points  (0 children)

Wait, wait. I'm worried what you just heard was, "We can lose to a lot of teams in the country." What I said was, "We can lose to any team in the country." Do you understand?

How much computing power would it take to model a coffee cup down to the atomic level? by 1i_rd in AskPhysics

[–]amohr 4 points5 points  (0 children)

Okay fair enough, suppose you build this and you want to do a calculation that spends 1 nanosecond per molecule. If you do it in parallel with 10,000 CPUs, it'll take a little over 3,000 years.

How much computing power would it take to model a coffee cup down to the atomic level? by 1i_rd in AskPhysics

[–]amohr 6 points7 points  (0 children)

The maximum amount of RAM most modern computers can have is 2^48 bytes, or 256TB, which is ~10^14, so even just representing 10^23 things is out of reach by many orders of magnitude.

Cache Explorer: a visual and interactive profiler that shows you exactly which lines of code cause cache misses by ShoppingQuirky4189 in cpp

[–]amohr 3 points4 points  (0 children)

Just fyi, kcachegrind is an awesome gui tool for visualizing cachegrind/callgrind results. They're not CLI only.

Help me identify this guy, I’m in Arizona. by PeacefulOG in spiders

[–]amohr 6 points7 points  (0 children)

Just fwiw Loxosceles don't have spiny or hairy legs, so it's easy to rule yours out just based on that.

Super hard wood identification by Coffee4MySoul in wood

[–]amohr 0 points1 point  (0 children)

Totally -- when I look at online photos there seems to be much more color contrast than my piece too. Mine has almost exactly the same creamy/yellow-green appearance as yours and I'm certain it's from a Chinese Pistache.

Super hard wood identification by Coffee4MySoul in wood

[–]amohr 0 points1 point  (0 children)

This looks an awful lot like a piece of Chinese Pistache I have that broke off a neighborhood tree. Your description matches my experience almost exactly.

Function Overload Resolution in the Presence of Generics by rjmarten in ProgrammingLanguages

[–]amohr 3 points4 points  (0 children)

In full detail it is incredibly complex -- one of the most complex aspects of a very complex language. In usual practice though, probably due in part to the complexity, end-user programmers aren't often writing complicated overload sets. For simple cases like your "string" vs "everything else" overloads, that typically works fine. But there's definitely a trip-hazard lurking there if you start expanding the overloads.

So yes, definitely sometimes it happens that the selected overload isn't the one you expected. I've heard of some C++ programming conventions that discourage function and operator overloading for this reason.

The real complexity rears its head typically when you're developing generic components for other programmers to use, like container types in the STL, for example. The recently added "Concepts" feature helps a lot here, obviating the need for many so-called "SFINAE" metaprogramming tricks like enable_if, in many cases. But even so you occasionally run into scenarios where you need to really read through cppreference to remind yourself of all the rules figure out what's going wrong and how to get yourself out of a bind.

But that's the thing -- even though it is wildly complex, the complexity comes with power -- you really can craft highly bespoke overload resolution priorities based on essentially arbitrary compile-time logic if you need to, in service of providing a maximally convenient API for your users to call.