Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
brap
Aug 23, 2004

Grimey Drawer

Voted Worst Mom posted:

Which language doesn't allow you to write
code:
true
?

C# and probably many other languages don't let you use literals or operators with no side effects as statements.

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



SupSuper posted:

You can set throwOnError=true, but yeah the fact it isn't the default has caught me off-guard a few times.

I'm not 100% sure I'd ever get this thing started if it threw on every error.

Also pretty peeved that cshtml isn't compiled by default.

Oh and I once tried to work on a WPF project that had effectively become exactly as fragile WRT model consistency as HTML. Worked fine as long as everything was manually type-checked, but JFC was it a pain in the dick.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost

xzzy posted:

I've never made it to quux.

Though I do have a "biz" into my lovely variable sequence: foo bar biz baz. Googling it it looks like biz doesn't actually exist as part of the pattern and I should have been using quux all these years.

Truly a coding horror.

quux is a coding horror because it's a pain to type. Don't make me work for my nonsense placeholders. I usually go foo bar baz bort bart blarg blip...

xtal
Jan 9, 2011

by Fluffdaddy
x y z for atoms, xs ys zs for collections, f g h for functions, a b c for types

Absurd Alhazred
Mar 27, 2010

by Athanatos

xtal posted:

By return value do you mean expression? Because that makes perfect sense

Anything that is supposed to be handled by somebody. Yeah, sure, if you look at the assembly level, the computer doesn't care if you do anything with its return value, but it's still a really bizarre thing that C and friends do.

Voted Worst Mom posted:

Which language doesn't allow you to write
code:
true
?

Pascal. Incidentally, a language which uses ":=" for assignment, which is much more visually distinct from "=" than "==".

fleshweasel posted:

C# and probably many other languages don't let you use literals or operators with no side effects as statements.

That's good to know!

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
has anybody ever found a valid use for the comma operator in C

hobbesmaster
Jan 28, 2008

Suspicious Dish posted:

has anybody ever found a valid use for the comma operator in C

while(thing_that_modifies_var(var), var > some_int)

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Suspicious Dish posted:

has anybody ever found a valid use for the comma operator in C

The closest I've come is a defensive habit in manually reference counted objc. In objc calling methods (actually sending messages but whatever) on nil is a no op but calling methods on a released object is a terrible idea. I would write:

Objective-C code:

Some *thinger = ...

// when I'm done
[thinger release], thinger = nil;

So if I accidentally tried to use thinger later then nothing would happen.

I would absolutely not criticize anyone who split that on to two lines, but using comma felt harder to gently caress up.

fritz
Jul 26, 2003

Suspicious Dish posted:

has anybody ever found a valid use for the comma operator in C

getting fancy with for-loops, but even then that's a sign that maybe you should try something else

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I thought it was a different construction in a for loop, because I thought comma-operator style i = 1, j = 2 would be parsed as i = (1, j = 2), return the RHS, and set both to 2.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
No, comma parses outside of assignment. The for loop is a legitimate use of the operator, although obviously the language should have just made that a special piece of grammar instead.

vOv
Feb 8, 2014

Bigger question, has anyone ever found a good reason to overload the comma operator in C++?

VikingofRock
Aug 24, 2008




vOv posted:

Bigger question, has anyone ever found a good reason to overload the comma operator in C++?

"Good" might be a stretch, but both Boost::Assign and Boost::Phoenix have found somewhat-reasonable uses for overloading it.

edit: Not that I've ever used either of those libraries, I just remember that from the last time this came up.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

TooMuchAbstraction posted:

The real horror is that you forgot that quux comes after baz. :colbert:

Heretics! It's "foo, bar, baz, zip, qux, quux, quuux, ..."

VikingofRock
Aug 24, 2008




Zopotantor posted:

Heretics! It's "foo, bar, baz, zip, qux, quux, quuux, ..."

I thought it was "fett, boba, binks, luke, luuke, luuuke, ..."

pseudorandom name
May 6, 2007

VikingofRock posted:

I thought it was "fett, boba, binks, luke, luuke, luuuke, ..."

I think I'll adopt this from now on simply because it doesn't carry the taint of ESR.

