## Search found 4888 matches

Thu Sep 22, 2016 1:37 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

There should not be a space between the * and the p on the variable declaration. But what if putting spaces on both sides is designed to annoy adherents of both Type* p and Type *p at once? :-) I'd expect in a software company that there'd be such a code formatter though. I wouldn't; I doubt most c...
Wed Sep 21, 2016 4:25 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

for (SomeIterator iter = something; iter != end; ++iter) { SomeObject * p = *iter; #define wat continue if (p == NULL) wat; #undef wat foo(p); } That should pass code review, right? I have an iterator that "returns" pointers, of course. I have no idea why it's giving me NULL... I think it...
Wed Sep 21, 2016 4:09 am UTC
Forum: Coding
Topic: faster function than 1/x?
Replies: 18
Views: 9260

### Re: faster function than 1/x?

I'm pretty sure using a union is also undefined behaviour? I think it may depend on C vs C++. In C, it is not UB -- rather, it just produces a perhaps-partially-un specified result. However, from what I can tell it does guarantee that, if you are converting from type A to B and A 's "object re...
Tue Sep 20, 2016 4:04 pm UTC
Forum: Coding
Topic: faster function than 1/x?
Replies: 18
Views: 9260

### Re: faster function than 1/x?

Thanks for the excellent advice! @EvanED: No, singles are fine. I avoided using f(x1) <= f(x2), because then f(x)=constant is technically a valid solution. I should have said "floating point" rather than "doubles"... point is, you're not working with ints or fixed point. (Both o...
Mon Sep 19, 2016 8:54 pm UTC
Forum: Coding
Topic: faster function than 1/x?
Replies: 18
Views: 9260

### Re: faster function than 1/x?

Input and output need to be doubles? Do the comparisons need to be strict? (i.e. would 'x1 > x2' but 'f(x1) <= f(x2)' be a sufficient condition)
Thu Sep 15, 2016 11:46 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

To the rest of y'all, JS is a pretty decent language. ... As a heavy user of both JS and Python, the two are extremely similar . Guido, and hence Python, knows what a type error is. :-) (Yeah, I know I cut out the "if you enjoy languages without strict typing" part, but you can probably g...
Thu Sep 15, 2016 1:53 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

Seemingly unpopular opinion: JavaScript has the cleanest type system of all dynamic languages. Prototype based inheritance just makes so much more sense for a dynamic language than classes. Ugh. I haven't used JS enough to have an opinion on the prototype system, but there is no way that, even if i...
Tue Aug 16, 2016 2:34 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

Are you telling me that Notepad and Microsoft can be misleading? gasp :P So for what it's worth, I actually feel a bit of sympathy for MS on this one because of its history. Windows adopted Unicode very early, back when it was (I think... this is my impression, and I might be wrong) synonymous with...
Thu Aug 11, 2016 3:05 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

commodorejohn wrote:(It was a joke on EvanED's post.
If it makes you feel better, I knew what you were doing.
Wed Aug 10, 2016 5:32 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

I think I might have to work on my program's memory use. 353gb.png (You might think that this would be thrashing like crazy, but it was actually pretty well-behaved most of the time, as you can see from CPU% there. Though it is thrashing now as it's running destructors after program exit. I did have...
Wed Jul 20, 2016 8:44 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

Are there that many non-toy applications that use graphs but do not need high performance OR specialized structures? First, I'm not sure there are "that many", but I personally fairly frequently do one thing or another on a reasonably small graph (hundreds to hundreds of thousands of node...
Wed Jul 20, 2016 1:28 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

Graph data structures need to be tightly coupled to the problem they want to solve. Even something simple like DFS requires specialized data structures (i.e. a per-node flag that remembers if the node has already been visited yet). You wouldn't need to store that flag intrusively though. It might b...
Fri Jul 01, 2016 2:48 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

I don't know why you're adding the check to the initialization of stuff. stuff can be empty without problems. The representative is the problem. Unless some information was lost in simplification/anonymization of the code, that's where the check belongs. It's interesting you say that; when I was or...
Fri Jul 01, 2016 3:33 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

How terrible is this? struct Something { set<int> stuff; int representative; Something(set<int> const & s) : stuff((assert(!s.empty()), s)) , representative(*s.begin()) {} }; ? Would it be worth it to write something like: template <typename Container> Container const & ident_if_nonempty(Con...
Mon Jun 20, 2016 6:13 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

When linking to a compiled entity, you already need to find out or specificy its type, no? When adding exception inference to a language, the exception type will just have to be specified alongside the normal type. If you have to "specify" it, then it's not inferred. Or when it isn't, it ...
Mon Jun 20, 2016 5:46 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

Hmm, I wonder whether exception inference can solve the symptoms of checked exceptions. If type inference can transform the monstrosity that is Java into C++'s auto/Scala/Haskell, then surely exception inference can hide that complexity. Every expression is just a monadic function (Right? Am I righ...
Mon Jun 13, 2016 7:11 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

Pretty sure I've posted this before, but my absolute favorite DailyWTF is this "false detector" : public boolean checkFalse(Boolean bool) { if (bool.booleanValue() == Boolean.FALSE.booleanValue()) { return Boolean.FALSE.booleanValue(); } else { return Boolean.TRUE.booleanValue(); } } This ...
Mon Jun 06, 2016 1:54 am UTC
Forum: Religious Wars
Topic: Witches Vs. Wizards
Replies: 15
Views: 8411

### Re: Witches Vs. Wizards

Baba Yaga is the epitome of a witch, and is pretty damn cool. She's basically a cranky old grandmother... a powerful witch with "Godfather" like connections across the world and spirit realms. And also the inspiration for maybe the best music of anyone mentioned in-thread. :-) (Harry Pott...
Wed May 25, 2016 11:23 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

Right. (defun add-one (x) (+ 1 x)) is analogous to function add_one(x) { return 1 + x; } var add_one = function() { return 1 + x; }; // (or perhaps to this) whereas var add_one = new Function("x", "return x + 1;") is constructing a function from a string at runtime. I'm not actua...
Tue Apr 05, 2016 5:49 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

C++ allows both, although the C style declaration is really only used in forward declarations as far as I know. Sure, that's why struct S s; works. But struct S() to create a temporary doesn't, and that's really my complaint. It's not really a practical matter, but in the name of consistency I thin...
Tue Apr 05, 2016 3:30 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

\$ cat tags.cpp struct S {}; int foo(S s); struct S s; // including the tag is OK int i1 = foo(S()); // calling the default constructor is OK int i2 = foo(struct S()); // Calling the default constructor with the tag: Not OK?! \$ g++ -fsyntax-only -Wall -Wextra tags.cpp -std=c++1y huh.cpp:7:14: error:...
Thu Mar 31, 2016 2:21 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

ucim wrote:wat?

Oh, that's very easy to explain:
ucim wrote:(in PHP)
[/troll]
Tue Mar 22, 2016 7:57 pm UTC
Forum: General
Topic: Offline installers are rarer now
Replies: 32
Views: 16544

### Re: Offline installers are rarer now

First, wrong forum. [not anymore -phlip] Second, I suspect it's so that people will get the latest version of the software instead of installing something old just so that it can then go and be updated. So it's sort of a security issue, in the sense that installing an old version is generally a secu...
Thu Mar 03, 2016 1:26 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

redundant check for result.Rows.Count > 0 Why is that redundant? Is it not possible that result could exist but have zero rows? Yes, in which case the loop won't execute because of the test. But what if you omitted the test? Then the loop would execute zero times. Soooo... same thing! There's nothi...
Thu Mar 03, 2016 12:12 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

ucim wrote:What is even wrong with it? I assume you take exception to the (in this case unneeded) break statement
The break statement is needed (perhaps). What's not needed is the whole loop! Not to mention the redundant check for result.Rows.Count > 0.
Sat Feb 06, 2016 5:04 am UTC
Forum: Computer Science
Topic: what are the contents of Knuths The Art of Programming
Replies: 2
Views: 5057

### Re: what are the contents of Knuths The Art of Programming

Fri Feb 05, 2016 7:14 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

The illogic of using the word "implies" and the distinction from the typical English meaning may become clear when I make the following statement: (A implies B) implies (B implies A). From an English standpoint, this statement is false. The fact that A implies B does not in any way imply ...
Fri Feb 05, 2016 3:49 am UTC
Topic: 1638: "Backslashes"
Replies: 62
Views: 12228

### Re: 1638: "Backslashes"

Not a shell thing per se, but you can combine the head and grep: sed -n '/foo/p; 10q' out.txt (sed -n /foo/p = grep foo . 10q = quit at line 10 = head .) Your point stands, though. It's hardly an improvement. And even more what I was trying to get at, if you're building up your pipeline incremental...
Thu Feb 04, 2016 3:53 pm UTC
Topic: 1638: "Backslashes"
Replies: 62
Views: 12228

### Re: 1638: "Backslashes"

Depends what you call a "special" character, but: ... That's exactly what I came to the thread for. Thanks! The top one for me is... ------------------------------ ERROR OUTPUT ----------------------------------- Um, I suspect that was probably me pasting a file into the shell by accident...
Thu Feb 04, 2016 3:10 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

Btw C already has a clean circuited implication that implicitly converts to bool: !a || b. I'm not sure I'd call that clean, especially if the "operands" to the implies start becoming complicated. Perhaps this is my fault, but if I see that I don't start thinking about what it means in te...
Fri Jan 29, 2016 2:29 pm UTC
Forum: Religious Wars
Topic: 1/xy
Replies: 12
Views: 9755

### Re: 1/xy

Of course mathematically there shouldn't be a difference, but this is about notation, and how to make due with limited formatting options. But the other part of notation is to have predictable rules that lead to everyone having the same unambiguous interpretation. I agree that 1/xy seems like it sh...
Fri Jan 29, 2016 5:29 am UTC
Forum: Religious Wars
Topic: 1/xy
Replies: 12
Views: 9755

### Re: 1/xy

I think there is a clear answer -- (1/x)*y -- but I also think that anyone who seriously writes 1/xy in the first place should be banished from ever writing anything mathematical again.
Mon Jan 25, 2016 4:54 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

What's the warning message from GCC 6 anyway? It's an instance of -Wtautological-compare; it's some variation of "comparison is always false." I don't have access to the exact message ATM. Just for the record, I was slightly wrong; it's -Wbool-compare rather than -Wtautological-compare: \$...
Sat Jan 23, 2016 2:33 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

(And thank you to the C++ committee for allowing < and > on bool , though maybe I could by that was the least-terrible solution.) It's probably a side-effect rather than a solution: booleans may be implicitly promoted (note: not even converted in the case of an integer) to other types. Right, but t...
Fri Jan 22, 2016 4:25 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

\$ cat bug.cpp bool f(bool b) { return b < 0; } \$ g++-4.9 -c -Wall -Wextra bug.cpp \$ Thank you, GCC, for warning about that pretty-nonsensical, always-constant comparison. :roll: (And thank you to the C++ committee for allowing < and > on bool , though maybe I could by that was the least-terrible so...
Tue Jan 12, 2016 4:43 am UTC
Forum: Gaming
Topic: Dragon Age: Inquisition
Replies: 122
Views: 29995

### Re: Dragon Age: Inquisition

Late to the party, I know, but I got the GOTY edition of this a couple months ago and have been playing through. I'm not sure how far I am... probably 1/2-2/3 of the way through, at least trying to play pretty completeist. (I'm sure I'll miss a ton nevertheless.) And overall, it's a blast; I'm lovin...
Fri Jan 08, 2016 7:38 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

"It requires a copy constructor" is definitely the bigger objection there by a significant margin, though I'd argue that the copy-elision "optimizations" are of a much different character than most, in that they can actually change the non-timing semantics of your program. (In th...
Fri Jan 08, 2016 7:05 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9924
Views: 1884211

### Re: Coding: Fleeting Thoughts

Maybe this is religious wars, but I'll put it here for now... Goddammit C++ can be a terrible language sometimes. Some of this anger is directed at the fact that we're not using C++11 for some reason, but most of it C++98/03 deserves. template<typename T> void foo() { // declare and value-initializ...
Fri Jan 08, 2016 3:38 am UTC
Forum: Religious Wars
Topic: Editors
Replies: 267
Views: 127614

### Re: Editors

Wildcard wrote:Hence my modifying clause "If you were limited..."
What kind of flamewar would we be having if I actually responded honestly to your whole post? Sheesh.
Fri Jan 08, 2016 12:30 am UTC
Forum: Religious Wars
Topic: Editors
Replies: 267
Views: 127614

### Re: Editors

If you were limited to using a steering wheel and pedals for your spaceship control system, I hope you would have the sense to at least engineer in an "axis control" so that you could shift the abstracted "flat surface" on which your steering wheel would move you around. You mea...