« first day (1826 days earlier)      last day (3123 days later) » 

10:00 AM
@LucDanton erm... but I still need to enable_if that wouldn't I?
 
I always forget the ingredients for printing a hex string.
 
@LucDanton Ah, I should keep an eye on that when I implement structs. Thanks!
 
@thecoshman In the client? No. In the implementation? Maybe, but don’t be so sure.
 
for (auto& byte : str)
    std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(byte) << std::dec;
Especially the cast.
 
@thecoshman decltype(declval<T>().get_name()) gives you whatever get_name returns; you can SFINAE in case the type doesn't exist
 
10:01 AM
@thecoshman I’m telling you to separate the concerns here because specializing class templates is awful re: boilerplate/verbosity/duplication.
 
I have a cool project idea.
 
got another upvote today, the more upvotes I get the more I get annoyed :<
 
@R.MartinhoFernandes *g(); by itself already triggers a warning on my compiler, because dereferencing and then not doing anything further is pointless.
 
Ugh, vimL
@fredoverflow Er, that's false. What type did you use?
A compiler that warns of such is broken.
 
10:02 AM
Why? Counter example?
 
@R.MartinhoFernandes Dude it’s C for beginners.
 
void operator*(T const&) { std::cout << "hello"; } @fredoverflow
 
@thecoshman what should that do when the class does not have a class_name() member?
 
@LucDanton Oh, I missed that.
 
@AndyProwl just use 'a class'... or maybe use the ugly mangled type id thing
 
10:03 AM
@fredoverflow My point is that you didn't use the type I described.
 
@R.MartinhoFernandes There is no such type in C, right?
 
@LucDanton I believe you since it's fred, but did he mention it?
I struggle to find it, but everyone seems to know so.
 
@R.MartinhoFernandes Kinda, but that’s a while ago.
i.e. he’s quoting from his reddit thread (I assume)
 
@R.MartinhoFernandes Well, everybody seems to imply it from the fact that I write a C compiler, not a C++ compiler ;) But no, I didn't mention it explicitly in the challenge quotes.
@LucDanton correct
 
@LucDanton Ah, ok.
 
10:05 AM
sorry for the confusion
The C++ examples are still interesting, of course :)
 
No worries.
 
@thecoshman I’m writing you a demo but I’m all tea’d-up and cozy, so might take me longer than usual.
 
black tea with honey and milk?
 
My eyes.
@ScarletAmaranth Dude, trigger warning.
 
@ScarletAmaranth Green tea with ginger and cinnamon. I add the honey when my throat is sore, which has been happening a lot these past few weeks :(
 
10:07 AM
@AndyProwl typeid(your_object_here).name()
 
@R.MartinhoFernandes and this?
 
5 mins ago, by R. Martinho Fernandes
Ugh, vimL
 
@LucDanton You have two girls over?
 
Dead on inception.
 
braaaaam
 
10:08 AM
tpooooooope
 
@fredoverflow Yes. I only get the honey some of the time though.
 
@LucDanton pointing me in right direction would suffice
 
@R.MartinhoFernandes Oh I was making a reference to this actually lol
 
@GregorMcGregor lol, accidental jokes
 
@thecoshman Well I have been but that doesn’t seem to be working so I’m changing tacks.
 
10:09 AM
@thecoshman cpp.sh/6tccq
 
@thecoshman You can use something like this but trust whatever Luc will come up with more than that. Anyway you can find one basic way to detect whether a class has a certain member is here
 
(Do I get bonus points for no std::enable_if?)
 
@Griwes good lord!
 
oh yeah Griwes's is better
 
Oh damn, Bram works at Google in Zürich. I shouldn't have told them to fuck off when they contacted me from there.
 
10:10 AM
SFINAE-based overloading. :D
 
@Griwes no, you lose points
 
lol
 
> Right before I went under to have surgery on my septum... I was about to start counting backwards before they put the mask on.
"Does anyone need anything while I'm out?"
The last thing I remember was an OR room full of people hysterically laughing. Source: https://www.reddit.com/r/AskReddit/comments/3ovic6/what_would_be_a_funny_thing_to_say_to_a_surgeon/cw17j2d
 
@R.MartinhoFernandes Fred's thingy he's doing warnings for is a C beginner IDE.
 
not starting with C could work too
 
10:15 AM
Yeah, I forgot that. Thanks
 
so much for robo-memory ;p
 
What's BSc again?
 
because you typed it there
 
Breast collision
 
10:18 AM
that's why it's
 
Like here:
32 mins ago, by ScarletAmaranth
@BartekBanachewicz do you have your BSc. at least?
 
but why is A() an lvalue, but int() is not?
 
@Jefffrey BSc is Bachelor of Science.
 
A() is not an lvalue.
 
@Jefffrey Bachelor of Suckage
 
10:19 AM
@orlp because the return value of int() is an rvalue
 
I see
 
@VermillionAzure how can constructors return diferent types?
 
@orlp The return value of the constructor is an lvalue.
 
That or Bartek Sucks
 
@thecoshman here
 
10:19 AM
@VermillionAzure Are you fucking kidding? A is a type, not an object.
A() is a temporary default-constructed A, just like int() is a temporary default-constructed int.
 
@orlp Because your A's assignment operator is not ref-qualified.
 
@Puppy hmmmmm
 
@orlp assignment for fundamental types requires lhs to be an lvalue
for user-defined types it's different
 
@VermillionAzure Being able to write x = y does not mean that x is an lvalue!
 
@fredoverflow is true
 
@LucDanton coliru is broke atm
 
sighhhh
 
@thecoshman oh it works on my end, hang on
 
@AndyProwl More generally, assignment for UDTs follows the rules for UDT member functions, which is no value category restriction by default.
 
right
didn't feel like typing the whole thing out :P
 
10:21 AM
@R.MartinhoFernandes I've never used that
 
@thecoshman here
 
IYAM the compiler-generated assignment ops should be lvalue-qualified.
Wide does that now
 
@orlp Also consider A().operator=(0); vs int().operator=(0);.
 
@BartekBanachewicz "uni teaches mostly useless stuff"
 
10:22 AM
yeah, I totally forgot about the ref qualifier thing
that makes sense
I was just weirded out because I thought that the constructors returned different types
 
> It's crazy fast because of zero-copy optimization of msgpack-ruby.
>crazy fast
>ruby
 
well, of course they return different types.
one constructs an int and the other constructs an A.
 
well, outside of that >.<
 
there is no outside of that.
 
@GregorMcGregor "crazy" is the right qualifier since Ruby is involved.
 
10:24 AM
value category in C++ is not a direct part of the type system.
 
@LucDanton niebler power unleashed
 
fair enough
 
The Nieble is real
 
10:24 AM
"I was just weirded out because I thought that the constructors returned different value categories"
obviously I see now that it's part of operator='s qualifier requirements, but I forgot those existed
 
Was there ever any point in allowing assignment to rvalues?
 
optimization
 
no.
 
Hey guys can you help me with an issue I have in understanding immutability in C++?
It's very urgent
 
it was permitted only because of a lack of ref-qualifier functionality.
 
10:26 AM
yes jefri
 
@Jefffrey Quick, ask the question before we lose interest!
 
Why the fuck would you make an immutable interface in C++?
 
What do you mean by "immutable interface"?
 
for the same reason you would make anything immutable- because mutating it doesn't make sense.
 
you mean only const member functions?
 
10:27 AM
for example, Wide types are immutable interfaces.
 
An interface that does not allow non-cost member functions or friend functions other than the constructor and destructor.
 
@fredoverflow It’s just any other overloaded operator call, and many such operators are useful on rvalues. It’s more that disallowing it specifically required more language.
 
for certain value types it makes sense
 
Isn't that the kind of immutability that is professed in C++?
 
10:28 AM
ok, modulo assignment
 
@Jefffrey Do you have a concrete example in mind which you found somewhere?
 
@AndyProwl %=
 
I think that's fine if it makes sense
 
@GregorMcGregor lol
 
@GregorMcGregor lol
 
10:28 AM
it shouldn't be a design ideology though
 
@fredoverflow Give me a sec
 
like, shoehorning a type into immutability
just for the sake of immutability
 
@Jefffrey enum class?
 
but obv. anything that can be const should be const
 
@orlp Immutability is the new black!
 
10:29 AM
@fredoverflow racist
 
@fredoverflow rebecca immutability
 
@orlp must be muted
 
uuuuuuuuuuuuuuu yeaaaaa yeaaaaaaa
 
10:30 AM
blacklist is so raicsm
 
@chmod711telkitty What about blackboard vs. whiteboard?
 
const-correctness is apartheid
 
what do you think? ;)
 
