Hacker News new | past | comments | ask | show | jobs | submit | eMSF's comments login

How could you ever continue after the second statement without checking if you actually read an integer or not? How would you know what you can do with a?

You couldn't or wouldn't. but why have a read statement like cin>> which looks so nice and clean when you then have to go and check everything with flags and boolean casts on stateful objects.

I agree. It's lunacy. just be explicit and use functions or equivalent like literally every other language.


Well in a language like Haskell you could solve this with monads and do-notation. The general idiom in Haskell is to use a Maybe or Either monad to capture success/failure and you assume you’re on the happy path. Then you put the error handling at the consumer end of the pipeline when you unwrap the Maybe or Either.

I believe Rust has adopted similar idioms. I’ve heard the overall idea referred to as Railway-oriented programming.

In C++ you could implement it with exceptions, though they bring in a bunch of their own baggage that you don’t have to deal with when using monads.


from_chars_result closely matches the strtol line of functions we've had for decades. Not returning the end position would be weird here!

Well, obviously it doesn't have parentheses. It's not like this is the only instance where adding parentheses affects the end result.

You could write even more complex declarators (but don't have to), but that would not prove that some other syntax is inherently intuitive. Case in point, I cannot parse the Go syntax as I do not know Go.

In my experience pointers to arrays are rather uncommon and I'm not sure that I've ever written a function returning one, having even less of a need for a pointer to such. (Thus out of all these, only your first example is somewhat common in practice.)


> I cannot parse the Go syntax as I do not know Go.

Or you probably never even tried. You should be immediately able to parse it if I provide a hint that `*`, `&` and `[10]` mean roughly the same thing as C, because `*[10]int` has no reasonable reason to be parsed as an array of 10 copies of something. You can't do so in C.


Right. These are just "old chestnuts" used to scare C noobs particularly in interviews. IIRC the K&R C book itself had a example program to convert C declarations to English and also there exists a utility program called "cdecl" to do the same.


Better to use that English explanation as a model of readable syntax.


It is but you just have to know how to map it.


ABP was initially released almost a full decade before UBO was a thing (although I don't know if the Chrome version is related), so I wouldn't judge someone for just using it...


Why does everything have to fit in the memory all of a sudden? Open files, there's your infinite tape.


Your position in a file has to be uniquely specifiable with fpos_t, so you can't have an infinite file in C.

> fpos_t is a complete object type other than an array type capable of recording all the information needed to specify uniquely every position within a file.

[7.23.1p3 of N3054 working draft of C2x, as that's what I have open right now.]


> Your position in a file has to be uniquely specifiable

`socket()` has entered the conversation.


`socket()` is not part of C99.


It will eventually not matter, but I didn't suggest using a single file.


The Finnish caption is quite a bit worse than "all your base are belong to us" type of invalid grammar. Translating it back, even with best intentions (ignoring the naive attempt of translating "from" in place) it reads "Create images from AI generated words".


A lot of folks write char const * (and T const& in C++), and the "rule of thumb" is to read the declaration right to left. In this case, pointer (to) const char. Works also with multiple consts or levels of indirection.


Block heaters can be used to heat the engine coolant (and afterwards the cabin) with or without running the engine. I doubt any cars have special batteries for these (even a drive battery of a non-plugin hybrid is somewhat small to be useful); block heaters that don't require external electricity simply use the car's fuel in an auxiliary burner.


While writing a fancy word counter I learnt that glibc iswspace (or the glibc locale data) actually does not consider non-breaking spaces as, well, spaces even when using a Unicode locale. This apparently conforms to ISO 30112. (For example MSVCRT does do so.)

I happened to notice this via a result mismatch as GNU wc does count NBSPs as word separators. Even though it uses iswspace, it also additionally checks for a hard coded set of Unicode non-breaking spaces.

(I have to say I'm a bit surprised at being at getting voted hidden here. I thought this was mostly related to the topic at hand. I would of course gladly be corrected if mistaken about the details.)


This thread stinks of cabbage to high heaven. Can you actually fool even yourselves anymore? Russians have lost the war a long time ago, it's barely a nasty procession that's left.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: