« first day (492 days earlier)      last day (4446 days later) » 

3:00 AM
Tbh relying on the conversion when specifying std::hash<std::string> as the hasher is tricky :) A nice trick, but not to be expected.
 
Xeo
Btw, any better name for it? indirect_key sounds... dunno, not really descriptive
@LucDanton I created a hasher at first, and then remembered the implicit conversion. :)
 
mutable_reference_wrapper. Duh.
 
Xeo
lol
That's what I needed, an even longer name! :P
 
(Saying that in jest since it's not like std::reference_wrapper is immutable.)
 
Xeo
  auto files(boost::copy_range<
      std::deque<dependency>>(direct_deps | boost::adaptors::map_values));
 
3:01 AM
I don't mind long, descriptive names.
 
Xeo
Me likes Boost.Range.
 
You'd likely typedef that map type asap anyway.
By the way, what are we going to use instead of 'to typedef' now.
"Better synonym that map type soon."
Verbing 'synonym' weirds me.
 
Xeo
"Better alias that map type soon."
 
Oh yah, works for me.
$ grep typedef -Ri include/ src/ | wc -l
5
How come I still have 5 >:(
 
Xeo
Man, I'm using so much auto const& in my code right now...
 
3:04 AM
Nothing wrong with that.
 
Xeo
I think my code could even be ported to a functional language without much difficulties.
Atleast that part
 
Heh, I wrote a metafunction to compute the resulting type of a variant double visitation. I didn't really have a plan so I just went with functional list deconstruction and surprise, recursion makes the thing works.
By the way, if you had a visit operation to apply on a variant and a functor, in what order would you pass the parameters and what would it look like?
(I like to usually badger the robot with my naming/usages silliness :( )
 
Xeo
visit(variant, functor)?
 
Sounds obvious, right?
 
Xeo
Or apply(functor, variant).. or even apply(variant, functor)... Damn, I see where you're coming from.
 
3:08 AM
As a member it'd be variant.visit(functor). No brainer here.
 
Xeo
@LucDanton Member template == nested template keyword in generic code
 
But how does that work for binary visitation? :(
 
Xeo
Which is a strong reason to prefer non-member templates
 
@Xeo Right, but it's not a member. You know, like how it's getline(stream, string).
 
Xeo
@LucDanton How is variant.visit not a member?
 
3:10 AM
Not getline(string, stream) and I don't think it's a coincidence it mimics stream.getline(string).
@Xeo Because I wrote it not as a member.
 
I can totally see visit as a member
 
Xeo
Ah, you mean logically.
 
Yep.
 
I don't see how you'd reasonably implement it as a non-friend
 
Xeo
@DeadMG non-friend != non-member
 
3:11 AM
@DeadMG It's a friend. But there's a whole lot of reason to prefer it as a non-member.
 
Xeo
Or do you mean "part of the public interface"? :P
 
what's the point of a friend free function?
 
Given that visit<void>(variant, functor) is also how you 'discard' the results.
 
Xeo
@DeadMG No nested template keyword.
 
I mean, for operators, I get it, argument conversions and stuff
 
3:11 AM
@DeadMG See relevant GotW.
 
@Xeo You wouldn't need it anyway, because there's no need to pass an explicit parameter
@LucDanton You might have to be more specific. I don't have a database of them on hand, y'know
 
Xeo
template<class Variant, class F>
void foo(Variant const& var, F f){
  var.template visit(f); // UGH!
}
@DeadMG Isn't template needed even for deduced types?
 
no
it's only for explicitly passed parameters
 
@DeadMG Tried Ctrl-F for 'string', 'member', 'bloat', 'interface' but no dice.
 
to remove the ambiguity inherent in var.visit < identifier > (expr); which exists when you don't know that visit is a member template
 
3:13 AM
It might actually be in the book, I really thought there was a GotW for that.
 
there's no such ambiguity for member templates which only take implicit arguments
 
Xeo
@LucDanton There is.
 
@DeadMG What's the result type of your hypothetical visit?
 
Xeo
Sometimes, Google is just the easiest way.
"gotw string"
 
Wut.
I... wut.
 
3:14 AM
@LucDanton That can be deduced from the parameter type
 
This is so dumb I think I broke.
@DeadMG variant<std::string, int> v; visit(v, make_overload(++arg1, arg1 + "foo")); what does that return?
 
also, I read that GotW and didn't see anything about avoiding member templates
@LucDanton void
 
@DeadMG Mine returns variant<std::string, int>. If you call visit<void>(/* ... */) you get yours.
 
@LucDanton Well, I can't see why you can't just have both. If I don't want the return value I just won't take it.
 
Xeo
Btw, rethinking that member visit, I think variant.visit(f) sounds wrong.. variant.apply(f) would be better as a member
 
3:17 AM
@DeadMG If you want to avoid the variant construction. Have to be generic, "Don't pay for what you don't use" etc.
 
Xeo
@LucDanton visit(...., return_<void>()) !!
 
@Xeo yes. thinking usage for naming is good. thinking implementation for naming is bad. :-)
 
@Xeo Die.
 
@LucDanton That's what compiler optimizations are for
 
@DeadMG Right, right. You're free to call it without passing void.
Xeo is making the argument of avoiding template members, I'm not.
 
3:19 AM
ok
well, I'd totally make that function a member
 
Nothing wrong with that. (I also like the naming suggestion.)
But what about binary visitation? Now what?
 
oh, and you don't have to have void explicit specialization
you could simply return one of those lazy evaluation automatic cast objects
@LucDanton What even is binary visitation?
 
@DeadMG Those overloads are here to distinguish the request for type deduction vs. the request to ignore the return type.
 
Xeo
visit(var1, var2, binary_func) I think.
 
visit<void> is indeed implemented like you said, yes ;).
 
3:21 AM
with an automatic conversion, you don't need to distinguish.
 
Wut. Run my answer again I think.
One overload picks visit(..., the other picks visit<void>(...
 
Xeo
@Luc, what's binary visitation?
 
Then visit computes the return type just fine.
 
yes, but you don't need to choose
 
@Xeo Visiting two variants at once.
@DeadMG What, lazy computation?
 
Xeo
3:22 AM
Hm.. any usage examples?
 
sure
 
Xeo
Like, the functor really can only have a templated operator()(T1, T2)
 
Or a bunch of overloaded operator(), yes.
I'm just replicating the original Boost.Variant feature here.
@DeadMG Let's put it another way: visit<void> is an advanced feature. It doesn't matter that it stands out when used, visit(...) should be the default.
 
there's no need for it to be a friend non-member
 
boost::variant< double, std::string > v2( "hello" );
assert( boost::apply_visitor(are_strict_equals(), v1, v2) );
Boost.Variant example of binary visitation.
The functor returns false if the two types are different, or delegates to == if they are the same.
@DeadMG Tbh I'm more interested in the order of parameters than member vs non-member.
I.e. if you keep at it I'll be making it a non-friend, non-member.
 
3:27 AM
I'd definitely place the variant(s) first and then the functor
 
So apply(left, right, f) (to reuse your name)?
I considered apply({ left, right }, f) but that seemed like a gratuitous std::pair construction for the sake of syntax.
 
yes
 
That's not too bad.
 
I do my best
 
It even mimics transform when applied to two sequences (minus output iterator). Perhaps I should just call it that: transform.
 
Xeo
3:29 AM
@LucDanton I thought about that too, but it doesn't transform in the functional sense
 
I even have a transform for std::tuple (as a non-member, which makes it an argument to have it as non-member for variant, hah!).
@Xeo Can't find what is usually used with Either in Haskell.
 
Xeo
Well, normally a visitor does something to the variants elements, and doesn't just transform them. In functional languages, you can't really do anything else than transform and return, so I'd guess it's just map
 
I have transform(tuple, functor) and also map(functor, tuple0, tuple1, ..., tuplen).
By the way the name transform is a callback to std::transform... which is map in the functional world.
 
Xeo
And to keep it with C++, it would really be transform, but applying a functor to a variant is idiomatically called visit or apply :/
 
idioms are over-rated
if you have something superior, then use it
being idiomatic only has so much value
 
Xeo
3:35 AM
@LucDanton Having two different orders is bad, isn't it?
 
@Xeo I think calling Boost.Variant 'idiomatic' for C++ is a bit of a stretch.
 
Xeo
@LucDanton Does map apply the functor in turn to each tuple, or to a tuple<get<I>(tuple1), get<I>(tuple2), ...>?
 
@Xeo Meh, Haskell has both mapM and forM that do the same thing, but with the parameters not in the same order. Admittedly that's useful convenience when you have currying.
Still, map is variadic where transform is not in my case. So, convenience with different functionalities.
@Xeo Second one. That wouldn't be very useful otherwise.
 
Xeo
@LucDanton Okay, and does it actually pass a tuple, or is the functor required to have an N-args operator()?
 
If I made a map operator you'd get the first one with transform(std::forward_as_tuple(tuple0, ..., tuplen), operators::map { functor }) or some such.
@Xeo It unpacks the tuple(s).
Let me check to make sure though since I do have uncurry.
 
Xeo
3:40 AM
@LucDanton Yeah, but does it pass the unpacked ones as N arguments, or as an N element tuple?
 
Sorry, bad explanation. Yes, presents individual arguments.
 
Xeo
k
 
(Confusion since under the covers there are in fact intermediate tuples as slices.)
 
Xeo
Otherwise, transform(zip(tuple1, tuple2, ..., tupleN), functor) would work too, with overloaded get<I> for the zipped_tuple that returns a tuple of args
transform would only have to bother with a single tuple, and functor with a single template parameter
 
Whoah I can't overload that, I'm compatible with std::tuple here.
 
Xeo
3:43 AM
Though having the tuples unpacked for you certainly does seem convenient
 
@Xeo Who needs template parameters when you have lazy-eval EDSLs.
 
Xeo
@LucDanton Huh? Why not? It'd be a new tuple type called zipped_tuple<tup1, tup2, ..., tupN>
 
map(arg1 += arg2, left, right);.
 
Xeo
eww, unpure mapping. :P
 
@Xeo Well then it's not an overloaded get is it? :p
@Xeo I wasn't going to call it for_each as that already has a 'usual' interface.
Nevertheless, I notice your suggestion mimics my idea of apply({ variant0, variant1 }, functor).
Although I remember I explicitly wanted to avoid apply(std::tie(variant0, variant1), functor) or the like as 'too verbose'.
Eh, can't use list init syntax with deduction in this case anyway I think. I'm screwed.
 
Xeo
3:50 AM
@LucDanton Could you even do that with list initialization? What's the type of the first parameter to apply?
Heh
 
Until now I only pondered what to use, not how feasible to implement it was :)
 
Xeo
hrhr
 
For instance there was the critera of "Can I generalize that syntax to an arbitrary number of variants"? Even though I'm pretty sure I'm not going to implement that.
Traversal of the cartesian products of all possible active variant members doesn't look too much fun.
I found another motivation to call it apply rather than visit: it's like Boost.Variant apply_visitor, but without the StaticVisitor concept!
 
Xeo
Hm, so constexpr is finished, lambdas nearly too, and list initialization seems to be going strong with many things already in place
 
Wait, I already have apply_tuple. How dense can I be?
 
Xeo
3:55 AM
lol
 
I have apply_tuple, tuples::transform and tuples::map (that I wanted to rename apply) that all do the same thing? How did I do that?
Ah they don't do the same thing. I have the urgent need to find more meaningful names though.
tuples::map is zipWithN in Haskell.
Guess I could go with that name.
 
Xeo
But without the N
zip_with
 
To be clear (not sure how familiar you are with Haskell), there's zipWith, zipWith2, and so on.
So yeah, without the N.
 
Xeo
I read about it on the wikipedia map function page
> Python map(func, list) map(func, list1, list2) map(func, list1, list2, ...)
 
My apply_tuple is uncurry (minus currying).
 
Xeo
4:01 AM
Having the functor as the first argument makes sense in a way...
 
That it does.
 
Xeo
"map this functor over these things..."
Meh, nearly every other language has the functor first. C++, of course, not.
Damn you, iterators.
 
And now you see why I provide both transform and map :)
 
Xeo
We need a real functional <functional>, including real ranges and not pure iterators.
That said, Boost.Range ftw.
 
I guess I could call it uncurry(f, tuple) to mean my current uncurry(f)(tuple).
Yeah that makes so much sense actually.
 
Xeo
4:05 AM
What's uncurry?
 
If you do uncurry (+) then you have a function taking a pair of integers.
 
Xeo
Otherwise, two integers?
wait
 
(In my current state of affairs uncurry is the name of the operators for what is currently apply_tuple. But nevermind that.)
Yep.
Due to syntax rules though uncurry (+) (3, 3) is valid.
 
Xeo
Isn't (X, Y) a 2 element tuple?
 
Argh. std::tuple doesn't really map to functional tuples the way my tuple helpers are designed.
 
Xeo
4:08 AM
Heh, why?
 
Sorry, had to have the disclaimer added. They're both models of plain mathematical tuples, nothing weird going on here.
 
Xeo
Ah
Yay, 1000 lines template errors \o/
 
Anyway the usual functional map works in that map f [a, b, c, d] == [f a, f b, f c, f d]
 
Xeo
And if f takes more than one parameter, you got a "curried" list
 
I'm using ML/Haskell-like pseudocode where [] means list.
In any case if f did take more than one parameter, there would indeed be currying. The return type would still be a list though.
ghci> :t map (+) [1..10]
map (+) [1..10] :: (Num a, Enum a) => [a -> a]
If that means something for you.
(The [a -> a] is the interesting part, the Num/Enum stuff not so much.)
C++ wise my tuples::transform goes transform(<a, b, c, d>, functor) == <functor(a), functor(b), functor(d)>, using an imaginary <> tuple literal instead of std::forward_as_tuple.
As you can see tuple::map(f, <a, b, c, d>) == <f(a), f(b), f(c), f(d)> has some resemblance at the expression level (not so much type level) to the functional map.
There is similarity between std::tuple and functional lists at the metaprogramming level, too.
 
Xeo
4:17 AM
Yay, the errors are getting less
Ohey, hello C4100 "unreferenced formal parameter" for this code:
virtual void failed(Model* x)
{
    x->~Model();
}
Together with a foot-long instantiation backtrack
@LucDanton I wonder how hard it would be to get true currying to C++. Theoretically you'd only need to return a new functor that has some parameters bound...
Hmmm
 
@Xeo Haskell has a trade-off in its type system in that variadic functions aren't really possible. Hence the zipWithN. I can't remember however if the trade-off is about currying or inference.
@Xeo However I think what an implementation of a hypothetical 'C++-with-currying' using the mechanism you described would only be an emulation of what a compiler like GHC can do.
 
Xeo
Sure
template<class R, unsigned FreeParams>
struct currying{
  template<class... As, class = typename enable_if<sizeof...(As) < FreeParams>::type>
  currying<R, FreeParams-sizeof...(As)> operator()(As... as){
    return { as... };
  }

  template<class... As, class = typename enable_if<sizeof...(As) == FreeParams>::type>
  R operator()(As... as){
    return _f(unpack_bound, as...);
  }
};
Now on to storing the bound parameters...
 
I don't mind the current state of affairs in C++ with std::bind/lazy-eval EDSLs.
 
@EtiennedeMartel : These are new in c++ 11?
 
@FaheemMitha Yep.
 
Xeo
4:26 AM
So, think that currying wrapper is a good start?
 
I think you're going to reimplement some features of a lazy-eval EDSL right here :p
I can do ref(operators::plus {})(42)(42) just fine currently.
 
Xeo
Maybe, but it's much more concise, dontcha think?
Meh
With that, you can wrap any function atleast!
 
Well you can write it (arg1 + arg2)(42)(42) if you want.
@Xeo Err operators is not part of the EDSL. It counts as 'any function'.
It's my superior alternative to std::plus although in this case you could have used std::plus<int>.
 
Xeo
Oh, so does ref kick of the EDSL?
 
Yes.
 
Xeo
4:30 AM
Alright, then. :( How does your currying work?
 
@LucDanton what does that mean
 
Welp imagine you implement operator() to 'do the right thing', i.e. apply the expression.
Nothing exotic right? (arg1 + arg2)(42, 42) == 42 + 42
Well you make sure that this operator() always uses something dependent on its return type, even in the nullary case, then you SFINAE on that such that another overload kicks in when the expression can't be applied ;) Then this operator() only has to return a new expression.
 
@KianMayne : That's an accurate description of what can happen if one is foolhardy enough to visit tvtropes. But I've developed some antibodies to that site now.
 
@AlfPSteinbach I'm not sure it's correct since I'm using ref on a temporary, perhaps it should be val. Anyway the ref/val is here to 'convert' an arbitrary value, here a functor, into an expression of the EDSL. Then I twice pass 42 to that expression.
 
Xeo
Hm, I wonder why my program doesn't do what it should... well, it can't if I don't give it any input...
@LucDanton Hm, sounds much more complicated than just returning a new functor expecting less parameters. Unless that's what you're trying to describe :P
 
4:35 AM
Let me check that I don't actually need plus(arg1, 42)(42, arg2) though.
 
Xeo
That looks fugly.
 
@Xeo Well, you need to make sure that plus(42)(42) stops currying and doesn't require the user to do plus(42)(42)(), so somehow you have to do the SFINAE on what I described as 'applying the expression' (i.e. evaluate it in full and return that).
 
Xeo
Okay, easiest way from set<(x, y, z)> to map<y, (x, y, z)>?
@LucDanton Check my currying again, if it gets passed an exact amount of parameters, it applies the expression (stored function)
I feel like I need transformed for my problem...
 
@Xeo Same deal: how do you count the free parameters anyway?
Stop having a free lunch :|
 
Xeo
@LucDanton What do you mean?
 
4:39 AM
How do you figure how many free parameters there are?
 
Xeo
I store it in the functor type! :)
 
How, at construction, do you count that?
 
Xeo
> currying<R, FreeParams-sizeof...(As)>
Uhm... can we rewind the last 5 minutes? :| For non-overloaded functors, it's easy, but...
Well, worst case, the user needs to specify which overload he/she/it wants
Until I have a better solution in mind
 
Definitely worst than what I have (or not, I can't figure out what works and what doesn't).
 
Xeo
lol
 
4:43 AM
Well I have something that works and not only does it look ugly but there's certainly nothing automatic about that currying. It's really binding: plus(arg1, arg2)(arg1, 42)(42)
 
Xeo
Ow
 
So I'm not so sure I have currying? I don't have many unit tests either.
Apparently I only made sure that the operators (of the EDSL) worked in my unit tests.
Dunno if that's salvageable and I can make operator() 'smarter'.
 
Xeo
The worst nightmare - having to refactor your template code from months ago.
 
Actually I've gone through that code not so long ago and it's not that bad :)
Hence why I could describe the currying thing from memory.
 
Xeo
Oh, then you're better off then me on that part. I sometimes code some strange thingy, get back to it a day or two later and have to "rediscover" what I did there.
 
4:48 AM
Well I did so some cycles of "Get an idea, hack something, get an idea to improve the idea, look with dismay the previous code, hack something from scratch".
 
Xeo
Damn, I want std::tie for std::pair without having to use std::make_pair(std::ref(...), std::ref(...))
Oooh, yeah, I know that feeling.
"Who the fuck coded that! ... Oh, wait, that was me, 10 minutes ago."
3
 
I got tired of that so now I make sure I can at least figure out intended usage from unit tests (which documents the intended interface, in part). Hence my disappointment when I found out I don't have so many tests for my EDSL.
 
Xeo
Sometimes, I hate compilers. "Hit F7 (compile) ... wait... see compiler compiling changed file ... wait ... hope ... no errors yet ... still not ... BAM 100 page error"
 
Right now I think that what the operator() in charge of currying returns isn't "smart" enough.
Bwahaha I'm already figuring out things to improve.
 
Xeo
Aww, damn. Boost.Range doesn't play nicely with lambdas, since they don't have a nested result_type or result template...
 
4:53 AM
umad bro?
 
@Xeo Is that with BOOST_RESULT_OF_USE_DECLTYPE?
 
Xeo
I always forget that, thanks.
 
@Yokhen I nomad
 
Xeo
Omg, it works.
I'm so happy right now.
 
@Xeo congrats. Those are the effects of doing something right in programming. Infinite happiness
 
Xeo
5:20 AM
Anyways, I'm off, g'night.
 
5:56 AM
Does anyone know if there is a way to filter favorite questions on SO by tag?
 
6:08 AM
Maybe I could add a wishlist item.
Where did everyone go?
Oh god. I drove everyone away.
 
6:39 AM
unlikely
it is 6:40am here and similar times in countries from which most regulars are from
 
@DeadMG : Just kidding.
I'm passing a arg to my code which is a struct I defined, but it doesn't like that I declared it const. I'm getting:
pval.cc:379:50: error: passing 'const lik2' as 'this' argument of 'double lik2::data_stat_from_pvals_partial(const std::set<int>&)' discards qualifiers [-fpermissive]
Am I missing something obvious here? I'm getting errors calling member functions of that struct.
Do I need to declare the member functions const or something?
 
sbi
STAND BACK, I've got a hammer! "if( T *t = f() ) …" Ooooh so many nails around me!
 
7:03 AM
@sbi Best done when f is dynamic_cast<T>
 
@FaheemMitha You're calling data_stat_from_pvals_partial from a member that is not marked as const.
I don't get the joke, if any :|
 
7:47 AM
Recommendations for parsing various numeric types from string, especially when the type (float vs int) is not known? Probably something in boost?
 
@robjb When you don't know the type, you will have to encode a full parser
 
@DeadMG Thought that might be the case
Thanks for confirming
 
how are could you possibly deal with it in any way if you don't know the type?
you would have to resort to a dynamic system anyway
 
I was hoping perhaps someone already had implemented is_numeric(const string&) or something similar
But parsing character by character myself is no big deal :)
 
lol
you can use Spirit
 
7:54 AM
hmm?
 
it will recognize various numeric types
 
@DeadMG Someone call me?
 
@sehe no
 
@DeadMG Y U SO HARSH
@robjb No big deal unless you want to interpret the results. Correctly.
 
@DeadMG Interesting, thanks
@sehe That depends on the amount of types and formats I need to support... currently that is quite limited
 

« first day (492 days earlier)      last day (4446 days later) »