« first day (461 days earlier)      last day (4486 days later) » 

6:00 PM
No.
 
flip flip :: b -> (a -> b -> c) -> a -> c
apparently not...
 
Flip flip table.
 
It just takes the function as the second param.
 
That sounds like currying?
 
Currying is about pairs.
 
6:01 PM
1
Q: C++ Observer pattern listener event methods/class or signals & slots

BlackCatHy, I am implementing MVC in my game and i can't get this thing to work in my head. I decoupled view from game logics and controller is decoupled to. Thing actually works, but i can't decide if Listener pattern or signals & slots is better for my case. I have base class Entity with few pure ...

 
gah, I was trying to figure out why it's running so slow. Maybe I should be running in release, no?
 
Yet another exercise in the ancient art of overengineering.
 
@MooingDuck Oh, right, I did my measurements with optimizations on.
 
@RMartinhoFernandes How about \y f -> \x -> f x y :: t2 -> (t1 -> t2 -> t) -> t1 -> t, isn't that the same as flip flip?
So isn't that binding the second parameter early or something?
 
$  pointfree "\y f -> \x -> f x y"
flip flip
@FredOverflow Seems so.
 
6:03 PM
Do you have your own private lambdabot?
 
@RMartinhoFernandes these are correct?:
    static_assert( !kiss::is_integral<kiss::int8&>(),  "l-reference type is recognized as integral type" );
    static_assert( !kiss::is_integral<kiss::int8&&>(), "r-value reference type is recognized as integral type" );
    static_assert( !kiss::is_integral<kiss::int8*>(),  "pointer type is recognized as integral type" );
 
@FredOverflow Yes. $ cabal install pointfree
 
@rubenvb What is int8&& supposed to be? There is no such thing.
 
@rubenvb Right.
 
One ampersand is lvalue reference, two ampersands is rvalue reference.
 
6:04 PM
And there's 8 and two ampersands.
 
oh :)
 
I need to eat more carrots. Or get a bigger monitor.
 
Or a better font.
 
@FredOverflow yeah, not the best spacing there.
 
6:05 PM
How about replacing int8&& with std::add_rvalue_refererence<int8>::type? Or just int8 && :)
 
@RMartinhoFernandes got it, my C++ averages 17.04ns (MSVC10). I had to run it 100000000 times in a loop to satisfy myself :/
 
@MooingDuck Satisfying yourself takes 100000000 iterations? Wow.
 
@FredOverflow the space might be helpful. I don't have a kiss::add_rvalue_reference yet.
 
Using add_rvalue_reference for non-generic code was a stupid idea of mine, anyway.
 
6:08 PM
Is it really as simple as F(n) = 4F(n-1) + F(n-2)? Seems to work. Cool.
 
@FredOverflow I was getting double rounding errors because the times are so small when you calculate in seconds. I just now realized there's a better way to calculate without those errors, I'm getting 16.844ns
 
@MooingDuck can't you just round each result?
but then the other way wouldn't be better
@MooingDuck How the MinGW-w64 stuff working out for ya?
 
@rubenvb no, I can run it 1000 times per clock tick (ctime library in MSVC)
@rubenvb very well!
 
Good to hear :)
 
@MooingDuck What are you using for measuring? Mine & Kerrek's stopwatch? </ad>
 
6:12 PM
@RMartinhoFernandes The ctime library with MSVC. I get took 0 ticks to do 100000 runs at 1000t/s.
 
@Fred FTR, the "improved" version that takes advantage of the formula runs in ~1250ns.
That is, slower than the naïve version.
 
does the C++ stdlib have a fibonacci function?
 
that's pretty lame
 
A Fibonacci function is a silly thing.
 
6:14 PM
@RMartinhoFernandes Well, adding is probably faster than multiplying or something :)
 
why's the header named "math.h"/"cmath" then?
pfff
 
Do you seriously expect every mathematical function to be in cmath?
 
@FredOverflow GHC is probably tweaked to optimize (+) better than (\x y -> 4*x + y).
 
@FredOverflow it'll be in mine
or a lot of em at least
 
@rubenvb A Fibonacci function is a silly thing!
 
6:15 PM
Again, addition is probably faster than multiplication on hardware, but that's just a guess.
 
@RMartinhoFernandes well, yeah, fibonacci is silly, I'll give you that.
 
@rubenvb There is an infinite number of functions, how do you propose to put them all into one finite header?
 
I want Ackermann!
 
@FredOverflow I'll get at least the ones that are described by the Hypergeometric function in
you know, The Mother of All Functions?
 
6:17 PM
Hmm... I think I'll go shopping now. See you later, guys.
 
Anyway, if your math library doesn't have this, it sucks:
In computability theory, the Ackermann function, named after Wilhelm Ackermann, is one of the simplest and earliest-discovered examples of a total computable function that is not primitive recursive. All primitive recursive functions are total and computable, but the Ackermann function illustrates that not all total computable functions are primitive recursive. After Ackermann's publication of his function (which had three nonnegative integer arguments), many authors modified it to suit various purposes, so that today "the Ackermann function" may refer to any of numerous variants of the or...
@FredOverflow Bye.
 
well, that's more computer science than pure math
 
@rubenvb When you're done reinventing the standard library, how about writing a tutorial on Monads?
 
lol
"Monads are standard libraries"
 
Can you believe I cannot make sense of the Wiki article on monads?
 
6:20 PM
Yes, I can believe that.
 
Are there any type traits you wish you had? Or often write because of their usefulness?
 
@rubenvb is_container, is_iterator
 
Usually I just write them once and dump them on my wheels library.
 
has_member macro
 
6:25 PM
@MooingDuck when would you use those? To enable_if certain algorithms?
has_member seems like a smell of bad design?
 
@MooingDuck It's better to have a is_expression_valid macro. More flexible.
 
@rubenvb yeah, to enable_if functions that take template type iterators
 
@MooingDuck You mean, to static_assert against them!
 
@rubenvb I remember using it several times, though I can't recall what for
 
ok, that sounds quite useful to algorithm writers
 
6:26 PM
Don't give me stupid "overload resolution failed" compiler errors when you can give me decent ones.
 
So maybe I should static_assert a non-arithmetic is_signed?
can I static_assert in a constexpr function?
I'm guessing yes
 
@rubenvb Yes.
 
awesome
 
But my point was, don't enable_if if the end result will be an error anyway.
 
is_signed is getting a static_assert(is_arithmetic<T>(), "bugger off fool");
 
6:28 PM
Use enable_if to select overloads, not to cause errors.
 
you are full of wisdom Sensei.
 
@RMartinhoFernandes I was, I think the problem was because I'd typo'd my copy operator and it took a while to notice because it was going into the templated constructor
hmm, MSVC is fussy about "external tools" being in the target directory.
Ah, no, it's fussy because it wants a fully qualified location.
 
