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
Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
Octal literals were a frequent enough source of bugs to warrant being fixed in Python 3:
Python code:
Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 011
  File "<stdin>", line 1
    011
      ^
SyntaxError: invalid token
>>> 0o11
9
Plain octal literals don't exist anymore -- they need to be prefixed with 0o, which also works in 2.6 and 2.7. When dropping support for plain octal literals, I see two options: remove special handling of leading zeros to interpret them as base 10 (as was apparently attempted in Javascript), or just forbid them altogether to make sure that anyone used to C et al. aren't writing numbers in base 10 when they intend base 8.

Adbot
ADBOT LOVES YOU

HFX
Nov 29, 2004

hobbesmaster posted:

Compilers these days will have a warning like "Did you really want an assignment in an if statement?" But I got in that habit when writing embedded code with a terrible compiler...

Embedded work, there is a coding horror that starts with the compilers being from the mid 90's.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
To me the disappointing part is how many languages support octal literals- which hardly anyone uses on purpose- but don't support binary literals. If you're doing any kind of bitmasking with fields that aren't nybble-aligned a binary literal is a hell of a lot more clear than any other choice of base.

Hiowf
Jun 28, 2013

We don't do .DOC in my cave.

Lysidas posted:

When dropping support for plain octal literals, I see two options: remove special handling of leading zeros to interpret them as base 10 (as was apparently attempted in Javascript)

No. JavaScript supports octals (in that format, when not in strict mode). The behavior that illegal octals fall back to decimal is a historical bug that can't be fixed due to backwards compatibility concerns.

If you use strict mode, then the statement gives an error.

shrughes
Oct 11, 2008

(call/cc call/cc)
We already have binary literals. They start with 0x. If you can't convert hexadecimal into binary into your head, I mean, if you don't have neural circuitry that does that automatically and subconsciously for you, I don't know what to say, it's an essential life skill.

Zopotantor
Feb 24, 2013

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

Volmarias posted:

Outside of Unix style file permissions, when would you realistically use octal?

I recently had a use for octal constants, when defining the settings for a device register with two 3-bit fields. But that's perhaps the second time in a 20+ year career that I've found them useful.

JawnV6
Jul 4, 2004

So hot ...

shrughes posted:

We already have binary literals. They start with 0x. If you can't convert hexadecimal into binary into your head, I mean, if you don't have neural circuitry that does that automatically and subconsciously for you, I don't know what to say, it's an essential life skill.

I did alright counting hex on my fingers before I started breathing them. Still helps for masking after shifts.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



shrughes posted:

We already have binary literals. They start with 0x. If you can't convert hexadecimal into binary into your head, I mean, if you don't have neural circuitry that does that automatically and subconsciously for you, I don't know what to say, it's an essential life skill.

same, OP

or should I say, 0xCAFEBABE

1337JiveTurkey
Feb 17, 2005

I think at this point it's safe to say that 18-bit and 36-bit processors are deader than disco and if you're doing cute little bit manipulation operations in security-critical code, just loving stop now.

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.

shrughes posted:

We already have binary literals. They start with 0x. If you can't convert hexadecimal into binary into your head, I mean, if you don't have neural circuitry that does that automatically and subconsciously for you, I don't know what to say, it's an essential life skill.
Hope your neural circuitry is bi-endian too. :getin:

Spatial
Nov 15, 2007

Apparently C was the first language with octal literals. Thanks a lot you old farts.

I had to write a literal parser a few weeks ago and I found that it's trivial to support any base at all, so I allowed base 2, 8, 10 and 16. Octal looks like 0o777.

You could also do something like: "<base>:number" to allow the programmer to specify any base directly. Base64 literals. :hehe:

more like dICK
Feb 15, 2010

This is inevitable.

Spatial posted:

You could also do something like: "<base>:number" to allow the programmer to specify any base directly. Base64 literals. :hehe:

Erlang lets you do this, specifying any radix up 36 I believe.

