« first day (545 days earlier)      last day (4625 days later) » 

21:00
Why
strcmp(str, "ciao");
doesn't work? "ciao" it's a string!
Don't use that.
it is a const char*
That's not C++, that's C with Classes at most, or just C.
Also strcmp returns 0 when strings are equal.
I know
But the error is on the function
21:01
It's not C++ either way.
try strcmp(str.c_str(),"ciao") ;
error: cannot convert 'std::string' to 'const char*' for argument '1' to 'int strcmp(const char*, const char*)'|
||=== Build finished: 1 errors, 0 warnings ===|
Use std::string with == unless you have a very good reason not to do so.
str == "ciao", gawd.
@unNaturhal why are you using strcmp? Don't do that in C++
21:02
Stay away from C library, especially if you don't know the difference between std::string and const char*.
@LewsTherin: Yai, now it works...
@MooingDuck: And what you think that is better to use?
I think there is also std::string.compare method
compare is for substrings.
@unNaturhal str == "ciao"
@CatPlusPlus Ok
21:04
@MooingDuck O_O
@unNaturhal ?
That's the only sane way to do it in C++.
If at least one of the operands are of type std::string, of course.
@CatPlusPlus compare is for when you want the -1, 0, 1 thing. It simply also happens to also have overloads for substrings
Hmm, does Jeff Attwood really only have a 32% accept rate (on meta, don't know if that matters)
@daknokt So, when my professor says "You cannot compare two not-atomic typy" he was lying...
@unNaturhal that statement is so far from wrong I would assume you simply misheard/misunderstood
@unNaturhal since I'm pretty sure you don't know what atomic types are in C++
@unNaturhal You can always do that. The semantics may vary, but even that may be fixed by overloading operators.
@MooingDuck too true
21:07
Or the 'professor' doesn't know C++, which wouldn't be that far fetched.
@sehe I assume he's referring to not being able to compare char* and get the expected result.
@unNaturhal you cannot compare C-strings (aka null terminated char arrays) using ==, but with std::strings you can. I suggest you read a good book on C++.
@MooingDuck that's why I menion overloading
@sehe can't overload two char*, but most other cases you can
@daknok_t I'm reading Thinking C++
21:08
@daknok_t std::string matches std::operator==(const std::string&, const char*) and others
@MooingDuck who said otherwise? I think I know
@sehe I know, that's what I said.
@MooingDuck int, float, double, char, bool. These are atomic types
@sehe your statements were ambiguous/misleading regarding that.
@unNaturhal no, those are primitive types. atomic types are completely different
@unNaturhal Those are primitive types. atomic means something entirely different (it is related to threading)
@sehe in fact, that operator isn't overloaded for std::string and const char* at all, instead the std::string constructor is implicitly called when a const char* is passed.
21:09
@MooingDuck Could you explain me the differences?
@daknok_t Sigh :) That's not what you said. It's what you meant, but I wanted to explain the mechanics to @unNaturhal
@unNaturhal atomic types are like std::atomic<int>, which I doubt you're using
@sehe reminds me of an old quote.
> Computers do what you tell them to do, not what you think you tell them to do.
2
@unNaturhal it's merely a vocab thing
Primitive types can be called atomic, too.
21:11
@CatPlusPlus it's misleading, but they could be
The same way fields in an 1NF database are atomic.
I think I know what's happening, because it's happening to me too: we over-use (me included) the 'respond-to-this-message' arrow icon, which makes it appear like we are telling each-other stuff (that we already know), just because the chat displays it in @user style (@daknokt @MooingDuck)
@MooingDuck ...I have never seen atomic<int> before..
@unNaturhal Keep it that way. For another year or so :)
@sehe In actuality, what we're all doing is elaborate on each other's messages, to clarify more to the asker (in this case unNaturhal)
@unNaturhal you don't need it until your third or fourth year of C++. That's why I figured you were dealing with primitives instead :D
@sehe probable
21:13
@MooingDuck Is that a law? I never even had a year of C++
@MooingDuck Hehe. I auto-responded to make the link clear :)
@sehe obviously not, just a rule of thumb. Some people never get that far, some get there right away, but at college class rate (here), it's about 3rd or 4th year of study.
@sehe I apologize, but my english isn't good enough to be able to read all message, understand what is written, and reply to each one... So I have to focus on a message at a time
Little and probably simple question, what's the difference between a token and a terminal as in lexical analysis? I can't figure it out… Are terminals just token names?
@MooingDuck I can see the 'reality', but I'd really resist putting that kind of statistic in generalized statements. But perhaps that's why I dislike schools etc.
@unNaturhal you can compare all the primitive types, but with pointers, you might not get the results you want. That's why we have std::string and std::vector. They are magic, and just make everything work.
21:16
@MooingDuck I assure you that my professor colled them "Atomic Types"
I kindly request you to invite your professor to this chatroom. :)
@unNaturhal he used the wrong word. std::atomic is new, he might not know about it yet. Tell him that there is a std::atomic, and the correct term for int and char and similar is... actually I'm going to doublecheck what the "official term" is.
@daknok_t A terminal is a symbol that cannot be decomposed anymore. Think to BNF, a terminal is each symbol that isn't included between < and >
I'd hate to say it was "primitive" and turn out to be wrong
they're typically called primitive
21:18
@unNaturhal you mean < and > in XML?
but since "atomic" basically means indivisible, I guess you could call them atomic too
we have builtin, primitive, cardinal IIRC. Cardinal might be a C99 term
in that they're not compound types
Which is what I said.
yup
21:19
Not everyone uses nomenclature lifted from the standard.
@unNaturhal int, char and such are officially "Fundamental Types"
@CatPlusPlus lol @nomenclature in that statement
@daknok_t Nope, in backus-naur form.
@jalf it's colloquially correct, but misleading. I prefer it not be used that way.
What, wrong word?
21:20
@MooingDuck So, it they are not primitive and not atomic, what they are? :P
Nope, but a bit amusing to say 'not everyone uses jargon' in .... highly specific jargon
@unNaturhal they are "Fundamental" apparently. I just looked it up § 3.9.1
We certainly almost seem "Fundamentalists" here
Fundamentalist pedants.
@unNaturhal ah, so if I have <foo> ::= "bar" | <qux>, bar is a terminal and qux and foo are non-terminals, right?
21:21
@StackedCrooked Pendants? Wrote too much in French, lately?
Terminals in grammars are leaves of the parse tree.
@MooingDuck Mmmh... But in this assumption, std::string is a type like int, char, float ecc, or it's something complex?
@CatPlusPlus @unNaturhal thanks, I got it!
@daknok_t Exactly!
@sehe Lol, didn't see it.
21:22
Terminals, softly bristling in the morning breeze
Tokens are just names given to lexemes before parser goes into play.
@unNaturhal std::string is a "compound type" which is provided by the "Standard C++ Library". It's not part of the language at all.
That probably is the wrong word. Whatevr.
@CatPlusPlus Yeah, who doesn't know that!?
Everyone had lexemes at least once in their lifetime.
I suck at writing lexers…
21:25
The point is, tokens and terminals are used into different stages of parsing.
The fundamental types are char, unsigned char, signed char, signed short, unsigned short, singed int, unsigned int, signed long, unsigned long, signed long long, unsigned long long, wchar_t, char16_t, char32_t, bool, float, double, long double, and void(but void is incomplete)
@CatPlusPlus tokens are used in lexical analysis, and terminals in assembling the AST?
Compound types are arrays, functions, pointers, references, classes, unions, enumerations, and pointers to nonstatic class members.
I'm using Boost PP to add a little syntactic sugar on top my design and come to realize that I might as well have done it all in Boost PP.
Why are you writing a lexer, anyway?
Generate it. Or use Spirit.
21:28
@CatPlusPlus I'm learning.
@MooingDuck Yeah! And for this reason (because is not a part of the language), it should not be possible to use == operaton on it. This is the reason of my surprise..
@unNaturhal in C++ one can overload operators.
So you can make operator== do anything you want, like comparing two objects for equality or taking a picture using a webcam over the internet.
@unNaturhal Actually, C++ is designed so that whatever class comes "last" tends to be the most compatible with other types.
@daknok_t Woooo O_O
Taking pictures in operator== is not recommended :(
21:34
@MooingDuck Mmmh I think to have understood...
I'm starting to think that Thinking C++ is no so good...
@MooingDuck LOL? xD
@MooingDuck but it is possible. :P
@daknok_t C++ has ways to do whatever you want, and merely hopes you will use the power wisely.
"With great power comes great responsibility"
@MooingDuck ...if you are Spiderman
@MooingDuck obviously, a URL class' operator== will talk to a DNS server to check if the domain names resolve to the same IP, because that is a requirement for URL's to be equal. No kidding, this is how Java does it…
C++ gives you the power to responsibly shoot yourself.
4
21:36
@Mysticial or anything else in your virtual memory space
@daknok_t it probably skips that step if the strings are equal
@Mysticial but if you do, you'll blow away your whole leg.
@MooingDuck but it won't if they aren't, which is more likely.
docs.oracle.com/javase/1.4.2/docs/api/java/net/… "Since hosts comparison requires name resolution, this operation is a blocking operation." That's impressive :/
@Mysticial Specially when you work with strings..
More reason to hate Java!
@MooingDuck Why would you hate the kid with the cobblers shoes?
21:40
@MooingDuck wow, that is so... broken
@CaptainGiraffe I'm slowly learning to not take you seriously so much
@MooingDuck But now, to empty a std::string, which is the best way?
@unNaturhal mystr.clear()
I wonder what happens if you try to construct a URL with a nonexistent host. I guess it is "equal" to any other nonexistent host?
21:41
@jalf or if you have no network connection…
@jalf The docs say. I think it compares inequal in that case, unless it's NULL.
@daknok_t now that is an interesting thought.
@MooingDuck how amazingly idiotic
That class' "equals to" method/operator/whatever is completely useless.
What api are we discussing?
@unNaturhal The list of string's members can be found at `msdn.microsoft.com/en-us/library/5zz6weyz(v=vs.71).aspx, but note that the free operators are not on that list
21:43
@CaptainGiraffe Java's URL class.
It needs network access to do a simple compare.
Well, thats easy, the URL class in Java has the same intention as the File class in Java.
@daknok_t luckily no other operation seems to need resolution :/
@CaptainGiraffe which is?
Its not a real URL/File its a url/path string
huh?
21:45
There is URI which won't do domain name resolution, AFAIK.
@MooingDuck Why are so different than cplusplus.com/reference/string/string ?
No validation whatsoever
@unNaturhal cplusplus has C++03 (and errors), MSDN has C++11
cplusplus.com is unreliable. The only reason it's popular is because it's on top in the Google results, probably because of the domain name.
21:46
@jalf "if either host name can't be resolved, the host names must be equal without regard to case; or both host names equal to null."
ugh that site SUCKS
But it is very convenient to create actual IO to files and paths from it.
it's like reading athe funny papers upside down
@ChetSimpson what site are you talking about?
@unNaturhal sorry, I linked the webpage from 10 years ago. Here's the latest C++11 one: msdn.microsoft.com/en-us/library/5zz6weyz(v=vs.110).aspx
21:47
If you were bashing Java IO you had the wrong troops.
@MooingDuck Well... D:
cplusplus.com
@unNaturhal here's another version of the same info: en.cppreference.com/w/cpp/string/basic_string
@CaptainGiraffe No, I think it's still perfectly fair to bash the URL class. It's absurd behavior, whether or not it was intended
@MooingDuck Much better :)
21:49
Are we (as stackers) accepting cplusplus.com now as a fair source or are we still reluctant because of its errors?
I use it as a reference whenever it agrees with me :p
@jalf I would disagree, What about URLConnection?
@CaptainGiraffe I can never remember which is which. I use MSDN.
@CaptainGiraffe cplusplus.com is horrible. It has a tutorial about C with Classes and the reference is unclear and contains mistakes.
@CaptainGiraffe what about it?
21:50
Bad education harms.
However, I can continue to read Thinking C++, or it's better if I burn it?
The same would go for w3schools
A blocking equals function which, in addition to blocking, tries to do network I/O is broken. There's just no way around that
@jalf WTF? Is that really the semantics of the URL class?
you've got to be kidding me
I'm still ambivalent on wether their usefulness outweighs their inaccuracies/faults
21:51
@unNaturhal Thinking C++ or Thinking in C++?
@DeadMG didn't you read the link?
just got here
Ah. Then yeah, those are the semantics
14 mins ago, by Mooing Duck
http://docs.oracle.com/javase/1.4.2/docs/api/java/net/URL.html#equals(java.lang.‌​Object) "Since hosts comparison requires name resolution, this operation is a blocking operation." That's impressive :/
21:52
The host part is considered equal if the both resolve to the same IP
@unNaturhal That book is on the book list so it's a good book. Keep it.
@jalf the equals blocking is horrible if it is true.
@CaptainGiraffe er, it is. That's why I'm saying it's broken
@daknok_t So it's the italian translation that sucks xD
21:53
I thought you actually knew what it did when you said it wasn't
@StackedCrooked no the URL class. URI doesn't block, URL does. But since they are Java classes it doesn't really matter; they both implicitly suck.
@jalf The docs says you are wrong. At least the 6.0 docs
@StackedCrooked no, the URL class
@CaptainGiraffe you mean the docs which we just quoted?
> Two hosts are considered equivalent if both host names can be resolved into the same IP addresses; else if either host name can't be resolved, the host names must be equal without regard to case; or both host names equal to null.
Ouch.
21:55
@jalf Yes tghe 1.4 docs you just quoted, the 1.6 says its a field by field comparison
I quote FOR THE FOURTH TIME IN THIS DISCUSSION
Two hosts are considered equivalent if both host names can be resolved into the same IP addresses; else if either host name can't be resolved, the host names must be equal without regard to case; or both host names equal to null.

