« first day (450 days earlier)      last day (4484 days later) » 

4:00 PM
@sehe I disagree. That sort of thing was in Haskell and Lisp before C++, as far as I know.
it was only a matter of time before, just like lambdas, someone noticed that it would make a great imperative feature
 
sbi
@sehe TMP in C++ wasn't started by Andrei at all. It was started by Erwin Unruh and Todd Veldhuizen. Great contributions were published by Czarnecki/Eisenecker and Abrahams/Gurtovoy.
 
@sehe I think it needs to learn more about me
 
sbi
Andrei's got us started on policy-based programming, though.
 
@sbi I don't know, D has already more than 10 years on its shoulders, and it is still actively developed. For example, it just got the x => x * x lambda syntax a couple of weeks ago. I don't think it will be completely forgotten in 2022.
 
@Xeo Hey, it makes perfect sense, of course. After all, there is no language to date where "hello" ~ "world" would not be syntax error <ducks/>
 
sbi
4:04 PM
@FredOverflow Oh, I meant to correct that to 20 years, but obviously I forgot. But it might be dead in 10 years already. The use of languages that don't get enough traction dwindles at some point. Programmers need tools and stuff, and there's always new languages coming that they can play with for the fun projects they can do without.
 
@sbi Thanks. The 'policy based' remark sound about right, and not having read all of the other quoted authors, I'm going to give you credit for having a better view of the history than mine. Thanks for the precisions, it will make me reread the design history of C++ post-templates one day (perhaps this summer's reading stack)
 
@sbi What examples of language are there that lived for more than 10 years and then died "soon" after? (Not saying they don't exist, just curious.)
 
sbi
@FredOverflow We have forgotten about them. :)
 
@sehe That reminds me, "The Design and Evolution of C++" really needs an overhaul, it's been 18 years already.
 
sbi
@sehe See here for Erwin's original program.
Oct 19 '11 at 18:41, by sbi
@LewsTherin Over a few beers in a pub, I asked Erwin Unruh (who is generally considered to be the first to ever write a template meta-program) how it happened that he came up with this. He told me. And then I asked him how the others reacted when he showed it to them. So he showed me how Bjarne Stroustrup reacted - by hiding his eyes behind his hand. My point: Nobody, not even C++' creator, had thought TMP would be possible until they actually run into it, hurting their shins badly.
@FredOverflow I think there's a much more up-to-date paper from an HOPLA speech of Stroustrup somewhere at his website. It's fairly extensive for a paper, IIRC, but of course nothing compared to a full-blown book.
 
4:13 PM
@sbi Is "hiding his eyes behind his hands" meant literally or figuratively?
 
sbi
@FredOverflow The literal gesture with which he described (rather than told) Stroustrups reaction was to cover his eyes with his hand.
 
is TMP is doing things like generating trig look up tables?
 
@sbi Okay, the gesture was literal, but that doesn't mean Bjarne actually did the same thing.
@thecoshman TMP is about computing stuff (either types or values) at compile time. I haven't seen trig lookup tables yet, but that might also be possible.
 
sbi
@FredOverflow Well, I wasn't there when Erwin showed his program to him, so I wouldn't know. All I know is what he told me Stroustrup's reaction was, and he said Bjarne covered his eyes and didn't want to see it.
 
lol Stroustrup is teh funny!
Bjarne's thoughts were probably "Oh my god, what kind of monster have I unleashed upon nerdkind?"
 
4:17 PM
@FredOverflow huh, well that is one of the first things I saw it described with. In (one of the) game programming gems book(s)
 
Xeo
@FredOverflow Though I think it might be wiser to compute it once, save it, and simply load it at runtime. The compiler will thank you
 
sbi
@FredOverflow Interestingly, this ("we've created a monster") is pretty much what Erwin said about TMP that night in the pub.
 
Well, monsters tend to be rather ugly... but also powerful!
 
