« first day (802 days earlier)      last day (4145 days later) » 

6:13 AM
hi guys!
i've gotten some winterbash hats
how to put it on my avatar?
 
go to your SO profile, click on the hats info
 
8
Q: How can we see hats earned by ourselves?

AYKI have participated in the Winter Bash and can see that many users have profile icons with hats on it. I think I earned one hat, but cant see on my profile? Am I missing something?

 
6:54 AM
If someone copied an answer
What do I flag it as?
 
cpx
Perhaps write something in the box.
 
 
1 hour later…
8:05 AM
@Cheersandhth.-Alf oh, I saw using namespace std; there
 
8:15 AM
what the hell that for(nAttempts) is? GetWindowText fails only when handle is invalid. If it becomes valid later - it will be a handle of some new random window, not notepad. You should put FindWindow in that loop. — Abyx 26 secs ago
I didn't downvoted it yet, btw :)
 
8:34 AM
the attempts is because the buffer might not be large enough for the window text when it's retrieved, or the window text might be empty when the retrieval attempt is made. unlikely as that is, it's even more unlikely that it will happen three times in a row. also, notepad might have exited by the time the window text is retrieved, so some kind of checking is necessary anyway.
oh, the error checking should be a bit more...
anyways :-)
 
@Cheersandhth.-Alf IIRC, if buffer is not large enough it won't return an error
 
right, i already posted follow up on that
;-)
 
ah, yep
 
9:03 AM
@Cheersandhth.-Alf, uhm, if nChars == 0 you should call GetLastError and maybe call FindWindow again. Also, nChars == 0 if window title is empty.
 
well, i think the code as-is makes a reasonable effort (perhaps already unreasonable effort) to succeed in the face of an immediate retrieval failure. adding more complexity would make it less effective as an illustration of using Unicode. which is what the example is about.
and there is no practical chance of the window handle being reused within the time frame of the loop.
if there was such a chance, then you could also have a scenario where it was reused before getting the title, and then reused by Notepad again before the check... if it worked that way then one could not guard against it.
 
yeah... that's right. but same thing could be said about title length - it cannot change in such small time frame
 
9:18 AM
hi, does anybody know if there is a binary suffix for a constant, like ther is ULL , f and so on...
 
for GCC there's an extension for the 0b prefix
Otherwise, no.
 
:( tnx, I meant ISO C++11
 
You can maybe define a UDL.
 
meh, Im compiling in VS and in g++ so before VS 2014... no UDL :D
just joking, maybe they added it in CTP :D
either way too much work
0x <3
 
they didn't
 
9:23 AM
ah, it is one of thise things... now I need to encode a lovely set (0..64) into hex... iill just write a program I guess :D
tnx for the help
 
gyazo.com/4f4f79ab8d78c0f8aee9d1bf8230474f - oh my... I was such a moron =\
 
From binary to hex should be easy, I even translated decimal to binary through hex on one test when I forgot direct method ;)
 
I know, but I basically have an list of ints for which something is true, they are all 0-63 so Ill encode them in uint64_t
and in binary they are easily visible
"easily "
 
btw, you always can use '\x31\x32\x33\x34' instead of 0x31323334
 
Do a macro, like
#define _BV(a) ((1UL)<<a)
Then X1=_BV(1); X2=_BV(2);
 
9:31 AM
Ill just do a for and do binary or
in the loop
I just need to get the magic value once
it is constant
like pi :D
btw shouldnt it be 1ULL not 1UL
 
yeah, but macro would be more readble and it will be optimized to constant by compiler
 
because some longs are 32 bit afaik
you misunderstood me
 
@NoSenseEtAl right
 
ill generate constant in one program
and put it in the source
of the other
I just wanted a nice way to do binary... more out of "do it the right way" desire than from necessity
 
Ok, then what really do you want to do? Maybe some code example?
this macro isn't nice way?
you can do even _BV(0)|_BV(1)|_BV(2) to get bits 0,1,2 set
 