code:
1> 36#GASTHREADBANOP. 
2780484704367714825577

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
code:
ij@red$ gforth
Gforth 0.7.0, Copyright (C) 1995-2008 Free Software Foundation, Inc.
Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
Type `bye' to exit

123 456 + . 579  ok
$BEEF . 48879  ok
071 . 71  ok
078 077 - . 1  ok
hex 123 456 + decimal . 1401  ok
32 base ! abcd decimal . 339341  ok

mjau
Aug 8, 2008
C++ code:
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>

static inline constexpr int basedigit (char ch)
{
	return (ch <= '9') ? (ch - '0') : ((ch >= 'a') ? (ch - 'a') : (ch - 'A')) + 10;
}

static inline constexpr uintmax_t baseliteral (int base, const char* ch, size_t len, uintmax_t v = 0)
{
	return len ? baseliteral(base, ch + 1, len - 1, v * base + basedigit(*ch)) : v;
}

static inline constexpr unsigned int operator "" _b36u (const char* ch, size_t len)
{
	return (unsigned int)baseliteral(36, ch, len);
}

int main ()
{
	printf("%d\n", "lfls"_b36u);
}

The Laplace Demon
Jul 23, 2009

"Oh dear! Oh dear! Heisenberg is a douche!"

mjau posted:

C++ code:
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>

static inline constexpr int basedigit (char ch)
{
	return (ch <= '9') ? (ch - '0') : ((ch >= 'a') ? (ch - 'a') : (ch - 'A')) + 10;
}

static inline constexpr uintmax_t baseliteral (int base, const char* ch, size_t len, uintmax_t v = 0)
{
	return len ? baseliteral(base, ch + 1, len - 1, v * base + basedigit(*ch)) : v;
}

static inline constexpr unsigned int operator "" _b36u (const char* ch, size_t len)
{
	return (unsigned int)baseliteral(36, ch, len);
}

int main ()
{
	printf("%d\n", "lfls"_b36u);
}

Unfortunately, constexpr functions had some pretty crazy constraints that were fixed in C++14, such as the function body may only consist of a single return statement. So it's not entirely the author's fault that's an unreadable, buggy mess. :v: Oh wait that's not supposed to be a horror

mjau
Aug 8, 2008

The Laplace Demon posted:

Oh wait that's not supposed to be a horror

Haha, it kinda is though :v:. I was curious if it could be done in c++11, and.. that's what i came up with

It'd be nice if the template<char...> operator"" syntax was supported for string literals though. Then you could check if the input is within the valid range and static_assert if it's not, instead of silently generating invalid values like that thing does. But the template syntax is only available for numbers, and i don't think they fixed that for c++14.

Amarkov
Jun 21, 2010
code:
typedef struct kqgbwbakvvw {
    uint_8 kqqbwbakacs;
    uint_16 kqqbwbakcqo;
    text *kqqbwbakpeb;
} kqgbwbakvvw;
I would at least understand why this happened if the common prefix weren't 8 characters long.

Zopotantor
Feb 24, 2013

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

Internet Janitor posted:

code:
ij@red$ gforth
Gforth 0.7.0, Copyright (C) 1995-2008 Free Software Foundation, Inc.
Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
Type `bye' to exit

123 456 + . 579  ok
$BEEF . 48879  ok
071 . 71  ok
078 077 - . 1  ok
hex 123 456 + decimal . 1401  ok
32 base ! abcd decimal . 339341  ok

Yeah, but in forth you can also do things like
code:
: 4 5 ;
3 4 + . 8 ok

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Why would you define a word named "4" if you didn't want it to do that?

FlapYoJacks
Feb 12, 2009

HFX posted:

Embedded work, there is a coding horror that starts with the compilers being from the mid 90's.

Real men know not to ever trust the compiler. :colbert:

Also I write var == condition instead of condition == var. :colbert:

edit*

Snapchat A Titty posted:

same, OP

or should I say, 0xCAFEBABE


0xDEADBEEF

Doctor w-rw-rw-
Jun 24, 2008

ratbert90 posted:

0xDEADBEEF

My favorite hex constants to use are 0xABADCAFE and 0xDEFEC8ED. Maybe 0xBADFECE5.

I have a juvenile sense of humor.

Jewel
May 2, 2009

