Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
gsg
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
35 ms
·
271.
▲
by
gsg
14y ago
I'm aware that it will return the right answer, but I was worried that it may look at too much of the url string in order to do so. Consider the (admittedly perverse) input "test.php?a=1&a=1&a=1&a=1&a=1". At each comparison,
272.
▲
by
gsg
14y ago
How is testing for a terminator the right approach? The comparator is only supposed to look at a single parameter, and the only null byte in the url string is at the end...
273.
▲
by
gsg
14y ago
Your insertion sort scans downwards from the highest populated index, bumping elements up as it goes. Given that you have space on both sides, I'm surprised that you didn't start in the middle and pick a scan direction based on the comparis
274.
▲
by
gsg
14y ago
Have a look at http://blog.regehr.org/archives/523
275.
▲
by
gsg
15y ago
If you read the BitC documents, Shapiro mentions that one of the goals of the project was to avoid innovation. The BitC goal isn't to invent a new language or any new language concepts. It is to integrate existing concepts with advances in
276.
▲
by
gsg
15y ago
When I was first learning elisp, one of the utilities I wrote was a flood-selection feature that sounds very similar to what you describe. Interestingly, it turned out to be quite useful in C code despite only being aware of string and pare
277.
▲
by
gsg
15y ago
Sure, I wasn't arguing against C++.
278.
▲
by
gsg
15y ago
Huh? That link claims "The STL will not work in kernel mode and cannot be used", which is not much of a surprise given the STL's use of exceptions and dynamic allocation. In any case, kernel guys seem to prefer their data structures in intr
279.
▲
by
gsg
15y ago
void (int i, struct { float f; bool b; }) f; Apart from f being in the wrong place (and bool not being defined without including stdbool.h), this is a valid C declaration.
280.
▲
by
gsg
15y ago
I've always found it unsurprising that people find typedefs confusing. They're a storage specifier, which allows for some questionable constructs: int typedef x; typedef what; struct { int x; } typedef *x, y; enum { x } ty
281.
▲
by
gsg
15y ago
Yes, CompCert is no timeless perfect gem. You could make a convincing argument that it's not really verified software in the Djikstra mold at all (only parts of the compiler are verified, although they are fairly large and interesting parts
282.
▲
by
gsg
15y ago
People certainly have written real software using formal methods: http://compcert.inria.fr/ is a good example. Of course this does not constitute an argument that programming must be taught as a formal discipline, but it does indicate tha
283.
▲
by
gsg
15y ago
You mean this one? int binary_search_pow2(const int a[], int len, int key) { int i = 0, step; for (step = len / 2; step > 0; step >>= 1) if (a[i | step] <= key) i |= step;
284.
▲
by
gsg
15y ago
No mention of representation issues? Memory is a big optimisation target these days, and a weak point of languages like Java and OCaml.
285.
▲
by
gsg
15y ago
Casting the result of malloc isn't a good idea in C because it can hide the lack of a prototype if you forget to #include <stdlib.h>. It's also a redundant mention of the type name in question, making for more work / noisy diffs und
286.
▲
by
gsg
15y ago
If you have a function that returns a function, basically you need to rewrite things to lift the referenced state into the outer scope. In pseudo-C: (void -> int) incrementer(int initial_value) { int count = initial_value; retur
287.
▲
by
gsg
15y ago
That would require changing every single existing header that currently contains reserved identifiers. Do you have any idea how much work that is? Even if you could somehow magically enumerate and alter them all - and test them, since the n
288.
▲
by
gsg
15y ago
The goal is not just to allow for new keywords. Reserved identifiers are also intended to be used in system headers to protect implementation code from the unfortunate effect of user defined symbols. Go and read your /usr/include/stdio.h (o
289.
▲
by
gsg
15y ago
A bit suspicious, maybe? I was trying to suggest the unsigned issue without actually spelling it out, not anything to do with side effects. I probably should have used sizeof, even though that doesn't make sense there.
290.
▲
by
gsg
15y ago
You don't need to do wacky things with pointers to get into trouble in C: int i; /* Iterates over everything except the last n elements of array... right? */ for (i = 0; i < length - innocent_little_function(); i++) do_so
291.
▲
by
gsg
15y ago
Crit-bit trees don't branch per bit, they branch per differing bit. Much more efficient for most data sets.
292.
▲
by
gsg
15y ago
Crit-bit trees are not radix trees. A crit-bit tree stores next-different-bit positions at branches and entire values at the leaves, and is searched by following branches depending on the value of the relevant bit in the search key (the "cr
293.
▲
by
gsg
15y ago
You are conflating virtual memory and swapping. A disk-backed page cache is not necessary for memory protection.
294.
▲
by
gsg
15y ago
O(1) prepend doesn't conflict with good contiguity at all. Deque is an useful data structure with (possibly amortised) O(1) prepend and append, O(1) indexing and excellent contiguity.
295.
▲
by
gsg
15y ago
& and | have the wrong precedence because in primordial C they were both either short-circuiting boolean or bitwise depending on context. :(
296.
▲
by
gsg
15y ago
Why would you deny allocation requests larger than immediately available physical memory when they could be serviced perfectly well by paging? On modern systems malloc and friends manage address space, not physical memory. Failure should on
297.
▲
by
gsg
15y ago
I think it does matter, although my example fails to make clear why. Type identifiers have different syntactic requirements to regular identifiers (the parens in sizeof(typename) are required, but the parens in sizeof(varname) are optional)
298.
▲
by
gsg
15y ago
No, consider int x; sizeof(x); and typedef int x; sizeof(x);.
299.
▲
by
gsg
16y ago
That's not a fair example. There are languages that have lambda expressions but not the lexical scope that requires closures, whereas there are no languages that have class definition expressions but not classes. Given there is a meaningful
300.
▲
by
gsg
16y ago
|| is conditional, not relational.
More ›