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
Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

j4cbo posted:

This is because the size of any pointer must be a multiple of the size of a single char, and if pointers are of finite dimension

The first part of this does not imply the second part.

Adbot
ADBOT LOVES YOU

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

j4cbo posted:

The sizeof operator result "is an integer" according to the spec, so it can't be infinity. Or is that not what you meant?

"Integer" in the ISO standard is understood to refer to the integral types in the language, which make no explicit mandate that the values be finite. It's being pedantic, but so are you. (It would be stupid, for instance, for sizeof to return an integer larger than can be represented by the available integral types, so just "is an element of Z" isn't what the standard is referring to. Besides that, the grammar rules for integer constants clearly allow constants of infinite length.)

Incidentally, a conforming implementation of ISO C can have unbounded char values if it wants. The standard says nothing whatsoever about the size of a byte, and in fact goes out of its way to provide for systems where a byte is not 8 bits.

Avenging Dentist fucked around with this message at 04:46 on Apr 13, 2009

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

j4cbo posted:

Infinite and unbounded (arbitrarily large) aren't the same thing. And yes, of course I'm being pedantic. :)

If you have infinite space (required for TC) you can define a decimal integer literal equal to aleph-0 (by way of writing a decimal expansion with aleph-0 digits). I mean, that's part of the basis of the proof that R is uncountable.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

A question so bad, even StackOverflow shits on it. :pwn:

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

twodot posted:

If you've been doing C for long enough you start to write code with format string vulnerabilities in it?

Congrats, you don't know printf.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

rjmccall posted:

If print were actually printf, then print a would indeed have format-string vulnerabilities. But it isn't; the printf-like thing in that code is python's % operator, which is essentially sprintf.

I think he is trying to assert that, in C, printf("%s",s); has a format-string vulnerability. Which is false.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Seth Turtle posted:

Where do people come up with this insanity? Is it really that hard to code in a sane and understandable manner?

Given that people make functions called doit or run in Java, yes.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

thesaddestpirate posted:

code:
package java.lang;

public interface Runnable {    
     public abstract void run();
}
:colbert:

Um, thank you for agreeing with me that Java is horrible?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

rhag posted:

May I please get some? Been using it for so long, I've never had a problem with Runnable->run, Thread->start, Cloneable->clone (even tho clone is part of Object).
And I don't remember ever seeing a bad naming example in Java.

The fact that there are multiple, differently-named methods in Java that amount to "doit()" is pretty bad. For as much poo poo as operator overloading gets, at least with using the call operator, you aren't forced to come up with vague method names that vary depending on the specific usage.

As for bad naming in general, let's just go through the Javadoc alphabetically, shall we?

code:
AbstractAnnotationValueVisitor6
AbstractQueuedLongSynchronizer
AccessibleTableModelChange
AlgorithmParameterGeneratorSpi
AnnotationTypeMismatchException
AppConfigurationEntry.LoginModuleControlFlag
ArrayIndexOutOfBoundsException
AttributeChangeNotificationFilter
AuthenticationNotSupportedException
BadBinaryOpValueExpException
BasicComboBoxRenderer.UIResource
BeanContextChildComponentProxy
BeanContextServiceProviderBeanInfo
BeanContextServiceRevokedEvent
BeanContextServiceRevokedListener
BeanContextServicesSupport.BCSSServiceProvider
C14NMethodParameterSpec
CertPathTrustManagerParameters
ClientRequestInterceptorOperations
ColorChooserComponentFactory
CompositeDataInvocationHandler
ContainerOrderFocusTraversalPolicy
ContextualRenderedImageFactory
DefaultKeyboardFocusManager
DefaultStyledDocument.AttributeUndoableEdit
EnumConstantNotPresentException
FileCacheImageInputStream
FileCacheImageOutputStream
FormatFlagsConversionMismatchException
ImplicitActivationPolicyOperations
IncompatibleClassChangeError
IncompleteAnnotationException
InternalFrameFocusTraversalPolicy
InvalidTargetObjectTypeException
JFormattedTextField.AbstractFormatterFactory
JMXConnectorServerFactory
JobAttributes.MultipleDocumentHandlingType
MalformedParameterizedTypeException
MemoryCacheImageInputStream
MemoryCacheImageOutputStream
ModelMBeanNotificationBroadcaster
MouseDragGestureRecognizer
ObjectReferenceTemplateSeqHelper
ObjectReferenceTemplateSeqHolder
OpenMBeanConstructorInfoSupport
PixelInterleavedSampleModel
PortableRemoteObjectDelegate
PropertyChangeListenerProxy
ReferenceUriSchemesSupported
RelationServiceNotRegisteredException
RequestProcessingPolicyOperations
ScheduledThreadPoolExecutor
ServantAlreadyActiveHelper
ServantRetentionPolicyOperations
ServerRequestInterceptorOperations
SignatureMethodParameterSpec
SinglePixelPackedSampleModel
SQLFeatureNotSupportedException
SQLIntegrityConstraintViolationException
SQLInvalidAuthorizationSpecException
SQLNonTransientConnectionException
StringIndexOutOfBoundsException
TransformerFactoryConfigurationError
UnknownFormatConversionException

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Seth Turtle posted:

It could be worse. The classes could be abbreviated to AAVV and AQLSync.

EDIT: I, of course, mean AAVV6. Don't want to confuse it with the previous five Abstract Annotation Value Visitor classes.

Or you could use something called "namespaces" and allow people to apply using declarations to minimize verbosity. A radical idea, I know.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

rhag posted:

Am I weird for not finding those names...bad? I don't see the problem with a 20 character long class name. I mean, I would have had such a problem back in Borland C++ 3.1 days, but today, with today's IDE's, its all a CTRL+space away.

Yes. You are weird. It's not even about typing them, it's about reading them. Anything nontrivial with any of those functions (and given Java's propensity for verbosity, that's 99% of things) is going to be spread out on multiple lines or will just scroll horizontally off the screen. A good sign that your code is poo poo is when a majority of the individual statements have to wrapped to fit on the screen.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
If you don't program with (at least) 2 columns of code side-by-side, you are not a real programmer.

rhag posted:

don't do Java

The only true statement in that entire post.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

No Safe Word posted:

Hell I do and I still have an 80-column limitation.

Newspaper/magazine articles have short columns for a reason: it's easier to read.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

rjmccall posted:

2. The import system lacks shortened qualified import, which turns name collisions into minor catastrophes (because everyone uses prolix package names), which means you see some really silly workarounds like Swing's J prefix on every single class in the library.

This was my favorite part of reading through the Javadoc. C++ has an awful "package" management system, and even it can avoid the old-school C way of applying prefixes to identifiers to avoid name collisions.

Any language made after C just has no excuse for that.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Brain Candy posted:

Thread is a thread, Runnable is a functor that you put in threads. Would you like ThreadFunctorActionier instead?

Thanks for not reading what I wrote?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Otto Skorzeny posted:

This* is why warnings and strict should have defaulted to on since like 1995


*among many other things

Ummmmm gently caress you buddy? Barewords are a great way of cutting out a few keystrokes in Perl Golf.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

A A 2 3 5 8 K posted:

http://codytaylor.org/?p=14122

Urge to update Blogging Considered Harmful... rising...

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Vinterstum posted:

Looks like it was for Visual Studio compatibility: http://bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=3638&p=13749&hilit=std%3A%3Avector#p13749

Oh the HORROR!

Hate to break it to you, but Visual Studio's STL implementation is by Dinkumware and is generally regarded as being pretty good.

(Also if your problem with an implementation of the STL is that it doesn't let you violate the standard then you are probably an idiot.)

Avenging Dentist fucked around with this message at 08:04 on Jul 2, 2009

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Vinterstum posted:

1. The Bullet guys needed some of their data to be 16 byte aligned.

Yeah cuz writing an allocator is really hard. This isn't even one of those situations where it's a weird allocator like EASTL needed. (The resize thing is an issue but who actually uses vectors anyway? Hurp durp arrays are hard better use a class that allocates up to the next power of two for space so I have amortized constant-time insertion at the end. :saddowns: Oh also vector<bool> is hilarious.)

There are like a million problems with the STL and it amuses me that when people write their own generic container classes, they solve 1% of the problems, replicate the 99% remaining, and then add a few of their own for flavor.

Avenging Dentist fucked around with this message at 18:39 on Jul 2, 2009

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Janin posted:

And in the end, the error was somewhere else, so I couldn't make any changes :sigh:

You need to learn how to lie.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Jon93 posted:

I like reading this thread for "What no to do"(s). But I wish you explained why what you posted is wrong and the correct way they should have done it, more often.

This thread is a good resource for that sort of thing.

You can't teach people that way. They'll (you'll) just make equally dubious decisions that are ever-so-slightly different from what's listed here. Everyone's got (at least) 10,000 lines of awful code in them so you just have to get that out of your systyem first.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Otto Skorzeny posted:

We had a fun time in the channel kicking around why Linus might have chosen the ((void)0) construct.

What do you mean? That's idiomatic C for "do nothing".

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Lexical Unit posted:

What about putting them in a union with an unsigned integer type, byteswapping the integer and returning the integer? The integer can go over whatever I/O it needs to and be byteswapped back into a floating point type on the other end.

I'm honestly asking, wouldn't this work?

Accessing a value stored in a union from a type other than the one that it was stored with is a violation of strict-aliasing (with the exception of accessing via char*). Furthermore, y'all need to shut up about the original code being unsafe since it casts to a char* and that's guaranteed to be safe by the ISO standard.

EDIT: Since I don't want to write an essay on this, I will defer to a good source: http://www.cellperformance.com/mike_acton/2006/06/understanding_strict_aliasing.html

Avenging Dentist fucked around with this message at 04:21 on Jul 8, 2009

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
There is literally nothing in the C99/C++03 standards* that says you can't manipulate a floating point value from casting/type-punning to a char*. I don't see why people are obsessing about this for.

* Probably the same for other versions of C and C++, but I don't have access to the specs.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Lexical Unit posted:

Probably due to lovely websites found through google:

Then yeah keep the swapped data in a char buffer.

(Also note that I didn't say anything about manipulating the value of a floating-point number in a predictable way. :angel:)

(Also also you should really be using type traits to disable that if it's not a primitive type).

Avenging Dentist fucked around with this message at 04:57 on Jul 8, 2009

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Lexical Unit posted:

Edit: Wait, I think I misread that. Did you mean should or souldn't? I already mentioned that I used type traits to clamp that poo poo down.

I said primitive, not integral. (There's also no reason that byteswapped data needs to be returned with the same type as the original; in fact it would be more sensible to return it as a char buffer, since you really shouldn't be manipulating byteswapped data as though it were of the original type, floating-point or not. What I am saying here is "make it work with integral and floating point values and nothing else".)

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

RussianManiac posted:

I must be missing something. If you do #define __(a) ( ) then all you are doing is just getting rid of arguments to a function prototype, right, but the return type and name should still be there assuming that it looks like

<type> <function name> __((<parameter list>))

Yes, hence K&R syntax. (Except that functions don't have prototypes in K&R C.)

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Once you see someone use "fail" as a noun you can pretty much ignore everything else they say since they are human scum.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Believe it or not, the OED doesn't tell you which words are stupid.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Zombywuf posted:

However you have just called dictionary corner human scum. This is tantamount to a declaration of war on the UK.

Um yeah, I'm an American, we have a habit of fighting the UK.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
So, I'm sure some of you know that C++'s throw specifiers don't always work too well, even for the no-throw case, e.g. void my_func() throw() {}. Luckily, the C++ standards committee has decided to resolve this, but since it's fairly late in the standardization game, they're worried about adding any new keywords, so they're reusing some old ones:

code:
void my_func() do not throw while using this
{
    // ...
}

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Scaevolus posted:

What's wrong with it?

The sine function generally does not range from -0.0174532778 to 0.0174532778.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Scaevolus posted:

The only thing I can find wrong with it is that it uses degrees instead of gradians. :smug:

Why would a system that uses 400 units for the angle of a circle be better?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Scaevolus posted:

Why would a 404 help your point?

If you can't be bothered to figure out what the URL should be, perhaps you should go and hit the books?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Scaevolus posted:

3 char extensions should be good enough for anyone!

You know, if you got a 3-char extension maybe you wouldn't be a 2-bit poster anymore!

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

geetee posted:

It's almost as if there used to be a line of code under "foo".

People have an unhealthy obsession with switch statements though (especially in languages like C# or Java). I mean ok, sure, in C/C++ with a sub-optimal compiler, a switch statement might be faster than if/elses by implementing it as a jump table (a smart compiler should be able to figure this out too for if/elses), but that sort of thing isn't going to work with string comparisons.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Flobbster posted:

I went to search Google for some statistics on when C#'s compile-string-switches-to-a-hashtable approach becomes more/less efficient than a chain of if/elses

I would hope that the compiler would notice that you're using a chain of if/elses and transform them into a switch statement in the IL.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

BattleMaster posted:

Not all if/else chains translate into a switch/case block, and if they do you just wasted a lot more time typing it out like that.

Do you really have that hard a time writing else if(foo== compared to break?

BattleMaster posted:

Also there's no good way to represent two consecutive labels with no break statement in between within a switch/case block if you type it out as an if/else chain.

They don't have the boolean-or operator where you're from?

Switch statements are useful, but people use them a lot of times because they think it makes them clever. Unless you're writing Duff's Device (and you shouldn't), you're not being clever. See the above example for a good misuse of switches, since I guess using boolean arithmetic just wasn't enough fun.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
A real man would use the GCC frontend with LLVM to compile to (optimized) C and then compile with the old-n-busted compiler you've got.

Adbot
ADBOT LOVES YOU

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
If the compilers support functions, if statements, and gotos you'll probably be ok.

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