My fav is definitely 0xD15EA5E (it's a flag on the Gamecube/Wii) because it looks the least like any other. Most use "BAD" and "BEEF" and "CAFE" and such way too much.

Workaday Wizard
Oct 23, 2009

by Pragmatica
My favorite is:
https://lkml.org/lkml/2012/7/13/154

FlapYoJacks
Feb 12, 2009

I see poo poo like this in the kernel all the time. Swear words are common, uninitialized variables are common. The kernel seriously needs a lint party something fierce; it is the coding horror that can make you cry.

Coffee Mugshot
Jun 26, 2010

by Lowtax

ratbert90 posted:

Swear words are common, uninitialized variables are common.

This is the idiomatic way to write C though

Hughlander
May 11, 2005

ratbert90 posted:

I see poo poo like this in the kernel all the time. Swear words are common, uninitialized variables are common. The kernel seriously needs a lint party something fierce; it is the coding horror that can make you cry.

Of course cleaning that up and you can't play well with Microsoft Hyper-V any longer. Since that's the identifier Microsoft uses to indicate the guest ID. (Hint: it's poo poo from Microsoft in this case.)

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Hughlander posted:

Of course cleaning that up and you can't play well with Microsoft Hyper-V any longer. Since that's the identifier Microsoft uses to indicate the guest ID. (Hint: it's poo poo from Microsoft in this case.)

Is that really the part of the API? It wasn't clear to me from the thread whether it was key or value.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

0xABAD1DEA

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Ah, I see you've hashed a certain codebase I've worked on before.

Volmarias fucked around with this message at 00:49 on Aug 12, 2014

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Volmarias posted:

Ah, I see you've hashed a certain codebase I've worked on before.

You contribute to our open-source project?

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Suspicious Dish posted:

You contribute to our open-source project?

... No?

:thejoke:

Edit: I am the horror in this thread :negative:

Volmarias fucked around with this message at 03:57 on Aug 12, 2014

ohgodwhat
Aug 6, 2005

0zABADJOKE

:v:

Zemyla
Aug 6, 2008

I'll take her off your hands. Pleasure doing business with you!
Shut up, you 0xBA57AA4D5.

El Marrow
Jan 21, 2009

Everybody here is just as dead as you.
code:

function(err, collection, res, depth) {
  if((depth == 1) || (depth == 2)) {
    if(err !== undefined) {
      res.send(500, 'Lost in space.');
    }
    if( depth == 2) {
      if(collection === undefined) {
        res.send(400, 'No results were returned from your query.')
      }
    }
  }
  else {
    return 'failed';
  }
}

Doctor w-rw-rw-
Jun 24, 2008
My horror for today: just got harassed by an ex-employee of a company I was at in 2013. Our industry really sucks sometimes.

(not so much a coding horror as it is a coder horror, I suppose)

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Dick people exist everywhere and in every industry. Just learn to deal with them as best you can.

kitten smoothie
Dec 29, 2001

edit: n/m

kitten smoothie fucked around with this message at 16:14 on Aug 13, 2014

BigRedDot
Mar 6, 2008

Suspicious Dish posted:

Dick people exist everywhere and in every industry. Just learn to deal with them as best you can.
I guess this made me kind of a dick, but this guy never did his own drat work when I was there, I wasn't about to do his job for him after I left:

quote:

First let me say that I don't really appreciate this sort of correspondence. I think even less of pestering third parties about my current whereabouts. If <crappy company> is looking for a paid consultant, I will be happy to discuss my hourly rate; otherwise, please do not contact me again.

CORBA interfaces are specified in IDL (.idl) files. These files are not valid C or C++, but must be compiled down to C or C++ headers and implementation files using a CORBA IDL compiler. In the case of the TAO CORBA implementation, for instance, one would use the TAO IDL compiler to accomplish this. The resulting generated header and implementation files are what you include and link into your project, in order for it to interoperate with other CORBA clients and servers.

If one uses a build system with features like derived dependencies and out-of-tree builds, then one would only ever store the .idl file in source control, and the build would invoke the IDL compiler as needed to keep the generated sources up to date. Lacking these features, there is no choice but to compile the IDL by hand, and check in the generated header and implementation files, even though that is a Bad Idea, for reasons you are discovering.

Now that you are using a different version of CORBA, your task is to recompile the IDL files by hand to generate new C++ headers and implementation files, and then check those in to revision control in place of the old ones. The documentation for the TAO CORBA IDL compiler may be found here:

http://www.dre.vanderbilt.edu/~schmidt/DOC_ROOT/TAO/docs/compiler.html

and a very brief example may be found here:

http://www.crossleys.org/~jim/corba/hello/idl-tao.html

Regards,

BigRedDot
To be clear, the dick part was CC'ing his boss (who wrote the worthless homegrown perl-script build system alluded to), and his boss's boss. drat I hated that guy.

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
Ah coder horrors eh?

code:
On Wed, Jun 27, 2012 at 11:10 AM, Me wrote:
Hey Dickhead,

Would it be possible to get an eta on when the server transfer will be starting?  
I'm weary of doing any work until it's finished.

Again I would be happy to help out if necessary.

Thanks,

---
Me

Date: Wed, 27 Jun 2012 11:39:14 -0700
Subject: Re: Server Transfer
From: Dickhead
To: Me

It will be done at midnight so we have no down time.

On Jun 28, 2012, at 8:48 AM, Me wrote:

Dickhead,

Server still isn't transferred, what's up?

Subject: Re: Server Transfer
From: Dickhead
Date: Thu, 28 Jun 2012 08:56:23 -0700
To: Me

I'm busy with Important stuff right now that's what's up. 

Will be sure to let you know when it's done 

Thanks
Dickhead
6 months later he still didn't wouldn't transfer the site and we didn't even have FTP access to work on anything. He was holding the business hostage. He was a dick in pretty much every way possible every time we communicated.

I created a website scraper to pull every bit of content and created a new instance of the website on my server. The scraper apparently crashed his server and somehow deleted everything on it (I used throttling :shrug:). He threatened to sue but it's not like I had a dollar to my name (first computer job and it paid only $12/hr part time). He didn't have any backups. Karma is a bitch.

Still making $75/mo off this client for web hosting.

Adbot
ADBOT LOVES YOU

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



How is it possible that any amount of load on his server could ever cause deletion of data? Alright, assuming some things are in memory and waiting to be written to whatever data store, that might be a problem in certain cases, but everything??!

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