Since hosts comparison requires name resolution, this operation is a blocking operation.
@CaptainGiraffe I just posted the 1.7 one which says the SAME DAMN THING
Couldn't you at least read the link before saying we're wrong?
I think we agree that it sucks.
@CaptainGiraffe THe URL class is not the same class as the URI class. I think that's the confusion.
apparently not. @CaptainGiraffe still refuses to believe that it does what we say the documentation says
@StackedCrooked Java sucks anyway.
5
21:56
lol
Java is not fun to work with.
@jalf My reading comprehension sucks, I have a 5 minute ban in effect from now.
it's Java, how can it not suck?
Java was designed by a moron for morons
@CaptainGiraffe ;)
I wrote a game in Java once. That was my first and last experience with Java.
21:57
JVM is pretty solid though.
@daknok_t we did a raytracer in java on first year at uni
@StackedCrooked I wonder, if it does a resolve on the object on every equals, a.equals(a) may return false if there is a load balancer in the DNS. gotta love java :)
@StackedCrooked especially if your coworkers use exceptions only to change the global state of the program :(
unless it's underlying semantics are fundamentally different to those of Java, then I'm pretty sure that the JVM must suck
was fun enough, but I haven't really missed the language since then
21:57
@MooingDuck Huh?
I've seen exceptions used because "goto's are always bad" aaarrararaggg.
@StackedCrooked at my job, our Java code uses exceptions only to switch the global state of the program from one section to another section.
@DeadMG I've seen talks by JRuby and Clojure language designers and they were both very positive about JVM. I can only go by that.
@MooingDuck I can't even imagine how that is supposed to work.
The only pro of the JVM is that everyone has it installed and that you can use a giant library of classes.
yeah, I can see it now
"We implemented useful features by hacking around the fact that the JVM sucks."
21:59
Lol.
Are you making that up?
yes
it was my idea of what a JRuby language designer might say
Worst part about JVM is slow startup language.
MacRuby ftw.
@daknok_t "Gotos are considered harmful" Thats the title of our gurus paper.
Imagine running find . | xargs my_jruby_script
22:01
@CaptainGiraffe Welcome to 1980? :P
think I'll boot up my model III
@DeadMG I believe it was written in about 1973
hey all
hello
22:04
@MooingDuck xD I'd leave that company.
"I'm too good for this crap."
@daknok_t I actually like the company. The code is terrible, but they know it. They let me fix stuff when I'm ahead of schedule.
@MooingDuck sounds fun…
@daknok_t I enjoy the people, and I like making things better.
@MooingDuck I wasn't being sarcastic.
22:07
@daknok_t oh >.<
BRB I'm going to bed.
@daknok_t problogservice.com/2011/11/30/… We need to use this
en.wikipedia.org/wiki/Irony_mark#Irony_markl Hmm, there's two in competition apperently
back
Just checked the source and a DNS lookup does occur in Java for URL.equals. First culprit is at line 457 in URLStreamHandler.java My apologies for thinking the implementation was sane.
22:10
So I cannot use a switch with a string?
switch (str) {
case str1:
//..
}
@CaptainGiraffe You were expecting sanity with Java?
Because in C++ switch cases can only be integral constants.
@DeadMG Java to me is one of the least insane languages as long as we are not including Java generics, which incidentally is an epic fuckup.
@unNaturhal you can only switch on integer type objects (int, char, etc)
@unNaturhal either use a hashmap or a series of if blocks
22:12
@CaptainGiraffe Java is a pit of horrifically stupid decisions. They pile stupid on stupid on stupid in an epic chain of fail.
@Mooing Duch that are constants!
@CaptainGiraffe careful, those are dangerous words here
@daknok_t what?
@DeadMG Being serious is a bananable offense her you know!
@Mooing Duck only integral constants.
@CaptainGiraffe lol
@daknok_t oh, you mean as the labels? Yeah.
@CaptainGiraffe Oh, the fun thing is, I actually try that one now (I wanted to break it) and I see no dns going out in wireshark whatsoever. Could be the java implementation on ubuntu is "broken" (towards the spec) though
@StackedCrooked and his dad did an interview as well
Could you explain me what does this mean:
error: expected unqualified-id before 'if'
error: expected unqualified-id before 'else'
error: expected unqualified-id before 'else'
?
@KillianDS The source tells me it tries to find equality but as a last resort tries to resolve the stuff.
It does not try to resolve an X.X.X.X addy for instance
22:16
@unNaturhal could be lots of things. Probably you forgot semicolons.
@unNaturhal without the code we can't know anything.
@MooingDuck Ehm... I know that I seem to be stupid, but not so much...
@unNaturhal if you can't figure it out, copy it to ideone.com and put a link here so we can look at it
if (tag == "<tr>")
        fout << "<move>\n";
    else if (tag == "</tr>")
        fout << "</move>\n";
    else
        fout << "ciao\n";
@unNaturhal I mention it because I just forgot a semicolon a moment ago and got confused
@unNaturhal what's the line before that?
22:18
@unNaturhal it's a good idea to block your statements even in here.
@MooingDuck The first error is on the IF, the second on the first ELSE, the third, on the last ELSE
@unNaturhal the first error says you forgot something right before the if: "expected unqualified-id before 'if' "
Complete code or we cannot help.
What happens if you remove the if entirely?
@CaptainGiraffe I am actually comparing two URL's that point to the same ip (and site for that matter)
22:20
@MooingDuck ideone.com/WaSun
@KillianDS Yes the URL equals does not block for most cases, just string comparisons.
@unNaturhal you have a } after your function opening
Its when the protected boolean hostsEqual(URL u1, URL u2)
@CaptainGiraffe ah, no it doesn't (for me), I had a stupid typo in my url (duplicated the colon after http :s), it returns true now :) (and does the URL lookup)
comes into effect stuff gets pearshaped
22:22
@MooingDuck Ok, you was right. I'm an idiot...
@unNaturhal Happens to all of us
@unNaturhal if you are on a unix platform and you want decent error messages, you might like clang. :P
@daknok_t Win7+Code::Blocks
GCC is being so fucking helpful in that example…
@MooingDuck 00:23 It's not the best time for coding...
22:23
@daknok_t not sure clang would have found that one. (And you can get clang and gcc for windows here)
Ok show of hands: "I'm on a unix like platform" 1 for linux 2 for anything else BSD/UNIX
@CaptainGiraffe what of windows? -1?
0
=) lets stay with 0, Win 7 is not that bad =)
@CaptainGiraffe does Windows + MinGW count as "unix like"? How about cygwin?
Cygwin would go as 3
22:26
@MooingDuck clang would at least say that an if statement belongs within a function, in plain English.
Or something like that.
Cygwin +all has both X and the gcc I'm very impressed there.
A function, constructor or destructor, also fine… or a lambda expression…
@daknok_t I don't have clang on this computer so I can't validate that, but you're probably right
@CaptainGiraffe 0
@MooingDuck Lo and behold I actually have classes (C#/Db) when I need to fire up the old MS Machine (Win7) And I really like Win 7.
@MooingDuck I was wrong xD llvm.org/demo/index.cgi
22:34
There is something compelling about having downloaded the Java source code to figure out the implementation of the URL class. Don't know why though in c++ everything has always been there for me. I guess some stuff you just expect to be free. I guess I'm saying thanks RMS.
I don't know if looking at the Java source code is very good for you…
I feel at home looking at that source, but I also feel at home looking at the std:: .h and .cpp's.
Java stdlib source comes with the JDK.
23:10
My xml "parser" is starting to work :D
23:22
@unNaturhal your "parser" is starting to "work"?
@MooingDuck Do you remember what I'm trying to do this afternoon?
Something to process an HTML file to generate an XML one from it?
@unNaturhal last I checked, you were trying to use strcmp with a std::string.
@MooingDuck Ah.. However was everything for this reason :P
(if I understand how to retreive a message in the past of this chat, I will link to you xD)
 std::cin >> noskipws;
 std::transform(std::input_iterator<char>(std::cin),
         std::input_iterator<char>(),
         std::output_iterator<char>(std::cout), ::to_lower);
@unNaturhal click the arrow to the left of the message, right click "permalink"->"copy link address", and paste it in the chatbox
2 mins ago, by unNaturhal
(if I understand how to retreive a message in the past of this chat, I will link to you xD)
@MooingDuck What is this?
@MooingDuck As soon as I found the message :)
23:31
@unNaturhal reads a file in from standard input, makes it all lowercase, and saves it to the standard output
at the console I could type "myprog.exe <input.html >output.xml" and it would convert the entire file to lowercase :D
And I just now realized I could make it all one expression:
 int main() {
 std::transform(std::input_iterator<char>(std::cin>>noskipws),
      std::input_iterator<char>(),
      std::output_iterator<char>(std::cout), ::to_lower);
 }
Alright, time for me to go. Later.
@MooingDuck O_O In two seconds! Amazing :D
@MooingDuck See ya man! Thank you very much for the help and the patience :)
user406009
23:46
No.
user406009
"Because the Clojure version has no branches, it is easier to read and test.
These benefits are magnified in larger programs. Also, while the code is concise,
it is still readable. In fact, the Clojure program reads like a definition of
blank: a string is blank if every character in it is whitespace. This is much
better than the Commons method, which hides the definition of blank behind
the implementation detail of loops and if statements." It seems like you would need conditionals either way, only the location differs(they just have a library with just the right function compared to Java).
That's typical functional programming.
> Clojure is high-signal, low-noise
Except for parentheses, of course, but being Lispers, we don't talk about that.
Guess they're immunized.
And really, comparing any language to Java will yield "high-signal, low-noise".
Haskell and Factor. Screw Lisp.
23:59
The first rule of Lisp: you don't talk about parentheses.
user406009
At least Java has well designed IDE's so most of that noise can be auto-generated. Programming functionally in Java is actually bearable when the IDE auto-generates the inner classes.

« first day (545 days earlier)      last day (4625 days later) »