In yajna (HashLife) the domain of the cells is readonly. There is an finite number of cells of each dimension and mutating them is not interesting because the mutated cell you want already exists somewhere. You just read the desired cell instead of mutating an existing one. Forbidding mutation enables sharing, which is the powerhouse of the efficiency.
 
> blackboard singing in the dead of night
 
10:32 AM
@R.MartinhoFernandes I didn't know efficiency had a powerhouse. What colour is it?
 
Wide bans mutating types because what the fuck would that even do.
 
but mutability is an optimization
 
@Puppy introspection
 
introspection is read-only.
 
and meta-programming
 
10:33 AM
as is metaprogramming.
 
@orlp That's not mutation o_O?
 
@fredoverflow Yeah, I can't find it now but there was a blog post that talked on how immutability in C++ is the new mantra and how it's simple to implement by just having the constructor and destructor be the only member functions that modify the object and so on.
 
@R.MartinhoFernandes I'm probably misusing the term
 
And they used a date object to show that IIRC
 
@Jefffrey As Robot said, immutability without sharing is pretty stupid for large objects.
 
10:34 AM
For a date object and certain value types it can make sense but "new mantra" is silly
 
honestly I don't think immutability is that great for random values
 
@Jefffrey I hope that date object doesn't have a destructor.
 
it mostly makes sense for larger data structures
 
so how would you write an object pool in Haskell (with the goal of avoiding dyn allocs)
 
@R.MartinhoFernandes ?
 
10:34 AM
mutability is a requirement, isn't it?
 
@Jefffrey RoZ
 
I'm curious about which scenario would desire a destructor and immutability.
 
@GregorMcGregor Haskell has no notion of objects ;)
 
@GregorMcGregor the answer always seems to be monads
or gonads
 
@fredoverflow An aggregate of data, anything that can be reused
 
10:35 AM
I forgot which
 
Implicitly defined destructors count too
 
how about assignment operators then
those should count as well
 
Nope
8 mins ago, by Jefffrey
An interface that does not allow non-cost member functions or friend functions other than the constructor and destructor.
 
 
then I don't get it, are they saying you should delete them
 
10:36 AM
@GregorMcGregor It's values all the way down, and Haskell uses sharing under the covers quite a lot.
 
@Jefffrey does the date type in that tutorial have deleted assignment operators
 
@GregorMcGregor It’s not possible.
 
@fredoverflow Doesn't answer my question :p
 
@AndyProwl Well, yes. That's the whole purpose of immutable objects.
 
@AndyProwl That would be pretty stupid, then you couldn't put them into vectors and shuffle stuff around, could you?
 
10:37 AM
@Jefffrey But those have no mutation.
 
Not being able to be modified later.
 
@fredoverflow Yeah
 