9:35 AM
I wanted to encode for example that for 7, 5 and 20 something is true. so I wanted to pack it into a int so that it has 5th, 7th, and 20th bit set to 1
 
_BV(5)|_BV(7)|_BV(20)
 
now im thinking even of constexpr :D
although that is g++ only :D
 
IMHO it's nicer than 0b000000000000010000
and after compiling it will be the same
 
either way it is gonna be ugly as hell, i have to set aprox 40 bits :D
 
oh
 
9:39 AM
either way tnx for the help
like i said i just wanted to do it the right way, aka suffix
it is not like i really neeeed it
so tnx and bye
 
bye
 
10:01 AM
damn - I can't believe how much shorter FP programs are compared to OOP versions... ...there's like virtually no room for bugs to creep in
(maybe OOP is naturally verbose or c++ OOP syntax is verbose - I dunno)
 
@kfmfe04 both
Good morning
 
guten morgen @sehe
 
@kfmfe04 cough
 
Ell
Fp is functional?
 
last few days I've been writing a bunch of function templates for Load() so that all my ORM/persistence code is all in one place - that worked ok. So my next step was to write a Fold() so that I can do one-to-many ORM mapping. Once that worked, Load_And_Fold() was a cinch!
@Ell aye
 
10:06 AM
@kfmfe04 Only, LoadAndFold would only make sense as a name for poker players
 
@sehe - haha - v.clever
 
No really, FP seems to forget about this a lot. 'car','cdr' anyone?
 
Ell
I don't know what they are
 
In fp, some abstractions are completely omitted and left to the programmer. I grant you, in the process demonstrating a lot of OO bread-and-butter abstractions don't actually pull their weight, yes
@Ell Point in case. It's like head and tail for lists
 
I've only begun to play with FP, but the more I do, the more I feel many (perhaps most) OOP patterns are obscenely, unnecessarily over-complex: most could never pass the rubber-ducky test... ...anyhow, I'm in my honeymoon period with FP - will have to play with it a lot more
 
10:10 AM
@Abyx oh, it can. because the title is controlled by the notepad application. in contrast, window handle reuse is controlled by Windows, and has been exercised by countless applications with no problem.
 
Ell
@kf which are uneccesary?
 
@Ell classes
@Ell Anyhoops, modern C++ agrees
 
Ell
I don't understand how you do anything without classes
Make everything an array?
But then you can't because arrays usually can only contain the same type!
 
@Cheersandhth.-Alf well, SetWindowText is definitely faster than destroying old window and creating a new one.
 
Ell
I love playing with winapi
 
10:15 AM
@Ell I haven't tried it en-mass, but if std::tuple<> functionality were filled out a bit more, they could certainly replace classes - there are many types of data-structures which could replace classes
 
Ell
I guess a dictionary could replace a class
Or std map
 
considering that memory is essentially just an array of bytes, it's certainly possible to do without the class abstraction. one can implement it in terms of arrays, as the view of memory as array demonstrates. but it's a heck of lot easier to have it supported by the language...
 
Ell
I just think classes would be a help of a lot easier
And they are pretty much language supported tuples anyway
 
sure - it's a matter of the right tool for the job - what makes c++ interesting is the array of tools you have in your toolbox
 
@Ell you're describing javascript now, that's dynamic typing, not FP
 
Ell
10:19 AM
I just don't understand how you could do without classes
 
@Ell "do it" - the unanswerable generalization
The essential realization would be that a lambda can replace a class. I'm not much into lisp/scheme anymore, but I think I could come up with a tiny (untested) sample
 
what I find amazing about FP is how much everything shrinks - even after implementation, while refactoring, I can reduce the number of template parameters by hiding associated typedefs inside the classes... ...it makes it a tiny bit harder to set up the class, but the interfaces are smaller, which makes it worth it
 
Ell
What's the difference between imperative and procedural?
 