hmmm. can I specialize a template on const (without is_const, I'm writing is_const)
 
This won't work:
template<typename T>
constexpr bool is_const() { return false; }
template<typename T>
constexpr bool is_const<T const>() { return true; }
 
6:35 PM
You can't partially specialize functions.
 
ah, function template partial spec
 
MSVC is fussy with the external tools! If the file resides on the system path, you can enter just the file name. If not, enter the full path to the file. The Use output window option is available for .bat and .com files only.
 
goddammit
basterdz
 
@MooingDuck Essentially, it's like a command prompt.
 
@EtiennedeMartel it lets me set the CWD, but won't execute files in the CWD :(
 
6:37 PM
@MooingDuck Oh. Now that's just silly.
 
@EtiennedeMartel I also can't use variables in the command. There's no way to execute a program in the "current project"'s folder.
 
@MooingDuck Yes, there is.
Make a bat that takes a command as argument.
Nothing one extra level of indirection can't solve :P
 
@RMartinhoFernandes there's gotta be a windows command that I can use instead :D
CMD.exe can probably do it if I could figure it out
 
@MooingDuck echo?
 
@MooingDuck cmd /c
Or cmd /k.
One of these pauses (I can't remember which), so you should test first which one you want.
 
6:40 PM
@RMartinhoFernandes exactly. Can't partial spec function templates, partial spec a struct and let the function use that. Sheesh
 
oh... the reason it's not executing is because I told gcc my output file was *.cpp
 
type_traits shows two things C++ can't do but could benefit from
 
and CMD doesn't like executing a *.cpp file
 
hmm, my gcc executable on windows is much larger than MSVC's... by 10x
prob static linked vs runtime library linked
@rubenvb what two things?
 
Xeo
6:51 PM
I'm in TS with two guys... who are sync-cooking. Over TS. It's hilarious.
 
fellow Haskell geeks, care to come join me in the Haskell room and answer my question?
 
@Xeo What are you talking about?
 
@MooingDuck inheritance from fundamental types (which can be well-defined the way it's in my head right now) and template function partial specialization.
 
Xeo
TeamSpeak
 
excellent, I now have MSVC external build tools to compile and run via GCC
 
6:52 PM
there's be no need for true_type nor a bunch of structs in type_traits.
@MooingDuck damn man, you're weird.
 
@rubenvb I would LOVE to inherit from fundamental types! (Also: primitive.operator+(primitive))
 
Add clang too, while you're at it
 
@rubenvb true_type is not just a convenience for traits.
 
@RMartinhoFernandes I'm listening/waiting for you to type more.
 
@rubenvb I think you still need true_type, so you can specialize true_type vs false_type... no wait...
 
6:53 PM
You can overload on it.
 
@RMartinhoFernandes you can overload template<bool is_true> as well
 
Like the STL does for optimization based on iterator categories.
@MooingDuck You need some type.
 
@RMartinhoFernandes what? template<bool is_true> func() and also template<> func<false>()
 
@RMartinhoFernandes no? what did I miss this time?
 
6:55 PM
can't you enum and template spec your way out of that?
 
@rubenvb template partial specialization works poorly with overloads I've heard
 
template <typename T> void f(T t) { f(t, is_signed<T>()); }
template <typename T> void f(T t, true_type) { do_stuff_with_signed(t); }
template <typename T> void f(T t, false_type) { do_stuff_with_unsigned(t); }
 
@RMartinhoFernandes enable_if+is_signed?
ooh, I can static_assert my math functions
so you don't take a sin of a char
 
`template <typename T> void f(T t) { f_impl<T, is_signed<T>>(t);}`
`template <typename T, bool is_signed> void f_impl(T i) {do_stuff_with_signed(t);}`
`template <typename T>` oh
 
6:57 PM
@rubenvb Just delete them.
 
alias templates ftw!
@RMartinhoFernandes I'd have to delete the function for every integer type
 
@rubenvb enable_if for whatever it is you were asserting.
@MooingDuck Needs partial specialization.
 
@RMartinhoFernandes I see, partial specialization, gotcha
 
There's a GOTW on why partial specialization of functions is not allowed.
 
@RMartinhoFernandes template<typename T> kiss::disable_if<is_integral_type<T>(),T> constexpr T acos(const T);?
 
7:02 PM
Why can't bitwise leftshift's operands be pointers in C++? they are also integral values, ain't they?
 
and then specialize for float/double/long double?
 
@rubenvb I'd enable it and = delete;
 
@MrAnubis pointers have a pointer type.
 
Shifting pointers makes no sense
 
Pointers are not numbers.
 
7:02 PM
@rubenvb they are integral types
 
@RMartinhoFernandes isn't my way clearer? you're enabling it to delete it.
 
Everything is a number. (Except for pointers.)
 
@MrAnubis No, they're not!
 
@MrAnubis I don't think they're integral types
 
@MrAnubis uh, no? You need a reinterpret_cast. That means != in my dictionary
 
7:03 PM
@StackedCrooked complex types aren't numbers
 
@rubenvb Well, but yours won't prevent another overload from being picked with conversions or something.
 
@MooingDuck because you can't inherit fundamental types!
@RMartinhoFernandes ah yes, good point.
 
@MooingDuck how is a number defined?
 
I hope you get paid for this ;)
 
@jalf ....good call
 
7:04 PM
@RMartinhoFernandes So what must be operands of << operator , only integers?
 
@MrAnubis yes. Doesn't work on floats either
 
I always sweat when I imagine being at an oral exam and math professor asking a questions like: "What is a number?", "What is negative?"..
How the fuck do you define that.
 
@MooingDuck aah , now got it why my conclusions are wrong , Thanks @MooingDuck @RMartinhoFernandes
 
@StackedCrooked books have been written on the subject. I couldn't care less, personally.
 
I could care less, but I feel my level of caring is currently just right.
 
7:07 PM
@StackedCrooked A number is a measurement or a counter.
 
this way of writing the math library would catch a lot of common errors
 
And then he asks, what is a measurement? what is a counter? (It's troll professor.)
 
@StackedCrooked 1: It's an elephant. 2: It's a turtle.
 
@StackedCrooked "what is a measurement?" hmmm, books have been written on that subject. I care more about that :)
 
@RMartinhoFernandes There is truth in that.
 
7:08 PM
@StackedCrooked by studying. The nice thing about exams is that they only ask things that are in the curriculum. So they're only going to ask if you have a fair chance of actually knowing the answer :D
iow, we don't need to know :p
 
My days of college are long gone anyway.
 
@jalf that is not always true.
 
@rubenvb and that is also not always true.
Apparently I'm happy it's weekend.
 
7:13 PM
 
@StackedCrooked Featuring Rebecca Black.
 
I"m officially a moron
in Haskell, 54 secs ago, by Tony The Lion
*Main> ['a'..'b']
"ab"
I asked why this doesn't generate the alphabet
 
@StackedCrooked yes it is. I didn't make a conclusive statement
 
I'm an idiot
5
 
@TonyTheLion congratulations
 
7:19 PM
lol
the fact that this statement is starred supposed to make me feel more idiotic or better?
 
Idiot is short for idiomatic otter.
 
And idiot is someone with lots of ideas.
 
Is it good style to qualify all in-library things? Like using std:: in a standard C++ library everywhere, even though you know you're in std::?
 
7:21 PM
@EtiennedeMartel one of the best games ever, the original at least.
 
@rubenvb How much Haskell do you know already?
 
@rubenvb I think Melee was the best.
 
I use std:: always. I think there's no consensus on this matter.
 
Engine wise, at least. Brawl had the best content.
 
@StackedCrooked That's not what he asked.
 
7:22 PM
@StackedCrooked wtf?
 
@RMartinhoFernandes He means inside the std namespace?
 
@StackedCrooked He asked if you qualify things in your namespace with your namespace.
 
Brawl was disappointment. Melee was competitive. 64 was most fun
 
@RMartinhoFernandes yes that, with namespace std as a ...std example
 
@EtiennedeMartel so, anytime I open this youtube video chrome crashes
 
7:23 PM
@Pubby ah, well, I didn't notice anything after the Super Mario Bros. WAAAAA COOL GAME!
 
@RMartinhoFernandes That's what I first thought. But then I remembered that you are not supposed to add things to std. So I assumed he meant something different.
 
@Pubby Hmm. I don't know. I mean, yeah, 64 was fun, but try coming back to it after playing Melee.
 
@rubenvb I would say no because it's duplication.
 
@RMartinhoFernandes hmm, if I enable_if acos for is_integral and delete it, I can't specialize it for floating point types without declaring the template first, which results in linker errors if used incorrectly :(
 
@rubenvb Overload!
 
7:25 PM
I like this take 24 (cycle "LOL ")
 
@RMartinhoFernandes but then I'm inconsistent with template vs normal functions :(
 
easy way to write "LOL" n times
 
seems I can't have everything the way I want it :/
 
@StackedCrooked You can add specializations to std, but not overloads.
 
Make template call overloads?
 
7:26 PM
@MooingDuck works here
 
@Pubby not following...
ah wait
I get it
 
Btw why are pointers not numeric? Are they not essentially indices in a table of memory locations?
 
@StackedCrooked Pointers may be arbitrarily complex, depending on the architecture. Also, it wouldn't make any sense to add two pointers, because you certainly wouldn't be guaranteed to point to anything valid.
@TonyTheLion lol n = concat $ take n $ repeat "LOL "
 
show the damn picture
ffs
 
@rubenvb What picture?
 
7:29 PM
@FredOverflow Pointers being numeric wouldn't automatically imply that the sum of two pointers points to a meaningful location.
 
@FredOverflow that one
 
@StackedCrooked Please show me a numeric type that doesn't support addition.
 
@StackedCrooked well, C++ is strongly typed, and I hate code that uses pointer to int casts.
that stuff tends to break on Win64 because they casted to long
 
@rubenvb It touches the first one twice, and it doesn't work for the empty list. Is that what you're after?
 
@FredOverflow no, I was after the "Evil Code Monkey" for the "pointer should be an integer type" thing. But my timing sucks due to markdown/google fucking with me.
 
7:32 PM
@FredOverflow That's not what I'm trying to say. I mean if pointers were numeric then that doesn't automatically mean that the sum of two pointers points to a meaningful location. For example if valid pointer ranges are between 100 and 110.
 
@rubenvb We have intptr_t for that.
 
@StackedCrooked Then what's the point of numeric pointers if they don't act like numeric types?
 
@FredOverflow well, people (and Qt, and WebKit and GNU and...) don't/didn't use that
 
@StackedCrooked Let me ask you this: what would you gain by numeric pointers?
 
@RMartinhoFernandes Ah, well never mind.
@FredOverflow Nothing. I just want to understand why they are not numeric.
 
7:33 PM
@FredOverflow indirection! Undefined behavior! More typecasts!
Multiplication!
(don't ask me what that should mean)
 
@StackedCrooked Because it wouldn't make any sense for pointers to be numeric, period.
 
@StackedCrooked I can think of two reasons. First, some architectures use separate registers for pointers and integers. So once something is loaded into a pointer register you'd be limited in what you could do with it. (and moving it into an integer register just to make it behave like an integer could be expensive)
second, some architectures use segmented memory or other weird address models. In those cases, a pointer isn't an integer, but a pair of integers
 
@StackedCrooked we have a system at work where all pointers to integers are between 0x8100 and 0x8200, strings between 0x8200 and 0x8300, and file handles 0x300-0x8400. Really opened my eyes to the fact that POINTERS ARE WIERD. (Note this system can't do enums or C)
 
I'm looking for headphones. Thoughts?
 
yay math templates:
    // acos = cos^(-1)
    template<typename T> enable_if<is_integral<T>(),T> constexpr acos(const T) = delete;
    constexpr double acos(const double x)
    { return __builtin_acos(x); }
    constexpr float acos(const float x)
    { return __builtin_acosf(x); }
    constexpr long double acos(const long double x)
    { return __builtin_acosl(x); }
    template<typename T> enable_if<is_floating_point<T>(),T>
    constexpr acos(const T x) { return acos(x); }
 
7:36 PM
@jalf C++ does that for pointer-to-member types
 
@jalf I see, interesting.
 
@MooingDuck Pointers to member are not pointers.
 
@rubenvb please say you have a constexpr log2 and log10 for integer types
 
@RMartinhoFernandes I was about to say that :(
 
@RMartinhoFernandes they show the wierdness nicely though
 
7:36 PM
But they're not pointers, so the weirdness is not relevant.
 
@RMartinhoFernandes they pretend to be like pointers
 
@FredOverflow I loooove saying that!
 
@MooingDuck hmm not yet. I haven't really done anything but forward to __builtin's and write my own copies of std type_traits :)
 
@rubenvb is there a thing in the standard library for getting the smallest type that holds X bits/decimal digits? That'd be nice too.
 
No, but it's been done to death in this room.
 
7:38 PM
@MooingDuck heh, which platform is that?
 
You can find lots of implementations in the transcript.
 
@jalf in-house homemade virtual machine
 
@MooingDuck hmm, I think Xeo showed me the type selector thingie. I'm sure it can be adapted to suit your needs
 
@rubenvb I've made several, one in the std would be nice
 
@MooingDuck cool :)
 
7:40 PM
@MooingDuck well, in my case it'd be in kiss. I'm not touching std except for <initializer_list> and maybe other hardwired stuff
patches welcome ;)
haha patches for a half ass incomplete library
 
@jalf slow as heck. It's used for speaking audio in multiple languages. Then customers can make custom languages, compile to our company-bytecode, and our virtual machine interprets it. I hate the fool thing.
@rubenvb eh, close enough
 
@ruben add a template <typename T> struct id { using type = T; }; too.
 
I'm looking for headphones to listen to music while I code.

I'm looking for something not too obnoxiously designed (like skull candy), and not too expensive. Noise canceling/wireless is a plus. Durability is a must.
 
Xeo
@RMartinhoFernandes template<class T> using alias = T; is also nice
 
@Xeo Not lazy!
That's the whole point of id.
 
Xeo
7:42 PM
Why?
 
@RMartinhoFernandes what's that for?
is it the std::identity thing?
@Xeo what's that for?
 
Xeo
@rubenvb easier declaration
alias<void(*)(int)> fp;
 
@Xeo Because you can do std::conditional<Cond, id<sometype>, some_metafunction_that_may_fail<T>>::type::type;
 
Xeo
or the infamous function that returns a reference to an array of function pointers:
 
@Moshe You should code in Haskell, then the code is music, and you don't need the headphones anymore.
 
7:45 PM
While std::conditional<Cond, sometype, some_metafunction_that_may_fail<T>::type>::type; would error out.
 
@Xeo is that like a typedef?
 
Xeo
alias<(&alias<void(*)()>)[]> f();
 
I don't see how that helps much.
 
@FredOverflow Lol.
 
Wait, how does lazy templates work?
 
Xeo
7:45 PM
well... somewhat
 
@rubenvb ianquigley.com/iq/ArticleData/A75/EvilCodeMonkey.png => The double check of the first element aside, if the List interface can be implemented as a "linked list" then this is a really sucky solution.
 
@Pubby You don't "invoke" ::type immediately, only at the end of computation.
See the examples I gave above.
@StackedCrooked List is a std::vector in .NET.
 
@StackedCrooked I was more concerned with the evil code monkey. Didn't check the code really.
 
@RMartinhoFernandes Just to be clear, foo<some_metafunction_that_may_fail<T>> doesn't instantiate the inner template unless needed?
 
I thought it was really funny when Alexandrescu muttered: "Indexing for list interfaces, are you crazy!?" When speaking of the .net libraries. (Or was it Java? I don't remember.)
 
7:47 PM
@Pubby It does.
 
Is there some MTP technique to enable_if<overload_exists<T,func_name>,T>?
 
@RMartinhoFernandes But wouldn't the error be caught during instantiation?
 
@rubenvb Needs to be re-done over and over for each function.
@Pubby Yes, that's the problem. It causes an error immediately.
 
@RMartinhoFernandes grrr
 
@Pubby std::conditional<Cond, sometype, fail<T>::type>::type will error out even if Cond is true.
 
7:49 PM
Yeah, but how does the other way avoid that?
Doesn't fail get instantiated either way?
 
It moves the ::type in fail<T>::type out.
 
I'm very confused :S
 
Instead of fail<T>::type as the 2nd argument, you use simply fail<T>.
 
I see that, I just don't get why it doesn't error
 
Now, if fail<T> doesn't have a type member, it doesn't fail.
 
7:51 PM
Oh, the error is fail<T> not having a member?
 
@Pubby You call a meta-function by looking up ::type. Without the ::type part, you don't call it.
 
Nevermind then. I thought it was an error like dividing by zero or something.
 
at compile-time?
 
int_<1 / 0>
 
7:52 PM
Yeah, like that
 
Since when is int a template?
 
@RMartinhoFernandes Any way to make that lazy?
 
whistles
@Pubby Add one level of indirection!
 
@Pubby divide<1, 0> or something, and don't call ::value on the immediately.
 
But wouldn't the member have error?
 
7:54 PM
Not if you don't touch it.
 
Hold on, let met test it
 
@Pubby Writing a normal function that divides by zero is not an error unless you actually call it. Same with meta-functions.
 
That lazyness trick is also good to prevent unnecessary recursion on unused conditional branches.
TMP performance optimization!
 
Hey, it works.
 
Also, I forget a bunch of freaking typenames on the examples I gave :(
 
7:58 PM
Is TMP lazy actually an optimization?
 
What's TMP?
 
std::conditional<Cond, id<Head>, recurse<Tail...>>::type::type will stop recursion once Cond is true.
 
(This comes down to profiling TMP again, hehe)
 
That could prevent lots of instantiations.
 
Yeah, I had to do something like that for that unique number function
 

« first day (461 days earlier)      last day (4486 days later) »