@LucDanton Aw :( so anything based on, say, double buffering would be out?
 
18 secs ago, by fredoverflow
@AndyProwl That would be pretty stupid, then you couldn't put them into vectors and shuffle stuff around, could you?
 
@AndyProwl Did you say... tutorial?
 
10:38 AM
NO
 
@R.MartinhoFernandes They are not implicitly declared const IIRC
 
@GregorMcGregor Well you can keep two buffers and write+swap as needed.
 
@LucDanton But that's mutating them?
 
@GregorMcGregor Yeah.
 
Anyway. I'm glad you are baffled at this too
I wish I could find that blog again
 
10:39 AM
link?
ah
I think I remember reading it anyway
and I think it didn't say you should always do that
 
@AndyProwl you can put them into vectors
 
@LucDanton Alright, thanks
 
There were more than one by the way. But other were with Java code.
 
you just have to placement delete and placement new
 
@orlp well, ok, you can't remove them from vectors
 
10:40 AM
@Jefffrey Oh, it's different in Java, I'd say.
 
@Jefffrey Shared immutable objects work far better in Java than in C++.
 
@AndyProwl you can, pop_back
 
sigh
 
@fredoverflow That's not really true.
 
@fredoverflow Exactly.
 
10:40 AM
@LucDanton couldn't that name_functor just be a lambda?
 
or are you suggesting that the std::vector itself is immutable?
 
I was looking for "immutability implementation" for functional languages and all I could find were these blog posts on how to make your interfaces immutable in Java or C++ and how wonderful and functional-like they were
 
in general you can't remove them from a vector unless they're the last element
 
I prefer to go with immutability for larger program structures
not basic types
 
@AndyProwl why not?
 
10:41 AM
To me they seem to have nothing to share with functional-like immutability
 
@AndyProwl Hence "you can, pop_back"
 
I do it for thing that are essentially mathematical objects.
 
@orlp cause that will try to move the following elements by one position to the left
 
@orlp Because then you have to "move" some other objects.
 
using move-assignment
 
10:41 AM
@GregorMcGregor The obvious limitation for a 'general purpose' pool is that there is no object model as fred pointed out. You can do things like ask for hashable types in a map/pool/whatever which would make sense for (possibly strict) finite types but that’s imo going against the flow when it comes to Haskell. You should probably try sharing things first.
 
I guess
 
Removing 2 from (1, 2, 3) involves moving 3 into 2's position.
 
I can make ImmutableRetardVector
 
@thecoshman In actual code I tend to have constexpr everywhere, in which case no.
 
10:42 AM
that uses placement new/delete for everything
 
@fredoverflow How?
 
@Jefffrey Garbage Collection
 
@orlp Yes, that'd work.
 
ref-counting works well enough in most cases IYAM
 
@fredoverflow Well you can have reference counting in C++ for shared data
 
10:43 AM
lol the $35 item humblebundle.com/weekly
 
@Puppy ...as long as you can guarantee no cycles.
 
@Puppy So where is the de-facto standard C++ immutable collections library?
 
@Jefffrey Wouldn't work in my example above, for example.
 
@LucDanton ah
 
@AlexM. lol
 
10:44 AM
@fredoverflow std::shared_ptr<const std::vector<T>>
 
The complexity guarantees are abysmal.
 
@Puppy lol
 
@Griwes Reasonable enough.
 
@Puppy Just pointing out it's hard to detect automatically.
 
@thecoshman I also actually have constexpr auto& foo = constant<foo_functor>;… don’t ask.
I blame Chandler.
 
10:45 AM
auto&&, no?
 
@R.MartinhoFernandes You mean the cell example?
 
no, although of course it’d work
 
@Jefffrey Yes; exploiting cyclic structures is the whole point of sharing there.
 
constant<foo_functor> is an lvalue?
 
@LucDanton I'm trying to avoid allocations, the rest of the design doesn't matter to me
 
10:46 AM
@LucDanton oh, you have the use case backwards
 
@Griwes Honestly, I figure that it should not be too hard to have a compiler pass to prove the absence of cycles, at least in most cases.
 
or at least not quite right.
 
@AndyProwl yeah, if it looks like that it must be an entity—either function or variable template spec.
 
@R.MartinhoFernandes You could use std::weak_ptr for cyclic structures
 
@LucDanton I see
 
10:46 AM
@Puppy The point of immutable collections is that auto a = b.add_element(x); should be efficient, and it should leave b intact.
 
can someone explain to me why functional style programming always is presented hand-in-hand with immutability?
 
Your 'client' has an instance of T, not just a type T. I want T to have the instance of the client
 
@fredoverflow That is a pretty trivial wrapper really.
 
for me those are kind of orthogonal philosofies
 
@orlp something something function and purity and mutation
 
10:47 AM
@Jefffrey Wouldn't work in my example. weak_ptr is only good for breaking cycles where there is a clear hierarchy between different objects.
 
and shoehorning everything into immutability is counterproductive
 
I agree.
I'm quite happy with mutability in a lot of cases.
 
@Puppy The fact that Scala and Clojure have immutable collections in the standard library and C++ doesn't even have it in Boost (check?) is sufficient for me to argue that C++ sucks at immutable collections.
 
@Jefffrey I.e. which cell would get the weak_ptr? It's not something you can determine statically and can only be known at runtime.
 
@GregorMcGregor Right, Haskell doesn’t really give you the tools for that. Even if it did you’d be writing lame-duck C-style ML inside IO. The usual approach is in fact to call through C btw.
 
10:48 AM
Okay :(
 
@sehe that FTL thing you tweeted is interesting
 
@Puppy Does your compiler solve halting problem yet?
 
@Griwes "in most cases"
 
@Griwes That's what "most cases" is for. I readily accept that there's always gonna be some cases where you can't prove a cycle or absence of a cycle.
 
@thecoshman Yeah pass some type tag instead of a T. I tend to use identity<T> for those cases. (And obviously you have a client of name, why else would you be writing one.)
 
10:50 AM
@Jefffrey Also, some cells will point to themselves; a weak_ptr wouldn't keep them alive.
 
but I think that there's gonna be a lot of simpler cases where you can issue a warning about the possibility of a cycle or prove a cycle impossible.
 
Well, I pass the tag behind the covers. Write the nice interface (i.e. name) however you want.
 
what is a cycle
 
@VermillionAzure when objects refer to eachother in a cycle
 
@VermillionAzure half a bicycle
 
10:51 AM
e.g. A -> B and B -> A
 
besides
 
@orlp oh
 
or A -> B -> C -> A
 
@R.MartinhoFernandes I haven't quite read your example that well, but I wasn't trying to say that reference counting is good always anyway. I was merely saying that for most acyclic structures you can use shared_ptr.
 
if I was truly desperate to break cycles, I'd do a mini-GC
 
10:51 AM
@orlp wait but what type of cycle
 
you could also argue that it's the users responsibility to avoid cycles
 
How are cycles formed?
 
like A calls B calls A calls B calls...?
 
@VermillionAzure reference cycle
 
@VermillionAzure we're talking about refcounted references
with weak pointers and manually breaking links
 
10:52 AM
lel, some guy is trying to do perspective correct texture mapping manually xd
 
A references B, that references C, that references A again, so it's always alive
 
@Griwes Oh I see
 
@Jefffrey I know. But weak_ptr is often called as a solution to break cycles when in fact it isn't really that helpful for that. It's primary utility is observers.
 
I agree.
 
Can't you just create a combo breaker?
 
10:53 AM
weak_ptr as a cycle breaker is not really effective.
 
@Puppy That's what I did! The GC consists of "leak everything".
 
but weak_ptr is better ownership if applicable, and can prevent unexpected cycles from forming
 
ingenious
 
@R.MartinhoFernandes You can use that for cyclic structures that are cyclic because you want children to have a link to the parent.
Like in a doubly-linked tree.
 
wait that’s not misspelled, unlike 'genious'
 
10:54 AM
> The Conch Cement Company had concealed the fact that it was building and testing an incinerator facility in its factory area.
lol typical China
 
@Jefffrey But there's no sharing there...
 
@R.MartinhoFernandes I'd just chuck them into a memory arena, then when the arena is full, do ye olde mark, sweep, compaction
 
@R.MartinhoFernandes You could share trees and subtrees yes
 
@Puppy Yeah, probably a good idea, but I really don't wanna discard old cells. Garbage will get resurrected often in my scenario.
 
@Jefffrey Maintaining links between parents and children is not easy in today's fast-moving world of ours!
 
10:56 AM
ikr
Especially when they change their surname
Or females get the right to apply their surname to children
 
...
still reference to the same thing person
 
hey kitty
 
What's a usual situation for a cycle?
 
> As for performance both have performance penalties. Automatic reference counting delivers a more consistent performance, no pauses, but slows down your application as a whole as every assignment of an object to a variable, every deallocation of an object, etc, will need an associated incrementation/decrementation of the reference counter, and taking care of reassigning the weak references and calling each destructor of each object being deallocated.
> GC does not have the performance penalty of ARC when dealing with object references however it incurs pauses while it is collecting garbage (rendering unusable for real-time processing systems) and requires a large memory space in order for it to function effectively such that it is not forced to run, thus pausing execution, too often.
I don't get it
 
10:57 AM
Don't get what?
 
Reference counting seems optimal to me
 
they're simply different algorithms with different complexities and use cases.
 
Yes, it has overhead in incrementing and decrementing and checking and whatever.
 
it's not that one is better than another
 
It applies to fewer scenarios to start with.
 
10:58 AM
But GC can take up a whole thread AFAIK.
 
they simply apply in different situations.
 
you can also do parallel incremental gc
 
@Jefffrey That's exactly what's written there.
 
it's just exceedingly difficult
 
for example GCing is O(live), so if you have a lot of dead objects, you can get a lot cheaper cycles.
you can also compact them for superior run-time performance when accessing them, for example.
and GCs can break cycles without worry.
 
10:59 AM
@Puppy How?
 
And trivially cheap allocation.
 
magic.
 
@VermillionAzure because it only tracks the alive objects
 
@R.MartinhoFernandes You can get pretty fuckin' cheap allocation for refcounting too if you need it.
 

« first day (1826 days earlier)      last day (3123 days later) »