Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
trealira
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
25 ms
·
301.
▲
by
trealira
2y ago
This compiles in C++: int foo(const int &x) { int &y { const_cast<int &>(x) }; y += 1; return y; } It may invoke undefined behavior if the original int was declared const, but this still compiles
302.
▲
by
trealira
2y ago
I upvoted you because I don't think Hacker News should become an echo chamber of the same few opinions, but I disagree with what you say here. I wouldn't call Rust "functional and impure." It has pattern matching (like i
303.
▲
by
trealira
2y ago
Not all experienced programmers become functional acolytes. See: Ken Thompson, Donald Knuth. They like procedural programming and prefer to model programs with imperative, mutable state, rather than pure functions that map one type to anoth
304.
▲
by
trealira
2y ago
Impeachment is a means for the elected officials of Congress to remove a sitting president from office. It doesn't begin a prosecution, and it doesn't have to be for anything illegal. Suggesting impeachment is there to sidestep th
305.
▲
by
trealira
2y ago
Are you implying that should make me want to change my previous answer?
306.
▲
by
trealira
2y ago
Thanks for the explanation! That makes sense. I knew from reading K&R that, in converting a char to an int without sign extension, casting to unsigned char first is just as good as masking by 0xFF after, and I guess I was just not suffi
307.
▲
by
trealira
2y ago
I think it was an impeachable offense, given that Democrats knew from the start that the president didn't have that power, yet he tried it anyway and let the courts strike it down. Pelosi even said once: "People think that the Pre
308.
▲
by
trealira
2y ago
> Mask, and then shift. > Repeat it like a mantra. You mask first, to define away potential concerns about signedness. Then you cast if needed. And finally, you can shift. Now we can create the fool-proof version for machines with at
309.
▲
by
trealira
2y ago
By the same principle, these are exactly the same: arr[i][j] j[i[arr]] These are the simplifications you'd do. You only need to know that a[x][y] is equivalent to (a[x])[y], and that a[x] is the same as x[a]. arr[i][j] (
310.
▲
by
trealira
2y ago
> When you provide software that is widely used and that people rely on, you automatically created a community where fixing bugs is an obligation. Your software has become a corner stone in other people’s software stack/life and so
311.
▲
by
trealira
2y ago
> and expect the judicial branch to inject their own favor when interpreting that vagueness. The judicial branch will once again do what it should have been doing all along: simply interpret the law. No, with Chevron deference, they expe
312.
▲
by
trealira
2y ago
I think they're saying that the point of each OS having different UI frameworks is so that all apps on that particular OS have a cohesive aesthetic and "feel native." That necessarily contradicts the desire to have the same U
313.
▲
by
trealira
2y ago
> Most people that are not trying to have children have chosen so either because they know they cannot afford to give a child a good life, or because they loathe to bring a new life into the quickly deteriorating world around them. Or, m
314.
▲
by
trealira
2y ago
This tracks with what my mom says - that she didn't feel like a full-fledged adult until she had kids, whereas her life before had just been a continuation of her adolescence and young adulthood.
315.
▲
by
trealira
2y ago
This isn't going to make Congress write more legislation. No politician that was extremist is going to start compromising and proposing legislation. This simply shifts power from the executive branch to the judicial branch. It just mak
316.
▲
by
trealira
2y ago
Got it, that makes sense. I think I completely misinterpreted the comment due to the context.
317.
▲
by
trealira
2y ago
> Marbury v. Madison was SCOTUS saying "we can overturn your executive and legislative choices" and no bothered to stop them. Are you implying the establishment of judicial review was a mistake?
318.
▲
by
trealira
2y ago
Yeah, that way of writing them definitely makes them look more symmetric. You could also do this, though it's a bit less pretty: for (i = -1; ++i != n; ) for (i = n; --i != -1; )
319.
▲
by
trealira
2y ago
In this particular case I think you could do one of the following (ignoring the "while (true)" + "break" combination): 1: while (printOneStr(s[i]), ++i < n) printOneStr(", "); 2: goto start;
320.
▲
by
trealira
2y ago
To be symmetric, the loops should read like this: for (i = 0; i < n; i++) for (i = n; --i >= 0; ) The second one could also be this: for (i = n - 1; i >= 0; i--) I say this because your backwards loop accesses the i
321.
▲
by
trealira
2y ago
I also think that some algorithms can be expressed better using goto than with a combination of nested loops, break, and continue. For example, Donald Knuth talks about the "basic backtrack" algorithm in fascicle 5 [0], which he u
322.
▲
by
trealira
2y ago
What they do is make assumptions like "null pointers are never dereferenced." So, they write optimizations that assume it doesn't happen. When their UB-oblivious optimizer runs into a situation where the user dereferences a p
323.
▲
by
trealira
2y ago
> (In my view, this is in fact what ANSI C requires for this type of "undefined behavior," but many others do not agree.) By not imposing any requirements for undefined behavior, ISO C does not require that, but maybe it ought
324.
▲
by
trealira
2y ago
I mean, the whole point of C is for it to be used by people who "know what they're doing" and just won't write code that dereferences invalid pointers (dangling pointers, null pointers, pointers that write past arrays, w
325.
▲
by
trealira
2y ago
Though I've only seen other people's Lisp projects online and in books, I haven't seen metaprogramming that made it less readable - usually, it makes the program more readable. At most, it defines a DSL, e.g. COMFY 6502, wh
326.
▲
by
trealira
2y ago
That's a fair point; not having first-class functions is a flaw for a high-level programming language, and the command pattern is just making up for a deficiency in the case that it would never need to be anything more than a closure i
327.
▲
by
trealira
2y ago
It's funny, because I had just recently read about there being a bug in that interpreter due to dynamic scoping, but forgot about when writing that.
328.
▲
by
trealira
2y ago
I have heard this said, mainly because some patterns can be made unnecessary with first-class functions and pattern matching. Closures are emulated with explicit objects, and the visitor pattern is equivalent to pattern matching. Something
329.
▲
by
trealira
2y ago
I suppose that, if I'm asked "What is something that makes homoiconic languages special?" and the answer can't be that it makes macros easy, then I would say it's that it's easy to write an interpreter for that
330.
▲
by
trealira
2y ago
> the code that is currently executing can be manipulated live Typically when people say this about Lisp, they mean that they can redefine functions and objects live, having all the code adapt to use the new definitions, or when their co
More ›