4,901 karma · joined Sep 13, 2020 (6y ago) · 1,641 submissions
comment 5y ago · link · parent
comment 5y ago · link · parent
The only thing my comment was about is the practice of imagining non-computer-expert people to be mindless zombies who don't know basic stuff. Cmd+C, Cmd+V, and Cmd+R are one of the most popular shortcuts in computers, known by people who aren't computer experts. Just because something is done with the keyboard, doesn't mean it's some l33t knowledge exclusive to "power users". But computer professionals often talk about "casual users" as stupid, probably to feel better about themselves, because they know all that oh-so-advanced-hard stuff.
So yes, just like a "copy" button would be a waste of space, when Cmd+C is so widespread, a "refresh" button is similar in that regard.
Apple would be the last company to optimize for power users.
comment 5y ago · link · parent
comment 5y ago · link · parent
comment 5y ago · link · parent
comment 5y ago · link · parent
Although in the article the author at some point switches from lists to vectors, which changes the whole task, and allows for a more efficient implementation (even if it's an answer to a different question).
comment 5y ago · link · parent
PS. It's not uncommon for me to drink 3 glasses of wine a year. Although recently I've been more social, so it's been 1-2 glasses of wine every 1-2 weeks. I don't go out of my way to drink alcohol, but I also don't avoid it.
comment 5y ago · link · parent
No. The alternative is using a desktop application, which offers a superior UX in every way.
I don't get what's so bad about installing applications. It's painless. Browsing the web on the other hand is painful.
comment 5y ago · link · parent
This is technically correct, but also purely academic. If I called the function f(X) = 5 in an analysis exam "exponential", then I would be laughed out of this exam, and for a good reason.
> This is really weird phrasing, since you're on much stronger ground saying "not growth" [arguable] than you are "not exponential" [flat wrong].
"not A" implies "not (A and B)". That's all I meant.
comment 5y ago · link · parent
But generally I disagree that preprocessor is separate from C for the following reasons:
1. It is specified by the C standard.
2. Different C compilers implement it differently, just like they implement other parts of C differently.
3. There is some truth in the claim that it is a separate text transformation, but here I also do not agree entirely, because the C standard doesn't say that the preprocessor outputs text. It says that it outputs tokens and those tokens are then converted to tokens of C proper[1]. It is also clear that this model of "text transformation" is also not entirely what happens in real world compilers, because if it did we wouldn't get good backtraces for tokens that went out of the preprocessor after substitution. Maybe GCC serializes it to text at some point, but clearly it gets more information out of it than what a naive interpretation of the phrase "text transformation" would suggest.
[1]: Translation phase 7 of the C11 standard:
> Each preprocessing token is converted into a token.
comment 5y ago · link · parent
comment 5y ago · link · parent
comment 5y ago · link · parent
The preprocessor is part of the language. Both in literal sense and in real-world. All C programs use the preprocessor. You need to deal with it. Also, the grammar of the preprocessor is intertwined with C proper due to "#if" directives. The expression on the right hand side of an "#if" is parsed according to the grammar of C proper.
> I'm not sure that anything you say about it is true (the preprocessor is complicated).
You can run the examples under compilers and verify. Also, the part about it being context-sensitive (with regard to tokenization in #include directives vs everywhere else) is explicitly noted in the standard. Nothing controversial here.
> Certainly, your first example won't compile without warnings for any sensible GCC options.
Compiles just fine without any warnings with GCC with options -Wall -Wextra.
comment 5y ago · link · parent
#define a stdio
#define header <a.h> // five tokens: <, a, ., h, > (otherwise preprocessor wouldn't substitue "a")
#include header // one token after substitution: <stdio.h>
int main() {
struct {
int h;
} stdio;
a.h = 0;
printf("%d\n", stdio.h);
}
What happened here is:1. In #include directives a thing like <stdio.h> is one token; everywhere else (including other preprocessor directives) it is five tokens;
2. But an #include directive can have multiple tokens on the right hand side of "#include" before macro substitution. After macro substitution the strings are lexed again - into ONE token.
3. In main() "a.h" is substituted with "stdio.h" - this time it's THREE tokens.
(Oh, and writing "#include <a.h>" will produce an error, because here we have a single token <a.h>, so no "a" to be substituted, and normally there is no "a.h" header file in include path.)
So the same string gets lexed into a different number of tokens in different places; and that happens even after it got lexed first into the same number of tokens before macro substitution.
Now have an example of a C file that compiles with GCC, but not with Clang:
#define CMPS x /*
*/ <y>
#define ALMOST_SHIFT<CMPS
#define FWD_FST(x, y) x
#define CONCAT(x, y) x ## y
#define x
# /*
LOL
*/ define y stdio.h
#include CMPS
#undef x
#undef y
#include FWD_FST(<stdint.h>, y)
// btw. comma is a valid character in a header name. but this will work anyway,
// because lexing in C works in mysterious ways
#include CONCAT(<std,def.h>)
int main() {
int x = 0;
int y = 0;
int z = 0;
printf("%d\n", CMPS z);
// printf("%d\n", z<ALMOST_SHIFT); // doesn't compile
// but the rest works fine...
}
So clearly the C syntax isn't simple. It's so not simple, that compiler writers can't agree on what exactly it is.(I've been writing such programs for the purpose of using them as edgecases to test my C compiler.)
Then of course you have the type declaration fiasco: <https://blog.golang.org/declaration-syntax>
Then there if of course the awful ternary operator.
Oh, and I almost forgot: spaces are insignificant... unless you're in a "#define" directive. Talk about language consistency...
Those things not only make life hard for compiler writers, but also for language users, because, I don't know about you, but when I write a program the smallest unit that I use to think about its source code is the token. When I can't easily predict tokenization, then something went really wrong. Same with other syntax complications. Guy Steele once said that when he designs a language he verifies that its grammar is LL(1) with a parser generator, which helps make sure that it's not only easy to write the parser and that parsing can be very efficient, but also that it's easy to understand by humans. C fails here big time.
comment 5y ago · link · parent
1. First you start numbering with 1.
2. Then you start numbering with 0.
3. You provide links for all but the first element in the list, which, combined with my first 2 points, results in a juxtaposition of "2" and "0", suggesting to my subconscious that I missed something.
Well done.