@Ell what's the difference between philosophical and mystical?
 
Ell
Mystical is like fake :P
 
10:27 AM
@DeadMG you won't compete with GamErix's example whatever you try
 
10:37 AM
@EtiennedeMartel Oh yeah. He's spot on, tbh. The rest of the thread also makes that clear. It's the style that gets the attention, though
 
user142019
@sehe s/s//
 
user142019
GOOD MORNING PEOPLE
 
There are no people here, we are all short perl scripts
 
@Ell it's actually quite simple - with classes, you have state(member variables) which get modified by member methods called. The equivalent in FP is passing data through a bunch of functions that have no side-effects. result = f( g( input) ). So what you can do in OOP, you can do in FP, and vice-versa - it's just a different paradigm (hence, sehe's comment that a lambda can replace a class). Starting from scratch, it's probably harder to understand the very basics of OOP than FP.
 
@yetihehe oxymoron. No non-trivial oneliner in perl could be less than 1k
 
10:45 AM
what's harder to understand, or at least takes more time to appreciate, is that OOP and FP are orthogonal
 
@sehe Short is a relative term.
 
user142019
You can have pure functions in OOP.
 
user142019
Actually, you can do OOP without mutating any state at all.
 
@kfmfe04 I don't think it's true: FP is fundamentally simpler, but harder to grasp for complete noobs. This is a bit how calculus is 'purer' than geometry, but potentially harder to 'grasp'
 
user142019
You just create copies of objects every time.
 
10:46 AM
@yetihehe That's what she said
 
user142019
std::vector::size() is a pure function.
 
@Zoidberg'-- yawn
 
user142019
For the same arguments (including the implicit this) it always returns the same result.
 
user142019
Of course you don't care about pointers here.
 
@Zoidberg'-- Arguing about purity is just asking for flamebait
 
10:47 AM
@Zoidberg'-- cough. unless the argument was modified...
 
user142019
@sehe size() doesn't modify the vector.
 
@sehe that's why I said the VERY BASICS - but I know exactly what you mean - like folding in FP is pretty basic, but that may be too abstract for some noobs...
@sehe folding is prolly harder to understand than loops for most noobs
 
user142019
If you push_back, you don't have the same vector anymore. It's different.
 
actually, it most definitely is...
 
@kfmfe04 Yup. Precisely. That's why BASIC came about. And a lot of imperative languages behind that. Slowly they seem to be gravitating to a purer 'CS' type of languages, though.
It has been said that the good languages are slowly evolving into languages with the power of a 1970 Lisp
 
10:51 AM
what's old is new once again
 
user142019
Heh. I wrote a Lisp dialect parser yesterday.
 
@Zoidberg'-- I know. It's a deterministic function. But your description sucked. "it always returns the same result". Well, unless you make it exactly clear what "For the same arguments" means, that is just not right
@Zoidberg'-- I do that twice every saturday. Oh wait. That's not true.
 
user142019
With "the same arguments" I mean exactly the same vector with the same contents (i.e. == returns true).
 
@Zoidberg'-- The point is, in OO, identity vs. equality/equivalence confuses things. You have to be clear about what you mean
@Zoidberg'-- Better. Of course, in C++ that means nuttin because operator== doesn't even apply to vectors
 
user142019
Wait
 
user142019
10:53 AM
 
user142019
Also, you don't talk about object identity in FP. :P
 
@Zoidberg'-- That's the point. Which is also why you don't talk about purity in relation to std::vector<>::size()
@Zoidberg'-- Blimey. Since when did that exist. Why?
@Rapptz That's crazy. Useful, but crazy
 
Since forever ago?
 
user142019
I would've been surprised if == didn't apply to vectors.
 
It's so completely arbitrary and unperformant.
 
10:56 AM
Why?
 
user142019
It is there for completeness.
 
@Zoidberg'-- I never even considered to look for it. I know there is lexicographical_compare, so...
 
user142019
Vectors are comparable objects, so those operators should be there.
 
@Zoidberg'-- That's circular logic. You just used 10 words to add nothing (besides being slightly sloppy about equatable and comparable)
 
user142019
Sounds like someone's got a case of the Wednesdays!
 
10:57 AM
That must be it
Anyways, it was circular logic
 
Why is it bad that it's provided?
I don't understand unfortunately
 
It isn't
 
user142019
It's not bad. It's good. You want this.
 
user142019
What if you want to use a vector as the key for a map? :^)
 