sbi
BTW, I just found the paper I wrote about (PDF link), and it's from 1991. :( There is a newer paper (2007, PDF link), but that's dealing with a slightly different topic.
@FredOverflow Yeah, I think he said everybody involved felt that they, by putting more and more features into templates (in order to better support the STL), had created a monster about which they didn't even know what it was capable of. His suspicion was that templates had become Turing-complete, and he always meant to prove this one day, but never got around doing so. Instead he came up with that program.
(Someone in a funny mood submitted it for the standardization process and it thus became an official document.)
 
@Xeo could not TMP be used to save said results?
 
4:23 PM
@sbi But Turing completeness was eventually proven, right?
@thecoshman You cannot open files and write stuff into them at compile time :)
 
@FredOverflow not even some sort of compile time log?
 
sbi
@FredOverflow I don't know if anybody ever formally proved it. When we had a beer, it was still on his todo list. Maybe someone else did it?
 
@thecoshman Not unless you externally redirect the compilers output into a file, and even then it's quite unlikely you would find valid C++ code in the log that was directly usable in another program.
 
I can't help but view TMP as something to do just because you can
 
then learn to program :P
I built my lexer out of expression templates and it's so much better than the hand-rolled version
 
Xeo
4:28 PM
@thecoshman TMP is purely functional. Aside from hacking with friend functions, you have no side-effects in TMP.
 
well, I get templates. there all funcky a shit, but TMP just seems to be more like a because you can. What's a good example of where TMP actually helps; and not just a case where normal templates are used
 
I just said
expression templates
they're much faster than non-expression-templates for many codes
 
huh...
well, that's going right over the top
 
std::string's concatenation operator
 
Expression templates are TMP?
 
4:31 PM
C++03 O(n^4), owch
C++11, rvalue references, O(n^2)
expression template version? O(n)
 
perhaps if I saw some code I would understand better, but right now, it's just going over the top of my head
 
look in the Lexer cpp file
 
are you saying that you are using templates to work out an expression at compile time? rather then having to process it at run time?
 
@sehe It's OK, I discovered their IRC channel :-) I was wondering why it would fork a process, copying all memory. Apparently it has to...
 
Xeo
@thecoshman That's exactly what "expression template" describes
 
4:33 PM
no no
 
@Xeo oh ok
 
expression templates are a combination of TMP and operator overloading
 
Xeo
You just abuse operator overloading and return unevaluated expressions
 
they give you the AST of an expression, effectively
which you can then evaluate in a much more efficient form than it's raw form, or in some other way
 
What is the TMP part? I don't understand
 
4:34 PM
look at my lexer source code, the operator overloads have to be TMPed to pick the correct overload
and there's CRTP in there too
 
@DeadMG MakeEquality is a mouthful.
 
meh
it does what it says on the tin, makes an equality functor
equality is the default anyway
 
I assumed as such. What's the meaning of >> and []?
 
but you can only apply that default in some cases, just like you can't do "hello" + "world" and get a std::string
>> and, [] semantic action
 
4:35 PM
@thecoshman Type traits like typename std::remove_pointer<T>::type are the simplest form of TMP. You compute a type at compile-time.
 
I think I am just too out of touch with C++ to get this fully. Dam Java ¬_¬
 
Xeo
35
A: How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000?

