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
TasteMyHouse
Dec 21, 2006

No Safe Word posted:


Stupid/made up/misspelled units
...
dekameters

This is the standard American spelling of "Decametres" as stated here and as taught to me in the 2nd grade.

Adbot
ADBOT LOVES YOU

No Safe Word
Feb 26, 2005

TasteMyHouse posted:

This is the standard American spelling of "Decametres" as stated here and as taught to me in the 2nd grade.

I always learned it as "decameter", and all units were prefaced with "deca-" and not "deka-". Weird.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

poemdexter posted:

What the hell software needs to go from nanometers to parsecs?
AutoCAD does! Some googling has indicated that this enum is probably retarded-up version of http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/files/WS1a9193826455f5ffa23ce210c4a30acaf-4f8f.htm with some values rearranged and Hectometers replaced with Dynes for some inexplicable reason.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

No Safe Word posted:

I always learned it as "decameter", and all units were prefaced with "deca-" and not "deka-". Weird.

It's not super important, I think it might even just be a Greek/Roman thing. I know it's worthless but deka loses the GoogleFight: http://www.googlefight.com/index.php?lang=en_GB&word1=decameter&word2=dekameter

raminasi
Jan 25, 2005

a last drink with no ice
I'm using a library for exact computation that supposed to be pretty close to drop-in (just include the headers and set up some typedefs and you're done). This is kind of neat*, but what if your library has some warnings to emit during use? You wouldn't want to throw an exception if it's just a warning - that's far too drastic. Instead, maybe you do something like this:
code:
// Usage: core_error(message, file_with_error, line_number, err_type)
//   where err_type=0 means WARNING, error_type=0 means ERROR
void core_error(std::string msg, std::string file, int lineno, bool err) {
  std::ofstream outFile(CORE_DIAGFILE, std::ios::app);  // open to append
  if (!outFile) {
     // perror("CORE ERROR: cannot open Core Diagnostics file");
     std::cerr << "CORE ERROR: can't open Core Diagnostics file"<<std::endl;
     std::exit(1); //Note: do not call abort()
  }
  outFile << "CORE " << (err? "ERROR" : "WARNING")
     << " (at " << file << ": " << lineno << "): "
     << msg << std::endl;
  outFile.close();
Since there couldn't possibly be any problem with just arbitrarily creating and writing to a file wherever the executable happens to be running, let's just do that. If it doesn't work the underlying file system must be unstable or something so obviously we have to just bail. No need to add capability to disable this "feature" - if they need to turn it off they can just dig around, comment this out, and recompile.

*It's also a horror on its own - the default behavior is to just redefine double.

GROVER CURES HOUSE
Aug 26, 2007

Go on...

No Safe Word posted:

Out of place units
Dyne

Stupid/made up/misspelled units
microinches
mils
dekameters

I'm fairly sure that the mil is a unit of angle and doesn't exactly belong there.

Jerry Bindle
May 16, 2003

Broken Knees Club posted:

I'm fairly sure that the mil is a unit of angle and doesn't exactly belong there.

mil can also be 1/1000th of an inch.

Zhentar
Sep 28, 2003

Brilliant Master Genius

Scaramouche posted:

It's not super important, I think it might even just be a Greek/Roman thing.

It also might be done to avoid confusion that could arise between decimeters and decameters.

McGlockenshire
Dec 16, 2005

GOLLOCKS!

poemdexter posted:

What the hell software needs to go from nanometers to parsecs?

Han Solo. :colbert:

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

McGlockenshire posted:

Han Solo. :colbert:
Han Solo is firmware.

tef
May 30, 2004

-> some l-system crap ->

poemdexter posted:

I had to double check if Parsecs was a thing.

What the hell software needs to go from nanometers to parsecs?

http://futureboy.us/frinkdocs/

TasteMyHouse
Dec 21, 2006

Zhentar posted:

It also might be done to avoid confusion that could arise between decimeters and decameters.

This is the reason my teacher gave when I asked this question in 2nd grade! For whatever that's worth...

Toady
Jan 12, 2009

Dooey posted:

Am I the only one who finds reading code in mixed styles not a big deal? I always use the same style for my own code, but at work we all have different styles and when I read other peoples code I have no problems at all.

I went through a period where I tried each style to see which one I truly preferred, and after the initial novelty of each one wore off, I didn't find any one more readable than the other, so I just chose one to be consistent.

Mustach posted:

I think that monospace fonts are an eyesore. I sometimes think that people stick to them just so they can pretend their code is some kind of WYSIWYG and waste time with valueless formatting like this:

Fixed-width fonts in Objective-C code let Xcode automatically line up colons in long messages, which is really nice:

code:
BOOL result = [someObject doA:firstArg
                        withB:secondArg
                       usingC:thirdArg
                        error:&outError];

Toady fucked around with this message at 21:35 on Aug 9, 2011

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Toady posted:

I went through a period where I tried each style to see which one I truly preferred, and after the initial novelty of each one wore off, I didn't find any one more readable than the other, so I just chose one to be consistent.

I think of written code as written prose: unless someone punches one of my pet peeves' buttons, I get used to different styles in a hurry.

Then the problem is reduced to limiting the number of pet peeves you have, which is much easier.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

I met the creator of that on Saturday during "Crash & Compile" at defcon; they won because one of the teams was a PDP-11 gimmick team that picked their language from a d12, and another team used the other gimmick team's d20 from last year.

PrBacterio
Jul 19, 2000

BonzoESC posted:

I met the creator of that on Saturday during "Crash & Compile" at defcon; they won because one of the teams was a PDP-11 gimmick team that picked their language from a d12, and another team used the other gimmick team's d20 from last year.
Hahaha holy poo poo, that thing is the *definition* of the "kitchen sink" language. Honestly, that's quite impressive even though I don't think I'm ever going to use it :)

Dren
Jan 5, 2001

Pillbug
In C++. Just found out that the base class for a ton of our objects is a "Utilities" class where all the methods are static methods.

The same codebase has namespace pollution all over the place, granted it's mostly using namespace std but it results in function prototypes like this:

code:
void doStuff( const string &the_message, const std::string &data );
Now those probably aren't two different types but I'd like to be able to tell for sure without running the preprocessor.

*sigh*

Dren fucked around with this message at 16:49 on Aug 10, 2011

shrughes
Oct 11, 2008

(call/cc call/cc)

Dren posted:

I'd like to be able to tell for sure without running the preprocessor.

The true horror spotted.

TasteMyHouse
Dec 21, 2006
It's cool when people declare virtual methods in abstract base classes that need to be implemented in subclasses as:
code:
protected virtual void cool_method() {}
instead of
code:
protected void abstract cool_method();
of course if I actually had documentation for this poo poo it wouldn't've been as big of a deal, but as is I had no idea why my subclass wasn't working.

w00tz0r
Aug 10, 2006

I'm just so god damn happy.
Serializing a double (sanitized a bit for clarity):

code:
double d = 1.0;

volatile union TypeConverter {
	TypeConverter(double d) : _d(d) {}
	double _d;
	char _bytes[sizeof(double)];
} converter(d);

vector<char> buffer(sizeof(double));
for (int i = 0; i < sizeof(double); i++)
	buffer[i] = converter._bytes[i];
This was shown to me with the explanation of "this is the safest way I could think of to do this."

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Huh, I didn't actually realize you could give a union a constructor. I wonder if there's ever a good reason to.

The volatile there is extra-weird.

1337JiveTurkey
Feb 17, 2005

Plorkyeran posted:

The volatile there is extra-weird.

Just a wild guess, but the user might have ripped it off from somewhere else where it makes sense and didn't bother to remove it. The status registers for a UART in an embedded system would be some horrible combination of a volatile union and structs.

Brecht
Nov 7, 2009

TasteMyHouse posted:

It's cool when people declare virtual methods in abstract base classes that need to be implemented in subclasses as:
code:
protected virtual void cool_method() {}
instead of
code:
protected void abstract cool_method();
of course if I actually had documentation for this poo poo it wouldn't've been as big of a deal, but as is I had no idea why my subclass wasn't working.
'abstract' is not a C++ keyword? What is this?

Anyway, abstract methods should be virtual void cool_method() = 0; obv.

nielsm
Jun 1, 2009



Brecht posted:

'abstract' is not a C++ keyword? What is this?

Probably C#.

w00tz0r
Aug 10, 2006

I'm just so god damn happy.

1337JiveTurkey posted:

Just a wild guess, but the user might have ripped it off from somewhere else where it makes sense and didn't bother to remove it. The status registers for a UART in an embedded system would be some horrible combination of a volatile union and structs.

Not so much that he didn't bother to remove it, he wrote it that way. You're half-right on the embedded systems guess; he's an embedded C guy who's lead on our C++ desktop applications by virtue of being in the company the longest.

Dren
Jan 5, 2001

Pillbug
I guess it's "safe" because it went in a vector? Considering that he's an embedded guy at least he didn't use any macros.

TasteMyHouse
Dec 21, 2006

nielsm posted:

Probably C#.

Yeah, it's C#. I'm in the middle of writing a bunch of C++/CLI and C# classes to wrap a C library to write a plugin for a (completely undocumented) internal tool at work. It's fun kind of but also terrible.

Scaevolus
Apr 16, 2007

Plorkyeran posted:

The volatile there is extra-weird.
I think the volatile is meant as an extra-strong hint for buggy compilers that don't properly handle the union's double/char array aliasing.

He's probably been bitten by bad compilers for embedded systems before, making him learn a more defensive style of programming.

Scaevolus fucked around with this message at 00:55 on Aug 11, 2011

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
i guess disabling all optimizations is a way to avoid correctness problems due to aliasing violations

not a very good way

mjau
Aug 8, 2008

Plorkyeran posted:

i guess disabling all optimizations is a way to avoid correctness problems due to aliasing violations

Union members are allowed to alias even with strict aliasing optimization switched on. That's kind of what they're for.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Plorkyeran posted:

i guess disabling all optimizations is a way to avoid correctness problems due to aliasing violations

not a very good way

Seriously what the gently caress is an aliasing violation? I tried looking it up, but the examples I saw didn't make any sense. Is that something that you C guys have to deal with constantly?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

TasteMyHouse posted:

It's cool when people declare virtual methods in abstract base classes that need to be implemented in subclasses as:
code:
protected virtual void cool_method() {}
instead of
code:
protected void abstract cool_method();
of course if I actually had documentation for this poo poo it wouldn't've been as big of a deal, but as is I had no idea why my subclass wasn't working.

Maybe they didn't know that abstract methods exist.

I like it when people make every method in a class virtual, because "I might need to override it some day!" It doesn't hurt anything other than readability, of course.

First Time Caller
Nov 1, 2004

This is pretty miniscule compared to some of the things I've seen in this thread but I thought it was pretty retarded.

code:
<?php if("ying" == "yang"): ?>
//code block
<?php endif; ?>

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

mjau posted:

Union members are allowed to alias even with strict aliasing optimization switched on. That's kind of what they're for.

This is in fact a very exciting and lively debate on the C committee. Neither C nor C++ actually permits aliasing through a union. Unions have an "active member", determined by which member was last stored through, and it is impermissible to read from any member other than the active member, with one exception: if the member accessed and the active member are both structs, and they share a common prefix, it is okay to access a member of that common prefix. However, some people have argued that unions ought to influence aliasing somehow, except that nobody seems quite certain what the language rule should be.

Anyway, char can alias anything, so if the code instead just casted the double* to char* and did that final loop, it would be perfectly legal by both standards.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

mjau posted:

Union members are allowed to alias even with strict aliasing optimization switched on. That's kind of what they're for.
writing to one union field then reading from another one is technically undefined behavior, and we're assuming a buggy and dumb compiler that might do something completely insane

Ithaqua posted:

I like it when people make every method in a class virtual, because "I might need to override it some day!" It doesn't hurt anything other than readability, of course.
and performance

Ensign Expendable
Nov 11, 2008

Lager beer is proof that god loves us
Pillbug
Maybe they miss Java.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Plorkyeran posted:

and performance

I'd never thought of that, actually. I always assumed that was something the compiler figured out, and at runtime it was already squared away.

Turns out I'm wrong! http://stackoverflow.com/questions/530799/what-are-the-performance-implications-of-marking-methods-properties-as-virtual

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

MEAT TREAT posted:

Seriously what the gently caress is an aliasing violation? I tried looking it up, but the examples I saw didn't make any sense. Is that something that you C guys have to deal with constantly?

Basically "aliasing" is when you have one location that's referred to by multiple names.

If you assume that anything at all can be aliased to anything else in the current scope, then that really limits what optimizations you can do - you have to actually write everything to memory before you read through a pointer, for example. So for performance, the compiler is allowed to assume that in most cases there is no aliasing.

If there actually is aliasing when the compiler assumes there isn't, then you can run into some problems with your reads getting stale values and the like.

Zamujasa
Oct 27, 2010



Bread Liar

First Time Caller posted:

This is pretty miniscule compared to some of the things I've seen in this thread but I thought it was pretty retarded.

php:
<?php if("ying" == "yang"): ?>
//code block
<?php endif; ?>


That's actually a pretty decent way of doing it, compared to a "{", HTML block, then a closing "}" possibly many lines away.

A bit weird and rarely used, but understandable.

Adbot
ADBOT LOVES YOU

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Zamujasa posted:

That's actually a pretty decent way of doing it, compared to a "{", HTML block, then a closing "}" possibly many lines away.

A bit weird and rarely used, but understandable.

Surely the horror is the comparison that cannot possibly* be true, and/or the misspelling of "yin".

* I know nearly no PHP and would not be surprised to hear that I am wrong here.

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