So why is it crazy? :(
 
10:59 AM
I just mentioned it suprises me. It's a high-cost operation. And it's ungeneric. I'd expect <algorithm> to cover these things
 
std::equal?
 
You know, why stop at vector<T> vs. vector<T>? Why not vector<T> vs vector<Y>? And vector<T> vs set<Y>
@Rapptz Precisely
 
Now I feel like.. switching my operators to use the <algorithm> equivalents
 
user142019
If it's a high cost operation, why would <algorithm> not be a high-cost operation?
 
user142019
(Or do you want different semantics?)
 
11:01 AM
the one in <algorithm> according to cppreference says that is has "At most last1 - first1 applications of the predicate" complexity
 
user142019
That's the same with ==, since you want to compare all objects anyway. Unless your implementation is written by a moron.
 
It actually goes on to say that operator== is preferred when comparing whole containers so I guess I don't know or care.
 
@Zoidberg'-- The point is, usually std containers only provide member functions for operations duplicated in <algorithm> iff their implementation can be made more efficient
 
user142019
Maybe std::vector is older than <algorithm>.
 
@Rapptz Whoa. That's nice. Where?
 
11:03 AM
@sehe Under notes. "When comparing entire containers for equality, operator== is usually preferred."
 
user142019
Wait.
 
@Zoidberg'-- Makes sense. It isn't, but parts might be
 
user142019
Maybe == can be implemented more efficiently.
 
@Rapptz "usually" - so it conjecture, even in the context of non-normative text.
Anyways, it echoes the sentiment: by convention, you use operator==
@Zoidberg'-- True that. See vector<bool>. I'm convinced
 
Typically speaking it is much easier to write digit1 == digit2 vs std::equal(digit1.begin(),digit1.end(),digit2.begin(),digit2.end());
 
user142019
11:05 AM
lol
 
@Rapptz You. Don't. Say. Also: digit1 must be the worst name for a container object ever
 
It is a generic example :(
 
user142019
#define EQ(a, b) std::equal(a.begin(), a.end(), b.begin(), b.end())
 
lol
 
(unless it's a container containing the bytes in the unicode code point for a chinese digit, or sumtin)
@Zoidberg'-- cough
 
11:06 AM
@Zoidberg'-- it should use std::begin()
 
user142019
@sehe in my project for school we have a class called Coins which is a counter for the score. The fool who wrote it forgot he could name his classes ScoreCounter.
 
@Abyx @Zoidberg'-- and be a template.
 
user142019
@rubenvb A template macro. Hmm.
 
What's the difference between std::begin() vs container.begin()?
 
or have more parentheses, like (a).
 
user142019
11:08 AM
@Rapptz std::begin works on C-style arrays.
 
@Zoidberg'-- Cough. Joking, right
 
@Zoidberg'-- no, just a template.
 
user142019
@sehe nein!
 
I knew that I forgot we were discussing your macro
 
the macro like above will evaluate a and b twice
which sucks and is very unexpected.
 
11:09 AM
@Zoidberg'-- ScoreManager? ScoreController? ScoreBuilder? ScoreCountingObject? come on. You're Java infected already
 
user142019
lol
 
user142019
You know what?
 
you don't need a class to keep score
 
user142019
^ that
 
@rubenvb pssst. I think he knew
@rubenvb Precisely
 
11:10 AM
ScoreBusinessLogic?
 
user142019
Just have public int score; in your world class already. T_T
 
user142019
xD
 
yeah. Well. Mr. Obvious is in da house!
 
@Zoidberg'-- Or... a Amount score;
 
I'll be here all week.
 
user142019
11:10 AM
BUT THEN THE TEACHER GIVES -1 BECAUSE WE USE PUBLIC ATTRIBUTE AND THAT IS ALWAYS WRONG!!!!!!11
 
@Zoidberg'-- use struct and hide the public:
 
user142019
@rubenvb Java.
 
@Zoidberg'-- That's even wronger :)
 
user142019
I want to see my teacher write a Point class and use getters and setters.
 
getX(), getY(), setX(), setY()?
 
user142019
11:12 AM
:^)
 
That stuff drives me mad
 
@Zoidberg'-- this is the C++ lounge. Everything is C++. Period. Dot. EOL. EOF.
 
user142019
Java is so fucking fucked-up. It's conventional (for a long time, I think) to use getters and setters, yet you must fucking write them yourself unlike in C# which has { get; set; } or even Objective-C which generates this crap for you.
 
user142019
@rubenvb s/C\+\+/Haskell/
 
QED?
 
user142019
11:14 AM
And then the syntax is horrible. .getX, .setX. I WANT .x AND .x = TO INVOKE THE GETTERS AND SETTERS.
 
Ell
Yeah
 
user142019
In Objective-C you can use both .x and x and .x = and setX. xD
 
user142019
So if you don't use camelcase, you're screwed.
 
Ell
I like Pascal case
 
user142019
foo.x = 42; is just syntactic sugar for [foo setX:42];.
 
11:17 AM
@Zoidberg'-- That'd be a lie. There's no Haskell lounge
 
user142019
I wonder what would happen if I do this in Objective-C.
 
Anywhoops: I'm scanning this presentation: slideshare.net/adankevich/c11-15621074 describing what's new in C++11
It looks very well done to me
 
user142019
- (void)setURL:(NSURL *)URL. I hope foo.URL works otherwise you have to use foo.uRL. :P
 
The best thing is: he doesn't even mention move semantics until page 47
 
user142019
Also . operator on pointers looks weird.
 
11:19 AM
Meh. Stop talking about ObjC. It is weird
 
user142019
Objective-C is great!
 
user142019
I should write my kernel in it.
 
C++ Y U NO ABI?!
 
user142019
C++ Y U NO MODULES?!
 
fuck modules, now I want ABI
 
user142019
11:23 AM
You want an ABI? Why not multiple ABIs? Isn't that much better?! :D
 
@Abyx You fail to see how they are related?
 
I want ABI for my DLLs, so I could export foo(wstring) instead of foo(wchar_t*)
I don't believe C++ modules will support DLLs, ever
 
@Abyx release your source and don't complain.
 
user142019
What do you want for Christmas? Modules, std::make_unique, auto without trailing return type and a standard ABI.
 
all of them.
 
11:26 AM
@Abyx and ABI has little to do with DLLs. Static libraries are just as fucked.
 
user142019
@Abyx if you need ABI for dynamic libraries the most portable is export "C" and provide a C API.
 
user142019
Then you can provide an open-source C++ API on top of that. xD
 
that's even a pretty neat idea.
 
no way. it's closed-source thing
 
user142019
Yeah I know.
 
user142019
11:28 AM
So provide a C API.
 
user142019
You can wrap that API in C++ if you want, and open-source only that part.
 
user142019
Not everything has to be closed-source, unless the requirements are absolutely terrible.
 
user142019
Ohh
 
user142019
unless you don't want a public API, but then it doesn't even make sense to open-source the wrapper.
 
well, actually it's not exactly a "C API". I just can't can use some of standard library classes.
 
user142019
11:32 AM
Meh. Now I'm in the mood to write something in C.
 
...header-only classes with well-defined layout don't require any ABI
 
user142019
no way. it's closed-source thing
 
Ell
I wonder why there were multiple c++ implementations in the first place
 
fortunately, VC++ has ABI for virtual functions, so I can use abstract classes in my API
I mean stuff like COM
it's not "C API", it's sorta C++ish, but still I want goddamn std::string =\
 
user142019
Just use char const* and size_t already.
 
user142019
11:39 AM
Then just construct an std::string from that again on the other side.
 
Ell
I mean, Abu
*abi
Or someone write their own library format :L
 
user142019
You cannot have a standard ABI.
 
Ell
Why not?
 
user142019
Architecture A has more registers than B. A is 64-bit, B is 32-bit. On A, passing arguments one way is faster than the other way. On Windows, the stack frame is created by the caller (IIRC), on POSIX, the stack frame is created by the callee (IIRC).
 
user142019
The latter may be standardized, but still, the other ones are unavoidable.
 
user142019
11:45 AM
Heck, implementation isn't even required to use stack frames.
 
user142019
Name mangling issues. On OS X, function names are always prefixed with a _ unless they're written in assembly or have certain __attribute__s.
 
Ell
Hmm
 
Ell
12:16 PM
Water, y u so freezing cold!
 
user142019
 
Ell
I was extpecting type inferrence when I read var
 
that's actually pretty cool
 
Ell
Oh Its A library
 
humm I can't get hell world to compile on my mac using clang++ :(
IIRC I had issues some time ago with a broken clang installed by Xcode or somehting
 
12:25 PM
hell world is a hot topic :D
 
user142019
#if 0
"""
#endif
int main() {
    printf("Hello, world!\n");
}
#if 0
"""
print("Hello, world!")
#endif
 
user142019
CPython!
 
heh
ah nice @Zoidberg'-- ur spending quite some time with Python?
 
user142019
@Nils no.
 
user142019
I rarely use it.
 
12:28 PM
ok
 
user142019
Wait that's not valid C.
 
user142019
return 0; can only be omitted in C99 and C11, but both require functions to be declared before you use them.
 
user142019
There must be #include <stdio.h>. :P
 
@yetihehe "hell world" - don't go there
 
user142019
This one is valid C, valid Python and valid Haskell (in GCC with -XCPP): gist.github.com/4380140, I think.
 
12:38 PM
Can I copy the contents of a file directly into a vector using ifstream and std::copy?
 
user142019
Oh wait fuck. The Haskell versions includes <stdio.h>. XD
 
user142019
I should check if GHC is not being used using an #ifndef. Oh well.
 
I fail to find a proper C++ solution to read ints from a file into a vector.
Most of the code samples online seem to be flawed somehow.
also why do we need streampos?
 
What do you mean by "flawed"?
 
Simplest thing which works: codepad.org/XFKVFvVM
Now assuming I want to put the values into a vector. To do it properly I should first seek the end of the file to figure out how long it is and set the size of the vector, before putting the numbers into it.
But ifstream just gives me that damned streampos!
ah and number of bytes != number of values
 
12:53 PM
You don't need to, just use push_back, vector will grow automatically. Setting size beforehand is just a little more eficient
 
So most proper would be first put everything into a string, then count the num words and then copy into a vector of ints
 
push_back is amortized constant time
 
@Nils No need for std::copy, substitute std::cin by std::istream& of your choice.
 
humm
 
@irrelephant Only when you reserve enough space
 
12:56 PM
What do you mean?
 
god damnit Clang
try to do something remotely unusual and crash.
 
:6874151 Complexity:
Constant (amortized time, reallocation may happen).
*If a reallocation happens, the reallocation is itself up to linear in the entire size.*
Reallocation happens when storage space in vector is not enough to add next element
 
Correct link is liveworkspace.org/code/MjExMz$1, I can thank markdown I suppose.
 
user142019
@DeadMG clang = PHP!
 

« first day (802 days earlier)      last day (4145 days later) »