XeoUpdated Now with improved recursion depth! Works on MSVC10 and GCC without increased depth. :) Simple compile-time recursion + addition: template<unsigned Cur, unsigned Goal> struct adder{ static unsigned const sub_goal = (Cur + Goal) / 2; static unsigned const tmp = adder<Cur, s...

A perfect, small example of TMP!
 
@DeadMG And unary +?
 
one-or-more
* zero-or-more
 
@thecoshman It helps if you've seen the documentation for something like Boost.Phoenix.
 
4:36 PM
@Xeo The C# solution is so awesome :)
 
Xeo
@FredOverflow Yeah, but I'm wondering if that isn't relying on the behaviour of a particular compiler?
 
@Xeo You can't spell "abuse" without "use", so... :)
 
Xeo
@FredOverflow I abuse C++ like a bad husband all day, so ...
 
lol
 
@Xeo I doubt there's any mainstream language with rigorously specified compiler error messages.
 
4:40 PM
yeah...
 
Xeo
@FredOverflow No, I just wanted to know if it's really forbidden to convert from int to char in C#.
 
I think I see how TMP would work
 
@Xeo Oh yeah, that's totally forbidden.
@thecoshman That was fast!
 
@FredOverflow ... thank you?
 
@thecoshman I have a small utility that makes my life easier with variadic templates. It uses TMP to build a list of indices.
 
Xeo
4:42 PM
@LucDanton I want variadic templates in Visual Studio. :(
 
so would it be true to say, templates allow for generic programming, tmp allows for generic templates...
@FredOverflow case in point @sbi
 
Xeo
@thecoshman Since templates are generic by nature, no
 
No. Unless you clarify what a generic template is.
Genericity and metaprogramming are language features, templates is how C++ gets those features.
 
4:43 PM
C made so many mistakes, it's hard to imagine that any specific mistake was the biggest
 
@thecoshman Do you know a functional programming language?
 
@thecoshman: Maybe you should read this book.
 
Xeo
I want to improve on the sum answer, but this question of mine is getting sorely ignored. :(
 
@Xeo Did you see my update? I tried about 10 warnings and 3 worked
 
@FredOverflow maybe I will, but Dracular is laying claim to reading time right now
 
Xeo
4:45 PM
Oh, no, I didn't!
 
@Xeo What does one have to do with the other?
 
sbi
@thecoshman Huh?
@Pubby Yes.
 
Xeo
@FredOverflow Well, as I say, the sum question actually states that compilation finishes
 
sbi
@thecoshman I like to post this for a very practical and useful example.
 
Xeo
And an error is not very likely to let that happen
 
4:46 PM
@sbi interesting article that some one wanted to discus, so they linked to it
@sbi ¬_¬ looks just a little familiar :P
 
sbi
@thecoshman Sigh. I did not say this doesn't happen.
 
Xeo
@sbi You sure like that library. Do you get promotion salary everytime you post it or something?
 
@sbi I know you didn't. I am saying that this is the best way for it to happen
 
sbi
@Xeo I have found it useful in the past. And IMO it is a pretty good example for a practical application of TMP.
 
@Xeo @sbi only has two links, that one and the other one ranting about GIT
 
Xeo
4:48 PM
lol
 
sbi
@thecoshman There's also the one about quasi-classes.
 
@sbi oh, do go on
 
damn
why do I find it so hard to translate my ideas into code?
 
huh, I wonder how long a sentence I can't write exclusive with words that include the letter 'o'
 
sbi
@thecoshman google.com/#q=quasi+classes I post it whenever someone is in love with getters and setters.
 
4:50 PM
@DeadMG perhaps this is why you are making your language?
@sbi linking to a Google search is cheating
 
because I'm trying to do something stupid
 
sbi
@thecoshman Cheating whom?
 
Als
hmmm
 
most of this stuff is unnecessary
 
@sbi ooh, profound
 
4:52 PM
so instead of sitting here staring at it, I should just DELETE ITS ASS
 
its, not it's
 
ftfy
 
Als
Anyone uses google chrome?
 
yes
 
@FredOverflow actually, I think that still works as "Delete it is ass"
 
sbi
4:53 PM
@Als Of course. It's very popular.
 
@Als yes
@sbi awesome, ftfy
 
I could have said "Delete as it is ass", that would also be fine
 
Als
@chrome users: Wondering if use any extensions
any good ones
 
sbi
@DeadMG Deleting it would be its fin, that's for sure.
 
Als
I am usually wary of those
 
4:54 PM
@DeadMG true, I think "delete it is ass" probably should have a comma ie "delete, it is ass"
 
ftfy
this keyboard is also ass
 
Als
damn its always about ASSes in here!
 
and tits (or GTFO)
 
Als
tits yes..and rarely man-tits :P
lol
 
@Als man-tits don't count as tits if you ask me
 
4:55 PM
How did we go from template meta-programming to man-tits?
2
 
Als
@thecoshman: Are u the authority on what should be classified as tits? :P
 
also
I need to cut all the "AST" prefixes from all the fucking things
how redundant
 
@Als ... yes ¬_¬
@FredOverflow Lounge<C++>
 
Als
@FredOverflow: I think we all are men and we all have tits and tits being the favorite topic in this room since ever it was natural that we would drift towards it.
 
@DeadMG cut ALL the AST prefixes!
 
4:57 PM
lol
 
sbi
@FredOverflow Via the puppy's ASS.
 
Xeo
I wonder if the meta-police will hate me in a moment.
room topic changed to Lounge<Sex++>: Public service announcement: this is not an Objective-C room. Thank you. [c++] [c++11] [c++-faq]
 
hey!
 
Als
huh puppy ass..eew
lulz
 
Xeo
Maybe I should disguise it as Cex++
 
4:58 PM
room topic changed to Lounge<C++>: This is not the Sex++ room. We promise. [c++] [c++11] [c++-faq]
 
Als
And that from a guy who is talking of ASS!
 
@DeadMG ¬_¬ where is it
 
Als
ahem the contradiction
 
sbi
@Als Actually, I think sex and C++ (probably in that order, even) have been more popular than tits. :-/
 
I have a Lex question, how can I ignore everything that isn't between $< and $>?
 
4:59 PM
write your own lexer
 
sbi
room topic changed to Lounge<Sex++>: Public service announcement: this is not a Lex++ room. Thank you. [c++] [c++11] [c++-faq]
 
Xeo
lawl
 
@sbi thanks for that paper, nice reading
 
@sbi meta-GTFO? smooth
 
sbi
@bamboon I'm glad you liked it!
Anyway, gotta stop pretending I'm working and go home. I gotta feed one of my sons.
 
Xeo
5:02 PM
Feed him with your other son(s)
Makes for less mouths to feed and it's even cheap!
 
@sbi Can't you set up an automated feed for him?
 
sbi
@Xeo That's the thing about my kids: They seriously love each other. Yes, once in a while two of them get into a fight, but overall they'd never truly hurt each other.
 
@sbi if you wait long enough, he will feed himself and save you from having to feed another one them
 
sbi
@FredOverflow He is certainly old enough to feed himself (in fact, I expect him to have the table ready when I come), but it's a meek meal for a kid to have to eat all alone. // @thecoshman
 
still have another half hour ¬_¬ I hate late days
 
sbi
5:05 PM
Anyway, see you later!
 
@sbi throw enough sweets at him, he will not care :P
 
bb
 
@sbi see ya
 
Als
bb = bye bye or baby?
:)
 
evil laugh
I think I know what I am doing this weekend :P
 
5:15 PM
@DeadMG Did C do anything right? :)
 
well, I guess it's better than assembler
 
Did assembler do anything right? ;)
 