Storysmith
Dec 31, 2006


Well, it's time to start drinking that mental image away.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
It's not proper but I prefer bodily functions and related terms such as fart, poop, butt, rear end, etcetera since they can serve as predicates and nouns to represent function and argument names respectively.

Axel Rhodes Scholar
May 12, 2001

Courage Reactor

hoge, fuga, piyo, hogera, hogehoge

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

VikingofRock posted:

"Good" might be a stretch, but both Boost::Assign and Boost::Phoenix have found somewhat-reasonable uses for overloading it.

edit: Not that I've ever used either of those libraries, I just remember that from the last time this came up.
For every 1 reasonable use there's probably 100 other unreasonable uses hidden away in Boost.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

SupSuper posted:

For every 1 reasonable use there's probably 100 other unreasonable uses hidden away in Boost.

Hey boost that thing looks cool, can I borrow it?

The next day boost shows up and moves all their stuff into your living room.

Xarn
Jun 26, 2015
x87 strikes again
https://randomascii.wordpress.com/2016/09/16/everything-old-is-new-again-and-a-compiler-bug/

Also if anyone isn't reading Dawson's blog, you should start now.

Beef
Jul 26, 2004
Huh, I thought x87 was dead, or does chrome keep it around for _really_ old machines?

feedmegin
Jul 30, 2008

Beef posted:

Huh, I thought x87 was dead, or does chrome keep it around for _really_ old machines?

Per the blog, it was in third party code. I expect if you compile code for 32-bit and don't do anything special with the compiler flags it still defaults to targeting something really old like 486 or OG Pentium, so it'll generate x87 instructions.

hobbesmaster
Jan 28, 2008

Beef posted:

Huh, I thought x87 was dead, or does chrome keep it around for _really_ old machines?

It only comes up with an extra option for LTCG and whole program optimization. It's a mismatch between a function return using an sse register and the caller expecting an x87 register so Microsoft appears to be doing some crazy register optimizations.

The third party code just turned on reporting of x87 exceptions. The bug exists in normal builds, but the exception doesn't cause a crash.

xtal
Jan 9, 2011

by Fluffdaddy

Suspicious Dish posted:

has anybody ever found a valid use for the comma operator in C

It's basically the same as `(>>) :: m a -> m b -> m b` right? Useful for when you want to jam a side effect into an expression that returns something else.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

feedmegin posted:

Per the blog, it was in third party code. I expect if you compile code for 32-bit and don't do anything special with the compiler flags it still defaults to targeting something really old like 486 or OG Pentium, so it'll generate x87 instructions.

Almost. Absent an ABI break, ABI details like calling conventions have to be stable; you can't just change them when there are new processor features, because code compiled before still has to be callable from (and be able to call) code compiled after. So the 32-bit Windows calling convention is still exactly the same as it was twenty-five years ago, and back then they decided that the right way to return floating-point values was on the x87 floating-point operand stack. And it will stay that way forever unless Microsoft drops support for every existing Windows binary.

(New architectures are necessarily ABI breaks, so the 64-bit calling conventions are not obliged to interoperate with old code; therefore they can return floating-point values in the SSE registers, which are guaranteed to exist on x86-64.)

Now, the compiler doesn't always have to follow the calling convention; it can use ad hoc specialized calling conventions if it knows all the possible call sites. That's what's happening here, except that it is apparently wrong about knowing all the possible call sites. That might be a compiler bug (the compiler is forgetting about some interesting way that the function might be used), or it might be a project configuration bug (compiling a plugin with whole-program optimization sounds like bullshit to me), or it might be a project source bug (maybe this function is discovered in a fundamentally unreasonable way, and the code ought to mark it more clearly as externally used).

Absurd Alhazred
Mar 27, 2010

by Athanatos

vOv posted:

Bigger question, has anyone ever found a good reason to overload the comma operator in C++?

I'm not sure if it's a good reason, but the Eigen linear algebra library uses it for initializing vectors and matrices of arbitrary size. I.e.
C++ code:
Eigen::Matrix3f m;
m << 1, 2, 3,
     4, 5, 6,
     7, 8, 9;

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

Absurd Alhazred posted:

