« first day (464 days earlier)      last day (4500 days later) » 

sbi
12:00 PM
@thecoshman No. The secret to getting starred is to write something others can relate to, agree to, feel passionate about, plus them remembering that they can star such messages. (In this case, all four applied to me.)
 
morning
 
morning
 
are there any websites where I could browse STL implementations? I'm curious about whether the containers optimize for POD vs non-POD types...
 
I have an exam tomorrow
 
Als
hmm
 
Xeo
12:08 PM
@kfmfe04 libc++, libstdc++ and VC's STL are all free to see, if you have them installed
 
Als
Folks, I feel obliged to say I am a pretty pissed off mood, please don't cross me over anything today!
 
@Xeo thx - looks like it's in /usr/include/c++/4.6/debug/vector on my system
 
any Haskell geeks wanna help me in the Haskell room?
@Als ohhh... :(
 
Als
@TonyTheLion: How you doin btw?
 
I"m not too bad
I'm learning Haskell
lol
 
Als
12:13 PM
thats if(!!good)
 
haha
hmmm, why doens't C++ have pattern matching
would be kinda cool
the closest thing I could fit it to is function overloading...
would that make sense?
 
Als
You think We need another beasts to care of? Is it not complicated enough already?
 
@Als lol - how true
 
is it ever complicated enough?
 
@Als meh, depends how you look at it
 
12:18 PM
The climate is changing. Lions are migrating to other languages.
 
pattern matching sucks
 
pattern matching could make some things much simpler to implement
 
pattern matching is lovely. But not sure if C++ is the place for it
 
Als
@TonyTheLion: From the look of it We are looking different directions
 
@DeadMG did I expect anything else from you?
2
 
Als
12:18 PM
:P
 
pattern matching could make some things much simpler to implement
 
@jalf I'm just thinking out loud
 
until the point where it picks the wrong pattern
how you gonna debug that?
 
donno
 
exactly
 
12:19 PM
if I say "C++ sucks!" will I be put on trial, then executed?
 
would there be a way to simulate it in C++?
@IntermediateHacker yep :P
 
@IntermediateHacker no, you'll be joined in a chorus
 
@DeadMG er, the same way you debug any other part of a language
 
@TonyTheLion Expression templates?
 
How do you debug when the compiler picks the wrong overload or specialization?
 
12:20 PM
Who needs a trial?
 
@DeadMG meh, I was thinking that, just wasn't sure
 
Or the wrong branch in an if?
 
C++ already does implicit casting of function arguments, which is a sort of pattern matching. Also templates.
 
@jalf At least wrong overload errors occur at compile-time.
 
@jalf change the if
 
12:21 PM
and generalized pattern matching would need to match a lot more than overload resolution
 
@DeadMG So? Somehow we're able to cope with debugging if statements and switches.
 
@DeadMG If the compiler picks the wrong overload, that happens at compile time.
 
pattern matching isn't much more than a nicer, cleaner switch.
 
btw, another question, an interpreted language, can it produce an .exe?
 
12:22 PM
debugging it isn't really a problem in the languages that do have pattern matching. I don't see why it'd necessarily be worse in C++
 
the difference between a switch and a pattern match is that if you want to know why a given casewas executed, all you have to do is yoink out the subexpressions to see what they evaluate to
 
@TonyTheLion Yes. Simple proof: pack the interpreter with the program.
 
@TonyTheLion yep, if that .exe will have access to interpreter
 
if you want to debug a pattern match, you can't put a breakpoint in INSERT MAGIC HERE
 
@TonyTheLion sure. Put the interpreter in a .exe file, embed your script as a resource, and presto, you have a .exe
 
12:23 PM
I have no idea what you're talking about.
 
@Abyx oh, huh? doesn't it spit out asm or whatever?
 
but it doesn't really make sense to distinguish beetween "interpreted" and "compiled" languages. Nothing stops you from interpreting C++
 
6ec4842ca9dc1280fd136ca4b30ba41209086ecd147f27411e0ff9a247f76596
 
and in addition, I struggle to see how it could be implemented without otherwise unnecessarily strong ties to the libraries
 
Compiling Javascript is a bit tricky due to its dynamic nature, but fundamentally, tehre's no reason why it can't be done
 
12:23 PM
^ Encrypted text.
 
better to just make expression templates
 
@jalf yea well, look at Mr. Robot here, he interprets C++ in his head :P
 
What kind of pattern matching are we talking about? If you misspell a function name then it takes the function with the most similar name?
 
lol
@StackedCrooked That's what the puppy seems to be going on about.
 
How is pattern matching useful in a language without algebraic data types? What is there to match?
 
12:24 PM
@LucDanton It works fine in boo!
 
@TonyTheLion fprinf(temp_file, source_code); system(interpreter_cmd_line);
 
> How is pattern matching useful
coulda just stopped there
 
@DeadMG What? With a switch I can put a breakpoint in two places: before the switch is evaluated, and after we've entered a case. I can do the same with pattern matching: when the function is called, and after the pattern matching has been resolved, and a function is entered
 
@DeadMG are you sure you've really understood pattern matching?
 
@Abyx fprintf? I boot you
 
12:25 PM
I can't put a breakpoint on "INSERT MAGIC HERE" in a switch either
 
@DeadMG You know, template partial specializations use pattern matching.
 
@jalf No, you can put a breakpoint in a switch in three places
before it's evaluated, after it's evaluated, and in the middle of evaluation at any intermediate point you so desire
 
@StackedCrooked basically calling different overloads of a function depending on parameters. In functional languages you commonly use it to create one case for an empty list parameter, and another for a nonempty list
 
In Cocoa there is a feature called "bindings" where you connect a widget with an object and the widget will scan the object's methods and try to find a set of methods that can be used to populate the widget's view state.
 
@RMartinhoFernandes What does it do? Structural induction?
 
12:26 PM
@DeadMG how do you do that?
here's a line of code: switch (foo())
 
@RMartinhoFernandes Aaand they're a massive heap of junk. They only serve to back up my perspective
 
please tell me where you'd put this "intermediate" breakpoint
 
Oh damn, I've seen this sequence of events here, a million times before.
We'll rant for hours, perhaps days without reaching conclusion,
Then we'll vow never to participate in these kind of stupid debates again,
goto top...
 
@jalf auto x = foo(); __debugbreak(); switch(x)
 
12:26 PM
@DeadMG ...
 
@jalf How is this different from regular overloading?
 
yes, and you certainly couldn't do the same with patternmatching
 
@DeadMG It makes them useful. That doesn't back up "pattern matching is not useful"
 
@RMartinhoFernandes My google-fu is weak, can't find examples :(
 
you obviously could never do `auto x = foo(); __debugbreak(); mypatternmatchingfunc(x)
 
12:27 PM
no, you can't
 
@StackedCrooked it looks at the parameter values at runtime, not their types
 
because mypatternmatchingfunc is where the actual interesting logic takes place
 
@DeadMG ...
 
the equivalent would be a breakpoint inside the pattern matching function
 
exactly the same logic takes place as in switch(x)
 
12:28 PM
uh, not really
 
I'm outta here. @call me when peace is restored.
 
I might have to repeat @TonyTheLion's question here: do you actually know what pattern matching is?
 
meh, it was just a question. I didn't want to set off an argument
 
a switch is nothing more than an array lookup, effectively, and a pattern match is vastly more complex
 
"Pattern matching is bad because I don't trust compilers/runtimes."
 
12:29 PM
@DeadMG So C# is impossible to debug then?
because it allows you to switch on a string?
 
Obviously.
 
vastly more complex
Let's all go back to C
Everything else is too complex for the human mind
 
array lookup from K to V is pretty much the same, whatever K and V are
 
yes, and write state machines :P
 
NO!!!! Not C!
 
12:29 PM
and for our debuggers
@DeadMG It's not necessarily an array lookup btw
 
there's a big difference between "too complex" and "my program depends on magic the code for which I can never see or even begin to attempt to understand"
 
@LucDanton Well, it goes something like this (assume appropriate newlines and indents to please the Python syntax :) match x: case TypeA(PropertyOne: 42, PropertyTwo: TypeB(PropertyThreeWhichIsAString: /regex_here/): do_stuff
 
The logic is already vastly more complex
 
There's also some way of naming the parts, but I can't quite remember.
 
how big an array do you think the compiler generates if you have case 1: and case 10000000:?
 
12:31 PM
it's virtual array
 
@DeadMG There's also a difference between "too complex" and "a feature I didn't grow up with and therefore it scares the shit out of me"
4
 
the difference is that that is an implementation detail
the logic behind switch never changes
 
Once again, pleae tell me how people are able to debug their code in languages which do use pattern matching?
@DeadMG and the logic behind pattern matching does?
 
how would I know the answer to that?
 
Don't worry, the logic behind pattern matching doesn't change either.
 
12:31 PM
@jalf Considering that you give it arbitrarily complex patterns?
 
@RMartinhoFernandes I can't parse those brackets (one is missing too, right?). Is Type( ...stuff...) the pattern, for a record-like thingy? And Type is the name?
 
@DeadMG how can you have an opinion on the subject if you don't?
 
Please provide examples.
@LucDanton Yes. (and I might have missed brackets ):
 
So what you're saying is "I don't know what I'm talking about, I'm talking out of my ass, and yet I disagree with what you're saying"
4
@DeadMG arbitrarily complex? We're not talking about regular expressions here
 
@jalf "Let's introduce a feature which would require massive coupling between language and library and force people to use completely new debugging techniques, after the years it will take for compiler vendors to implement useful debugging techniques" is not a solid argument
 
12:33 PM
AFAIK regular expressions != Haskell Pattern matching
 
You're moving goalposts.
 
@RMartinhoFernandes Alright! So no AlDT support, but structural induction (well or at least pattern matching allows achieving structure induction, can't remember the terminology) on records. I guess not the full power or AlDT is needed to make pattern matching interesting if a language has pieces of AlDT.
 
@jalf one more 3-star message and u'll do a hat-trick!
 
@DeadMG Neither is "I don't understand the feature and I don't understand how it works in other languages, but I'm CONVINCED THAT IT CAN NEVER WORK"
5
 
Hat-trick.
 
12:34 PM
@jalf congratulations!
 
Wooo :)
clap-clap
 
I never said it could never work, I only said I'd never want to have to debug code using it
 
For having used a language with pattern matching, honestly that's the kind of feature that's as arcane and mystical as argument passing for function calls. You use it everyday without thinking about it. It's powerful and mundane.
 
@DeadMG So what solid argument do I need, again? IIRC, I never claimed it belongs in C++. What I did say was that it's a useful feature
And to back up that statement I just have to show that it's useful in the other languages where it's used
@DeadMG you said it was useless
 
in C++
 
12:35 PM
no, he said it sucks
 
I'm fairly sure that was in response to someone else proposing it's introduction into C++
 
@DeadMG you didn't say that before. Moving the goalposts again
 
but @DeadMG is notorious for saying things suck :P
 
18 mins ago, by DeadMG
pattern matching sucks
 
@TonyTheLion that should be included in the newbie hints
 
12:36 PM
as far as I am aware, this discussion has never been about anything except the suitability of pattern matching as a C++ feature
 
I don't see much there about C++
 
18 mins ago, by DeadMG
pattern matching sucks
 
19 mins ago, by Tony The Lion
hmmm, why doens't C++ have pattern matching
 
14 secs ago, by Tony The Lion
18 mins ago, by DeadMG
pattern matching sucks
^ everyone else did it
 
@DeadMG So? You answered the question of pattern matching in C++ by saying that pattern matching sucks
 
12:37 PM
@DeadMG your statement was not a reply to mine
 
So while you could have specified "it would suck in C++", you didn't. You said that the feature sucks in general
 
In any case, C++ has pattern matching.
 
and then you went off the rails whining that it'd be impossible to debug and that you don't understand it and hate it and are afraid of it
 
@RMartinhoFernandes ok, thanks for clarifying
 
@RMartinhoFernandes then WTF are we fighting about?
 
12:38 PM
I have no idea where you're coming from
 
@RMartinhoFernandes where? templates?
 
lol, hilarity ensues
 
I'm pretty sure that I have been solidly on the rails this whole time
 
@Abyx Partial specializations.
 
@DeadMG I could quote you again, if you like
 
12:38 PM
@jalf allow me.
 
To walk through variadic template parameter packs I do it just like I would do in Haskell (if I didn't have folds).
 
If you never actually meant that "pattern matching sucks", then fine, I'll accept that it was merely a grammatical error
 
20 mins ago, by DeadMG
pattern matching sucks
 
well, considering that @Tony had just complained that they weren't in C++, I think that their consideration in C++ was implied
 
Since it doesn't actually exist in C++, it is an error to say that "it sucks" in C++. You could say that "it would suck" in C++, but not that "it sucks"
 
12:39 PM
Virtual method call also seems like a form of pattern matching to me.
 
@StackedCrooked Way too simplistic patterns.
 
@RMartinhoFernandes Partial template specializations are teh badness.
 
Multimethods would be closer.
 
@DeadMG right, well, let's accept then that your statement could have been mistunderstood because it A:) wasn't referring to my question, B:) too general
 
@RMartinhoFernandes Match a dynamic type to a leaf in an inheritance tree?
 
12:40 PM
it's fine if you want T, T or T*
but if you want std::is_pod<T>, it starts to get more than a little unfunny
 
Pardon us for misunderstanding you, but it helps if we actually speak the same language, and in English, it does not make sense to say "it sucks" about something that does not exist
 
That's not pattern matching.
2
 
You can even do pattern matching in C ???
 
so we assumed you were talking about something that existed, ie. pattern matching in general
rather than teh hypothetical "pattern matching in C++" which cannot suck until it exists
 
I had some experience of attempting to debug PROLOG's pattern matching, which definitely sucked terrifically
 
12:41 PM
@IntermediateHacker That's a C library for pattern matching on strings. Not a language feature.
 
And pattern matching on strings is what regexes do.
 
anyway
 
@LucDanton I and half the open-source community consider the GLib to be part of C
 
21
Q: What is 'Pattern Matching' in functional languages?

RomanI'm reading about functional programming (in academic purpose) and I've noticed that Pattern Matching is mentioned in many articles as one of the core features of functional languages. Can someone explain for a Java/C++/JavaScript developer what does it mean?

 
I feel that an expression template library would quite possibly cover it just fine
 
12:42 PM
@DeadMG except that it can't
 
why not?
 
because pattern matching deals with runtime values, expression templates deals with compile-time data
 
@IntermediateHacker That doesn't make it a language feature.
 
In boo if you do pattern matching of a string with a regex, you get variables named like your named groups for free. Thanks to me :)
 
you could use it to define an operator== which compares a T to a pattern
 
12:44 PM
f(0, 0) = NaN;
f(x, 0) | x > 0 = Infinity;
        | else  = -Infinity;
f(x, y) = (double)x / y;
^ I think finally get it.
 
@LucDanton Oh yes it does.
 
Overloading by value.
 
on reflection, I think that my existing FSM lib could probably do it (to a certain approximation)
 
@DeadMG still doesn't solve the problem. The point is to avoid having to type out the comparison code, so an operator== doesnt' do the trick
 
Xeo
@StackedCrooked Think template partial specializations, maybe that helps :D
 
12:45 PM
unfortunately, C++'s switch sucks
 
@RMartinhoFernandes On a completely different topic, I just remembered that Tony mentioned an interesting idea: an EDSL in C++ for list comprehension. (I think he learned about list comprehension from Haskell.)
 
@StackedCrooked What language is that?
 
someone should propose a better one
 
@Xeo I was thinking of that indeed.
 
@DeadMG Yes, it's too complex and we can't debug it
 
12:45 PM
no, it's not generic
 
@RMartinhoFernandes I copy pasted it from the SO post. Dunno.
 
@StackedCrooked yup, exactly
 
@StackedCrooked Sometimes it's not on values, it's on structure.
 
@StackedCrooked Ah. Ok. It looks like Haskell but uses a reserved word in places it can't :S
 
I wonder when someone will realize , "Let's stop the debate, this is a waste of time, the are no weapons of mass destruction in pattern matching".
 
12:46 PM
now, Wikipedia claims that it's easier to implement dynamic typing in an interpreter then in a compiler. Does that sound like a valid claim?
 
@jalf switch(x) always does the same thing, patternmatch(x, pattern) is arbitrarily complex
@TonyTheLion No.
 
Interpreted language is a programming language in which programs are 'indirectly' executed ("interpreted") by an interpreter program. This can be contrasted with a compiled language which is converted into machine code and then 'directly' executed by the host CPU. Theoretically, any language may be compiled or interpreted, so this designation is applied purely because of common implementation practice and not some essential property of a language. Indeed, for some programming languages, there is little performance difference between an interpretive- or compiled-based approach to their imple...
@DeadMG so it's of Order(arbitrary) ? LOL
 
@LucDanton Hmm, interesting indeed.
 
@DeadMG But just to avoid more confusion, what kind of patterns are you thinking of?
because that syntax does not look anything like the feature the rest of us are talking about
 
floral patterns.
 
12:48 PM
@RMartinhoFernandes I've thought about it a bit and I'm at a point where picking the right delimiters is a bit tricky.
 
@jalf It's just illustrative, not syntactically accurate
 
@LucDanton Commas?
 
@DeadMG that's why I'm asking you to explain what you mean
 
Goddamnit, these computers have GL/glew.h but not libglew. Who would even do that?!
 
12:48 PM
hmm, tricky, I did my absolute best to forget the experience as quickly as possible
 
Someone that doesn't want you linking to stuff!
 
give me a sec
 
Xeo
@RMartinhoFernandes too low precedence
 
@Xeo But we want low precedence!
 
@LexiR It's a conspiracy!
 
Xeo
12:49 PM
No, not necessarily for the rhs of the list comprehension
 
Rhs? Wait, are we talking about the same thing?
 
@RMartinhoFernandes lol.
 
@RMartinhoFernandes If we want to make it look like lambda DELIM0 id DELIM1 range DELIM2 id DELIM1 range (e.g. (x * y) | range1 ->* x, range ->* y where DELIM0 == '|', DELIM1 == '->*', DELIM2 == ,) there are precedences issues indeed.
 
I'm talking about Haskell's [2 * x | x <- fibs, isEven x], which means "get me a list of twice every even fib".
 
Right.
Let's assume that the Lhs is a lazy-eval EDSL where we use e.g. x, y, z... as placeholders.
 
12:51 PM
anyway, I ,for one, have absolutely no idea what the f*ck we are talking about. I'm just here to annoy everyone.
 
you troll :P
 
Then if the Rhs needs a delimiter to separate the different range -> identifier/placeholder associations, this delimiter must have a lower precendence than |.
 
Xeo
@RMartinhoFernandes lhs == left of |, rhs == right of |
 
@RMartinhoFernandes fibs.Where(x => isEven(x)).Select(x => x * 2);?
 
Comma has the lowest precedence however.
 
12:52 PM
@DeadMG Right, but C++ lambda syntax makes that a bit uglier :)
 
heh
 
C#'s much sweeter.
 
@RMartinhoFernandes That's a taboo here. never say it again.
 
@IntermediateHacker Why? C# has a few features C++ could really use
 
Anyway, what's even a syntax for list comprehension, regardless of C++?
 
12:54 PM
the problem with C# lambdas is that they lack expressiveness that's kind of essential for C++
but they're much cleaner, sure
 
extension methods, partial types
 
but a C# lambda in C++ would be kind of useless
 
@IntermediateHacker like 90% of people who come to SO
 
@DeadMG yeah. I like C# a lot too. but still, I thought it might get the same response as Java gets around here.
 
@jalf but a C# style lambda is something that could me handy :P
 
Xeo
12:55 PM
@LucDanton In Haskell's list comprehension, the conditions on the extracted value and the extraction itself are both seperated by a comma, right?
 
@jalf Agreed, as soon as you involve captures, then C++ requires a lot more specifying about what's going on
 
@jalf Still, if you just tacked the [] in there for captures, you could keep everything else.
 
@IntermediateHacker Java is tasty :D
 
@IntermediateHacker Nah. C# is way better than Java
 
@Xeo Not familiar enough with the language, I'm looking things up.
 
12:56 PM
@Xeo Yes.
What makes C# lambdas sweet is type inference.
3
 
Xeo
[ x * y | x <- range, cond x, y <- range, cond y ] at least as far as I understood it
 
the dynamic keyword is useful.
 
[=] x => factor *x sounds feasible.
 
@Xeo That seems doable.
 
Xeo
Hm... yeah
Would get easier with explicit binding of the conditions, though
 
12:57 PM
Well, that's going to need list monad stuffs, i.e. concatMap.
 
Xeo
Anyways, in C++'s list comprehension through EDSL, I think we'll need lots of bind for conditions
hmm...
 
@Xeo only for access to class members
 
I think I'm going to pick arbitrary operators to start with and too bad if it looks ugly.
 

« first day (464 days earlier)      last day (4500 days later) »