assembler doesn't have to be any good, it's for compilers, not people
 
I used to write quite a lot of x86 asm. You know, back when computers were slow, compilers sucked, and I thought Pascal was the most awesome language ever.
 
@FredOverflow well, I guess it's better than punching binary code by hand
 
5:18 PM
 
@FredOverflow ¬_¬
 
SUPER CODER 2000 :)
 
by the way
is it a bad thing that I'm already considering how to implement automated code refactoring and suchlike tools?
 
Xeo
@DeadMG Tell that the guy who made Rollercoaster Tycoon. part 1 and 2 of the series were coded entirely in assembly IIRC
 
@DeadMG No, tooling-aware languages are almost always better.
 
5:21 PM
@Xeo So what?
 
What do you think of the idea to overload operator<< for numeric types meaning "a lot smaller than"? :)
 
what the fuck is the semantics of "a lot smaller than"?
 
At least an order of magnitude smaller or something, I dunno :)
 
honestly
I think it sounds like a kind of dumb idea
 
@FredOverflow sounds stupid to be honest
 
5:24 PM
@FredOverflow evil and unnecessary perversion
not because it doesn't make a kind of sense when seen in isolation, but because that operator already has several widely used meanings
 
Okay, I think dumb, stupid, evil and unnecessary are enough reasons for me not to do it :)
 