I'm not sure if it's a good reason, but the Eigen linear algebra library uses it for initializing vectors and matrices of arbitrary size. I.e.
C++ code:
Eigen::Matrix3f m;
m << 1, 2, 3,
     4, 5, 6,
     7, 8, 9;

This seems really silly when you could instead just do
C++ code:
Eigen::Matrix3f m{
     1, 2, 3,
     4, 5, 6,
     7, 8, 9};

eth0.n
Jun 1, 2012

Ralith posted:

This seems really silly when you could instead just do
C++ code:
Eigen::Matrix3f m{
     1, 2, 3,
     4, 5, 6,
     7, 8, 9};

I suspect it predates C++11 initializer lists.

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

eth0.n posted:

I suspect it predates C++11 initializer lists.
It's got a fixed number of arguments, that could just as well be a regular constructor. Besides, the question's not really about Eigen in particular.

Absurd Alhazred
Mar 27, 2010

by Athanatos

Xarn posted:

x87 strikes again
https://randomascii.wordpress.com/2016/09/16/everything-old-is-new-again-and-a-compiler-bug/

Also if anyone isn't reading Dawson's blog, you should start now.

Can confirm, I just read a few of the floating point posts and they're really interesting. Pro click.

eth0.n
Jun 1, 2012

Ralith posted:

It's got a fixed number of arguments, that could just as well be a regular constructor. Besides, the question's not really about Eigen in particular.

It's a typedef to a Matrix template which can support an arbitrary number of rows and columns, either static sized, or dynamically resizable. Implementing that as a constructor would not be feasible pre-C++11.

Even if it did individual implementations of most-common matrix types, it would still be worth including the "<<" syntax for the static-sized ones for consistency with the dynamic-sized ones.


Besides, the real horrors of operator overloading are &&, ||, and unary &. operator&() is a pain mostly because it creates a need for std::addressof(), even though it's obscure enough hardly anyone actually overloads unary &.

On the other hand, && and || seem like they should be overloaded just as casually as +, but then doing so breaks short-circuit evaluation. This one I've actually seen in the wild, from quite experienced C++ coders...

xtal
Jan 9, 2011

by Fluffdaddy

Ralith posted:

This seems really silly when you could instead just do
C++ code:
Eigen::Matrix3f m{
     1, 2, 3,
     4, 5, 6,
     7, 8, 9};

Surely you mean
C++ code:
Eigen::Matrix3f m{
     1 2 3
     4 5 6
     7 8 9};

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

xtal posted:

Surely you mean
C++ code:
Eigen::Matrix3f m{
     1 2 3
     4 5 6
     7 8 9};
How's that work?

xtal
Jan 9, 2011

by Fluffdaddy

Ralith posted:

How's that work?

Commas are whitespace so commas and spaces are redundant. A map in Clojure is {key value key value}.

FrantzX
Jan 28, 2007

xtal posted:

Commas are whitespace so commas and spaces are redundant. A map in Clojure is {key value key value}.

Since when are commas whitespace?

hobbesmaster
Jan 28, 2008

xtal posted:

Commas are whitespace so commas and spaces are redundant. A map in Clojure is {key value key value}.

Huh? Aren't we taking about C++?

Standard for Programming Language C++ posted:

8.5.4 List-initialization [dcl.init.list]
1 List-initialization is initialization of an object or reference from a braced-init-list. Such an initializer is called an initializer list, and the comma-separated initializer-clauses of the list are called the elements of the initializer list.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

xtal posted:

Commas are whitespace so commas and spaces are redundant. A map in Clojure is {key value key value}.

Nice.

In APLs, whitespace is also used as a list separator. K treats newlines and semicolons identically. The general form of a list is (x;y;z) (etc.), so a matrix is typically written as simply

code:
(1 2 3
 4 5 6
 7 8 9)

Adbot
ADBOT LOVES YOU

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today

xtal posted:

Commas are whitespace so commas and spaces are redundant. A map in Clojure is {key value key value}.
We're talking about C++. The code you quoted was even tagged as such :v:

I like Lisp and Haskell syntax more than most people, but in C++ you work with what you've got.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply