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
Nude
Nov 16, 2014

I have no idea what I'm doing.
So the podcast, 99% Invisible, causes a 2016 Mazda sedan radio to crash. Because when parsing the url "% I" tells the car to run some code. They don't really go into detail on how exactly it fails sadly.

Adbot
ADBOT LOVES YOU

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

code:
// Do we really need to define a macro for "if"?
#define CHECK_WCF_FUNCTION(X) if (X)
:eyepop:

Xarn
Jun 26, 2015

dougdrums posted:

It's not ambiguous, the pointer is part of the declarator. I mean this is well worn ground and I don't think I'm telling anyone anything new but:
code:
int x[4], y[8];
would not be sensible otherwise. Of course in C# arrays are reference types derived from Object with different semantics, and the [] is part of the type specifier. In that sense, T[] is just sugar for Array.CreateInstance, which ends up being an internal call which creates a struct with the type, rank, and lengths, and then the actual values. Pointer types in C# are neither value types or reference types, but they are all types, and the syntax for declarations treats them as such.

So the stronger typing is nice but it would make C arrays syntactically inconsistent or semantically inconvenient. It's just the matter of knowing why you're using C in the first place. That being said I love that I can use abstract stuff like BlockingCollections and also void* all the same in C# (more or less).

Also gently caress writing C declarations like that. Just don't do it aaaaaaaarrrrrrggg :rant:

Spoiler, the code is not sensible anyway and the C decl grammar is completely stupid.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆
A reasonable lang would make it a syntax error to declare two variables of totally different types in the same statement.

Ola
Jul 19, 2004

But think about the time saved, the massive performance increase and how awesome you look when there is one less line in your code.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

RPATDO_LAMD posted:

A reasonable lang would make it a syntax error to declare two variables of totally different types in the same statement.

Just don't allow declaring two variables in the same statement at all.

Also using an if/else/while/etc. and not using braces should be a syntax error

nielsm
Jun 1, 2009



The idea is that int *x, y; declares *x to be an int, and also y to be an int. It's not "the type of x is int*", it is "the type of *x is int".

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

nielsm posted:

The idea is that int *x, y; declares *x to be an int, and also y to be an int. It's not "the type of x is int*", it is "the type of *x is int".

Yup. "int* x" should be a syntax error. It should be either "int *x" or equivalently "&int x". Ampersand references, asterisk deferences.

Soricidus
Oct 21, 2010
freedom-hating statist shill

nielsm posted:

The idea is that int *x, y; declares *x to be an int, and also y to be an int. It's not "the type of x is int*", it is "the type of *x is int".

Which is all very well and good except that the actual semantics are to declare a variable x whose type is int*

The way the syntax works is inexcusable, sorry

Xarn
Jun 26, 2015

nielsm posted:

The idea is that int *x, y; declares *x to be an int, and also y to be an int. It's not "the type of x is int*", it is "the type of *x is int".


Well then, I guess this won't assert

code:
char *c;
assert(sizeof(c) == sizeof(char));
oh wait, gently caress, it does. The reality is that all of char* c, char *c, and char * c declare variable c as having the type of char*. All of the language supports it (sizeof, nameless args, etc), except for the declaration syntax, which is dumb af.

Xarn fucked around with this message at 13:02 on Apr 25, 2019

Munkeymon
Aug 14, 2003

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



Ola posted:

But think about the time saved, the massive performance increase and how awesome you look when there is one less line in your code.

Packing multiple declarations on to one line could save hundreds of byte of precious disk space on a large codebase!

That was probably a legit concern back in the day, along with fewer keystrokes to transcribe the program from the magazine or book

OddObserver
Apr 3, 2009

Munkeymon posted:

Packing multiple declarations on to one line could save hundreds of byte of precious disk space on a large codebase!

That was probably a legit concern back in the day, along with fewer keystrokes to transcribe the program from the magazine or book

I am guessing the complexity of the original compiler was a bigger factor.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Munkeymon posted:

Packing multiple declarations on to one line could save hundreds of byte of precious disk space on a large codebase!

That was probably a legit concern back in the day, along with fewer keystrokes to transcribe the program from the magazine or book

I'm not sure if any C programs were written on punch cards, but the language was probably designed with that use case in mind.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Dumb Lowtax posted:

In JavaScript sometimes you make long lines with lambdas nested inside expressions. Sometimes you do a few of these in a row. Sometimes I have a few complex, but similar lines in a row* and that's when I like to add horizontal spacing to make sure the like tokens line up. That can't really be done automatically because it's a subjective choice of whether to do it or not.

*These are all the cases where the DRY principle did not give good enough savings

Aren't you the person like a year ago advocating in this thread for longer line lengths and less vertical scrolling?

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Thermopyle posted:

Aren't you the person like a year ago advocating in this thread for longer line lengths and less vertical scrolling?

You can filter a thread to only the posts from a specific person if you click the "?" button underneath their posts!

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Hammerite posted:

You can filter a thread to only the posts from a specific person if you click the "?" button underneath their posts!

It was a rhetorical question.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Nude posted:

So the podcast, 99% Invisible, causes a 2016 Mazda sedan radio to crash. Because when parsing the url "% I" tells the car to run some code. They don't really go into detail on how exactly it fails sadly.

This was solved later on, it's the "%n" token in printf, where "%In" also does it. They were on the right track in the reply all episode but didn't test all of the tokens.

There's a Reddit post for the reply all podcast from 1-2 weeks ago that solved it the rest of the way.

edit: Oooh, this actually makes much \*more\* sense. T...

https://www.reddit.com/r/gimlet/comments/bdxht4/hey_its_ben_from_the_reply_all_episode_140_i_have/el1hf1q

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

Soricidus posted:

Which is all very well and good except that the actual semantics are to declare a variable x whose type is int*

The way the syntax works is inexcusable, sorry

Yeah, a derived type. It's like saying the syntax of mov rax, [rsp+4*8] is inexcusable. It makes sense to write T[] x; in higher-level languages, because x is really a reference type in those cases, with no special relation to pointer types (if said language has pointers), whereas subscription in C is sugar for pointer arithmetic.

Hammerite posted:

Just don't allow declaring two variables in the same statement at all.
:same:

dougdrums fucked around with this message at 17:29 on Apr 25, 2019

Zopotantor
Feb 24, 2013

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

CPColin posted:

Source code should only ever save to disk as an AST and IDE's should just format them into readable text on load.

There was a lot of work done on structural editors in the 80s when I was studying. There was a group at my university doing that kind of research, and I had to use their ... product ... during an undergrad programming course (Modula-2 IIRC).
I thought the idea was kind of neat, until I commented out a largish block of code while debugging.

The editor was quite happy turning the AST into comments, but since it didn’t have an actual parser it couldn’t do the reverse.

fourwood
Sep 9, 2001

Damn I'll bring them to their knees.
code:
int Foo(int i, const int *array) {
    while (array[i] != i) {
        i = array[i];
    }

    return i;
}
...but why...

e: placement of the * notwithstanding

fourwood fucked around with this message at 18:17 on Apr 25, 2019

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop

Thermopyle posted:

Aren't you the person like a year ago advocating in this thread for longer line lengths and less vertical scrolling?

Thermopyle posted:

It was a rhetorical question.

I wasn't "advocating" last year, I was defending myself. There was this giant thread pile-on after I had asked if something I was doing was a horror, and explained my own mindset and internal justification for formatting that way. I was asking an earnest question and trying to learn. Don't everybody mischaracterize it to make me the thread bad guy again.

I do not use long line lengths anymore since that conversation. I immediately re-formatted my hobby codebase. I hope you do not make me wear that badge forever.

On the other point, less vertical scrolling, that's not fair. There is nothing inherently wrong with less vertical scrolling if it is free, or nearly free. It helps with visual memory to see things simultaneously. Fitting more content onto one screen height for free (without exceeding a density threshold, without making lines uncomfortably long, without multiple statements per line, without damaging readability such as obscuring flow control or structure, etc.) doesn't seem like it deserves guilt.

For example I think the folks who just spoke up wanting strict bans on common idioms like declaring several variables, all of the same type, on the same line are taking a really extreme view. It's not a horror all the time. I think the act of intentionally avoiding being economical with space at all as part of some neverending competition for maximum readability *does* hurt readability because your code will be stretched thinner and thinner on the vertical axis until almost none of it can be seen at the same time, which is bad for visual memory and being able to keep code in your head.

On that last note, here's a good source: http://paulgraham.com/head.html

Happy Thread fucked around with this message at 21:57 on Apr 25, 2019

Red Metal
Oct 23, 2012

Let me tell you about Homestuck

Fun Shoe
You're also still putting two spaces after periods. On the internet.

Happy Thread
Jul 10, 2005

by Fluffdaddy
Plaster Town Cop

Red Metal posted:

You're also still putting two spaces after periods. On the internet.

Do something about it bitch

CPColin
Sep 9, 2003

Big ol' smile.
I only use tabs after periods.

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

Dumb Lowtax posted:

For example I think the folks who just spoke up wanting strict bans on common idioms like declaring several variables, all of the same type, on the same line are taking a really extreme view. It's not a horror all the time.
There's no reason to do this because we're no longer required to declare all the variables at the start of a block like animals. Variables should be declared immediately before use because it makes it easier to reason about dependencies, and there's less chance of loving up the intended scope. The only possible allowable place for it is in for loop initializers.

Dumb Lowtax posted:

I think the act of intentionally avoiding being economical with space at all as part of some neverending competition for maximum readability *does* hurt readability because your code will be stretched thinner and thinner on the vertical axis until almost none of it can be seen at the same time, which is bad for visual memory and being able to keep code in your head.
I keep all of my lines under 78 chars with some exceptions because on my laptop I can have a browser/terminal open to the side and still see all my code. The "minimap" some editors have, and "peeking" make vertical scrolling a non-issue. I'm also just used to looking at it. If I'm programming with other people in a more "wordy" language like C# or Java, I'm not gonna make a big deal about it for the sake of teamwork. 120 is pretty much the hard limit though.

Doom Mathematic
Sep 2, 2008

pokeyman posted:

Love when people think it’s possible to write C without invoking undefined behaviour, if only they condescend hard enough.

Yeah, this is crazy to me. Adding two ints together is potentially undefined behaviour.

Absurd Alhazred
Mar 27, 2010

by Athanatos

Doom Mathematic posted:

Yeah, this is crazy to me. Adding two ints together is potentially undefined behaviour.

Wait, what? Like, overflow/underflow?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Signed int overflow is UB, yeah.

Absurd Alhazred
Mar 27, 2010

by Athanatos

Plorkyeran posted:

Signed int overflow is UB, yeah.

But unsigned is DB?

eth0.n
Jun 1, 2012

Absurd Alhazred posted:

But unsigned is DB?

Yes, it's modular arithmetic; wraps around.

RPATDO_LAMD
Mar 22, 2013

🐘🪠🍆

Plorkyeran posted:

Signed int overflow is UB, yeah.

And the number of bits in an int is implementation-defined!

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
Microsoft Excel

gently caress you. it's a string. gently caress you

Munkeymon
Aug 14, 2003

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



Hammerite posted:

Microsoft Excel

gently caress you. it's a string. gently caress you

I think you mean the cell's format is Text, OP.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

https://www.theregister.co.uk/2019/04/23/hertz_accenture_lawsuit/

In short, Hertz hires Accenture to revamp its online presence.

$32 million later they get a codebase of poo poo.

Magissima
Apr 15, 2013

I'd like to introduce you to some of the most special of our rocks and minerals.
Soiled Meat
Lol at the PDF thing, I would be so happy if someone asked me for markdown or CSV instead of requiring PDF and Excel sheets

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
I don't know if it ever got fixed, but Hertz's website would show cars available at my local place whether or not they were actually available. I would notice that they would be out of Chevy Sparks or whatever and be able to make a reservation for the next day and get it upgraded to something nice for the same price. This backfired on me once when I had to take a Jeep Renegade that looked like it was designed by a stoned jr high school student to a proposal meeting.

Volguus
Mar 3, 2009

dougdrums posted:

I don't know if it ever got fixed, but Hertz's website would show cars available at my local place whether or not they were actually available. I would notice that they would be out of Chevy Sparks or whatever and be able to make a reservation for the next day and get it upgraded to something nice for the same price. This backfired on me once when I had to take a Jeep Renegade that looked like it was designed by a stoned jr high school student to a proposal meeting.

I was under the impression that rental companies have always done that: you come in and you get whatever's available regardless of what you actually asked. The idea is that they want to have their cars always on the move. No way in hell they'll keep that Jeep in the parking lot sitting there for you to pick it up tomorrow. That would be a waste of money. So, whether you reserved something or you just show up out of the blue is irrelevant.

Ola
Jul 19, 2004

Yeah it always says "Car Model or similar". I don't think I've ever got the brand it said on the menu. They have their own car classification system: https://www.sixt.co.uk/faqs/acriss-code/ Why then, do they keep on advertising specific brands? Probably a focus group thing. Their web sites have always been dumpster fires. It wouldn't surprise me if byzantine legacy issues made the upgrade project go to poo poo.

Anyway, I too get upgrades often by playing with that classification system. They have many different classes, but my local station won't have all of them. So I just pick the one that's slightly more than the cheapest (because they definitely have those), I think it's ILAR. When they don't have that, I get whatever they have available better than that, which can be a very nice car. No Golf automatics in, so I get a fully decked out Volvo S90 instead? Don't mind if I do!

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
Ah, well I thought I was being clever. Lord knows nobody else over the age of 25 was going to willingly rent that monstrosity. I'd get Buicks and Chryslers for the price of a subcompact which was always pretty swanky. I think my place is just small enough that it ends up being the next step from garbage tier car. It does make sense that they'd rather have someone pay half-price and be pleasantly surprised instead of letting it sit in the lot.

Adbot
ADBOT LOVES YOU

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Nude posted:

So the podcast, 99% Invisible, causes a 2016 Mazda sedan radio to crash. Because when parsing the url "% I" tells the car to run some code. They don't really go into detail on how exactly it fails sadly.

First time I read this I thought it said it causes the car to crash

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