what is wrong with functions ffs
@FredOverflow what was your thinking for doing it?
 
in languages which don't already have the << operator, I wouldn't mind too much
 
I'm insulted
 
I mean, it makes more sense than using it for streaming or, for that matter, bit shifting
 
5:26 PM
< less than, << a lot less than
 
this is the sex++ room, and I'm Hugh Heffner.
 
@thecoshman << means "a lot smaller than" in mathematics.
 
but if it has to coexist with those, it just gets silly
@FredOverflow so, are you making a language too now, or where would you add it?
 
@TonyTheLion Hello, Hugh Heffnerd.
 
too? you make it sound like everyone is doing it
 
5:27 PM
any ways, I'm off home now
 
whereas as far as I know, I'm the only one who is doing it
 
see ya
 
@jalf Just ordinary operator overloading in C++ for an imaginary class :)
 
@FredOverflow ah
 
5:28 PM
in that case, it's a definite NO :)
 
lol
 
ok maybe someone is willing to help me with my case of UB
 
2 mins ago, by FredOverflow
Okay, I think dumb, stupid, evil and unnecessary are enough reasons for me not to do it :)
@TonyTheLion What case of UB?
 
it's one of those "sensible idea, but unfortunately, someone else got there first" things
 
Got there? Did anyone actually do it?
 
5:29 PM
actually, I think it's a dumb idea
 
a bit like with kilobyte. Of course it makes sense that it should mean 1000 bytes. Except that someone decided many decades ago that it should mean 1024, and pretending that it means anything else today is just stupid
 
I'm filling up a 2D array of int's in C, the size is int x[9][9], and I'm filling it to x[8][8], which I think is actually valid. For some reason at x[7][0], it goes silly and skips to a different function or dies or something
 
everyone's opinion of "a lot less than" is going to differ
 
@DeadMG so it'd be suitable addition to Subjective-C, is what you're saying?
 
lol
yes, exactly
 
Xeo
5:30 PM
@TonyTheLion Your problem is that you use C
 
I can just imagine
 
@TonyTheLion actual code please
 
@Xeo yea I know, but I don't have a choice in this case
 
bool operator<<(int lhs, int rhs) { return lhs < (rhs - rand()); }
 
@TonyTheLion well, if you do what you say you do, then that's not supposed to happen
so either you're not doing what you say you do, or your compiler is broken. :)
 
Xeo
5:31 PM
or both
 
I was just about to sayt
 
A C compiler being broken is not very likely.
 
that
 
so I'm going to guess that you're an evil filthy liar, and you're not doing what you told us you're doing ;)
 
The fate of many a programmer :)
 
5:32 PM
yeah
 
hmmmm
here's the question
to pay moneys to play with a friend, or not?
 
@TonyTheLion You should spend more time with your rubber duck.
 
this chat channel is my rubber duck
2
 
@DeadMG What kind of friendship would that be?
 
Xeo
So, @FredO, since you said that << is the mathematical notation for "a lot smaller than", what is the mathematical definition for "a lot" here?
 
5:34 PM
the kind where the friend is two hundred miles away?
 
@Xeo "big enough"
 
@Xeo depends on the context, it's mostly stuff like "if x << 1 then f(g) ~ g(x)"
 
Xeo
@DeadMG I want a talking rubber duck too!
 
quack quack, bitch
 
ok here is my code snippet, and I put a comment at the line where it goes funny
 
5:35 PM
How sweet, a rubber duck debugging Java code :)
 
what is it with C code and bad variable names? :(
 
We must save precious memory, so no more than two letter variable names!
 
euh, donno, it's C and it's annoying and horrible to debug and error prone, and despite all that, I'm stuck with it :(
 
I know the feeling :)
why do you have blk[0] twice in the line just above the comment?
 
Xeo
@TonyTheLion What's offset?
 
5:38 PM
@Xeo it's an int, starts at 0, goes to max 8
 
Xeo
You sure?
And mtx?
 
@jalf that's part of the algorithm, which I was never able to fully understand, not my code. The print_row is mine
 
put some parens around it at least to make it clear what's supposed to happen :)
 
@Xeo also an int, it is the number of matrices, max 12
 
(blk[0] << 3)
 
Xeo
5:40 PM
@TonyTheLion Comment out the UB line and see if the assert triggers
 
@jalf not sure if that needs shifting the whole thing
 
Xeo
Or assert before the UB line that mtx <= 11
 
yeah, throw lots of asserts all over it
 
Xeo
Oh, and how big is pr_buff?
 
@jalf And don't forget not to disable the assertions :)
 
5:42 PM
it is an array of 12 structs
 
Xeo
@TonyTheLion Well... pr_buff[12] is obviously wrong when it's some_struct pr_buff[12];
So you should really assert that mtx never goes above 11
Best put a assert(mtx < 12) in print_row
 
hmmmm
apparently, I have a character named "loalge"
 
@Xeo oh but I need 12 matrices, so it should then be pr_buff[13]
@DeadMG lol
 
Xeo
@TonyTheLion No, some_struct pr_buff[12] is an array of 12 structs
 
@Xeo for some reason my mtx goes to 14 anyways, which is not good
 
Xeo
5:45 PM
However, only indices 0..11 are valid
 
int a[n]; goes from 0 to n-1
67
Q: How do I use arrays in C++?

FredOverflowC++ inherited arrays from C where they are used virtually everywhere. C++ provides abstractions that are easier to use and less error-prone (std::vector<T> since C++98 and std::array<T, n> since C++11), so the need for arrays does not arise quite as often as it does in C. However, whe...

 
@Xeo of course, I'm an idiot
 
@TonyTheLion That's not news to me :D
 
Xeo
@TonyTheLion Acceptance is the first step to improvement
 
@DeadMG Well thanks, at least you're honest
 
5:46 PM
@Xeo Trying is the first step to failing.
4
 
Xeo
@TonyTheLion @DeadMG knows himself that he's an idiot too. He proclaimed it several times in here.
 
repeatedly
 
Xeo
I mean, we're coding C++, aren't we all idiots somewhere?
 
it's my current opinion that C++ is the best of a bad lot
 
Xeo
Until DeadC is out, anyways, right?
 
5:49 PM
@Xeo Hey, I was about to say that!
 
rofl
and yes, until then, and it's not even called that
 
Imma make a language called "idiot++"
 
But it will eventually be called DeadC? I thought it was WideC?
 
meh
 
that's if you wanna get more idiotic, you code in this language
 
Xeo
5:50 PM
Anyways, I need to go down and grab some food or I'll starve tonight.
 
it's currently called WideC and I'm going to drop the C anyway
 
Xeo
@TonyTheLion We already got Bra*nfuck, thank you
 
lol
Ok, mine will be called HeffnerFuck
lol
 
it was going to be part of a pair where one half was compiled and the other half was interpreted, so they were WideC and WideI, but I dropped the interpreted one after I realized that I had absolutely no need or desire for an interpreted language, and especially after I had designed it to what I wanted and the pair were basically identical
 
cpx
wideC is a header file, right?
 
5:52 PM
uh... no
 
Ell
hey guys
 
@cpx What?
 

« first day (450 days earlier)      last day (4484 days later) »