« first day (942 days earlier)      last day (3999 days later) » 

1:00 PM
I have a basic callback example with std::function somewhere
 
class Button { std::function<void(void)> cb; template<class Functor> Button(Functor&& f) : cb(std::forward<Functor>(f)) { } };
Button b([]{ cout << "my callback"; });
 
@ThePet So, that's not a void-returning function. It's a callback-returning function.
 
Found it
 
@R.Martinho And what's such overloading good for?
 
1:01 PM
syntactic sugar mostly I think?
 
@Rapptz needs more std::move, no?
 
user142019
Writing good, readable, concise code.
 
@Solkar Dealing with augmented types smoothly.
 
@BartekBanachewicz basic.
It was meant for beginners in /r/learnprogramming
 
still, you get function in argument
 
1:02 PM
Smoothly? I would not want having to read such code.
 
async {
    try
        let uri = new System.Uri(url)
        let webClient = new WebClient()
        let! html = webClient.AsyncDownloadString(uri)
        printfn "Read %d characters for %s" html.Length name
    with
        | ex -> printfn "%s" (ex.Message);
}
@Solkar You clearly don't know what you are talking about.
 
Xeo
s/taking/talking/
 
user142019
I like F#.
 
That's pretty much the async/await feature of C#5, but implemented in the library.
 
Is that so..
 
1:03 PM
The let! line runs the call asynchronously, and when it ends, proceeds naturally.
 
So why don't enlighten me?
 
Do that without this feature and tell me the code is more readable (hint: it involves callbacks; warning: don't forget the exception!)
 
user142019
let! is like <- in Haskell do-notation, isn't it?
 
user142019
And let is like let. But strict.
 
@rightfold Yes.
 
1:05 PM
@Solkar Why act like you're owed an explanation?
 
user142019
Speaking of F#… I should install Mono.
 
Xeo
@R.MartinhoFernandes How's that executed?
 
If it's not allowed to question a concept, we can stop that discussion.
 
@Solkar It's not the question that I'm commenting on, its the attitude; i.e. the way you asked -- not that you asked at all.
 
user1182183
@BartekBanachewicz so if I understand it correctly, I can put per-button code between the { }
 
1:07 PM
@Xeo With the download asynchronous?
 
I'm surprised you call this a 'discussion', as well.
 
Hm.
It's truly insane.
You guys are genuinely making me write better code.
How dare all of you. =[
 
Luc, pls. go play with your kind. Leave me alone.
 
Wow, that's terrible.
 
@Xeo Kinda like, in some hypothetical C++, std::async(download).then([](html) { print(... html) }). Plus crap for the exception.
 
1:09 PM
@Solkar This is not going to end well
 
@Solkar Is it clear now?
 
user142019
@Xeo I think, roughly, asyncDownloadString webClient uri >>= html -> liftIO $ printf "Read %d characters for %s" (length html) name where asyncDownloadString :: WebClient -> URI -> Task a. Compare Task with Future. Correct me if I'm wrong.
 
@ThePhD What did you expect?
 
@Solkar careful
 
No. You gave an example for new syntax. No doubt that it's new, but what's good about it?
 
1:11 PM
@ThePet yes
@Solkar that was an exercise for you
8 mins ago, by R. Martinho Fernandes
Do that without this feature and tell me the code is more readable (hint: it involves callbacks; warning: don't forget the exception!)
 
@Solkar I posted an explanation immediately afterwards, including what something that is not yet the same would look like in C++.
 
user1182183
@BartekBanachewicz Thank you very much :) als, what's a good book on smart_pointer or something?
 
@ThePet C++ Primer (without "Plus")
 
Xeo
@R.MartinhoFernandes I mean, how do you use that async thingy?
 
user1182183
@BartekBanachewicz thanks
 
@Solkar That is just plain rude
 
user1182183
1,000 pages O_O
 
@ThePet I also bought Josuttis one about stdlib, but that's a) more advanced b) haven't really finished it yet (but the parts I read are amazing)
@ThePet that's a shortened introduction to beginning C++
 
user1182183
@BartekBanachewicz Kill me XD
 
Xeo
@R.MartinhoFernandes Ah, so async { ... } is a block you put somewhere, with code in it
 
1:14 PM
That's really cool
 
@ThePet who told you C++ is easy?
 
@Solkar What's good about it is that you can keep using the whole language, instead of being forced to a subset that includes little else than function calls.
 
user1182183
@BartekBanachewicz the good part is that no-one told me that heh
 
FYI Help us figure out a way to handle the explosion of comments on Stack Overflow meta.stackoverflow.com/questions/180325/…
 
user142019
@Xeo For example, you could also do this:
 
1:15 PM
@ShafikYaghmour oh come on Stocker again
 
user142019
let maybe = new MaybeBuilder()
let sugared =
    maybe {
        let x = 12
        let! y = Some 11
        let! z = Some 30
        return x + y + z
    }
 
@Xeo Yes. And async is actually an object, not a type. This means you can have functions that return this sort of "environments".
 
does he have some mission from god or something?
 
Xeo
@R.MartinhoFernandes interesting
 
@BartekBanachewicz I don't quite get his issue with comments but this post is a little nicer
 
user142019
1:16 PM
I am hungry.
 
@ShafikYaghmour Ugh please no
Get this shit out of my morning
 
@ShafikYaghmour he learned his lesson, a bit.
 
context(ctx) {
    ...
}
// look ma, no globals, no manually threading state around.
 
What is with this guy's obsession with comments?
2
 
user142019
fool1708801
 
1:18 PM
-3
A: Help us figure out a way to handle the explosion of comments on Stack Overflow

EnergyNumbersThe only constructive use for comments is to ask for clarification of a question or answer. Such clarifications should then be edited into the question or answer. So, any given comment should quickly become obsolete. So, I propose a sweeper bot that deletes all comments more than a month old. ...

Look at this, seriously
 
user142019
Wait I already said that.
 
@Rapptz immediately lounged
 
user1182183
i.stack.imgur.com/9I3MG.png Holy serous C++ shit, I LOVE IT!
 
> includes.h
 
1:21 PM
Sigh.
 
user1182183
@Rapptz it seriously speeds up compilation...
 
Second points of interest.
 
float FPSLIMIT isn't a const
 
1:22 PM
I know comments weren't invented yet, but can you make this one please? — Ruben Bartelink 5 hours ago
 
Also you have global variables
 
What? Comments were invented at some point?
 
user142019
Ugh fcuk.
 
@ThePet stop using pointers
 
What part of hard coded do you not understand?
 
user1182183
1:23 PM
@BartekBanachewicz until C++ primer ships I have no other (convienient) choice? XD
 
@ThePet no, just strip * from everything
and you're good to go
VALUE SEMANTICS, biatch.
 
user1182183
then copies will be created? ; o
 
@BartekBanachewicz Hmm, thanks? That's kind of old, though. And ugh, he really overdid the bad kerning thing.
 
user1182183
all over the memory, or not.
 
@Rapptz I don't see any of that there.
 
user1182183
1:24 PM
and last time creating .swap functions I already had enough problems
 
BTW, I explained a friend that C# variables (and Java ones) are pointers
he was like "but they're nicer"
 
@R.Martinho This ' This means you can have functions that return this sort of "environments'"' is an interesting concept.
 
@R.MartinhoFernandes I'm assuming the hexadecimals aren't numbers
 
I asked "where?"
 
@Rapptz They are colors :|
 
1:25 PM
@ThePet why would you create swap
 
(I thought addresses at first too, tbh)
 
there's already std::swap and unique_ptr::swap
 
Oh I was talking about the second function
but now I see it has Draw in the name
so now I'm confused too
 
gHwnd
kill it with fire.
 
@Rapptz Hmm, I doubt zigamorphs are addresses.
No idea what they mean there, but definitely not valid addresses.
 
user1182183
1:26 PM
It's not like anyone is going to maintain my code xD so gHwnd is nothing bad for a one person project... right?
 
Yeah I see that now
 
@ThePet no, it is bad and you should feel bad
 
"It's not like anyone is going to maintain my code" lol
 
Also you are going to maintain your code
 
user142019
How can I add __cdecl to function pointer types in GCC?
 
user142019
1:27 PM
/include/oslash/class.hpp:9:22: error: expected type-specifier before '__cdecl'
         using impl = __cdecl object*(*)(object*, sel, ...);
                      ^
 
the fact whether it's a one person or 100-ppl project is irrelevant
 
@ThePet Btw, WE ARE. YOU KEEP COMING BACK FOR HELP WITH IT.
 
just write good code FFS
 
For what it's worth, I agree with you. But until someone spends a week as a moderator, it's hard to show them the sheer number of problems there are with the "screw it, keep comments around." approach. I kind of wish everyone could be a moderator for a day, just so they'd get an inkling of what we're dealing with. — George Stocker 5 mins ago
:|
Anyway 9:30ish.
Adios.
 
well noone is forcing him to be a mod
 
user1182183
1:28 PM
@R.MartinhoFernandes ah sorry, I though Maintaining and helping were two different things..
 
so erm... github... by default who can push to your repo? how do you control that?
 
@ThePet It's the same fucking process, dude.
 
user142019
Oh [[__cdecl]].
 
@ThePet if you keep coming here with this code, they are the same.
 
@thecoshman pull requests
 
user1182183
1:28 PM
hm you got a point
 
@thecoshman the owner and collaborators
 
Xeo
@rightfold void (__cdecl*)(...) I think
 
@Rapptz yeah I know people can fork and then make a pull request, but that is not pushing
@BartekBanachewicz oh cool, so they are read-only by default? (plus pull requests)
 
if it's an org repo, there is no owner
 
Xeo
Maybe it was t the right of *
 
1:29 PM
@thecoshman yes.
 
yeah but I mean people contribute via pull requests not pushing because only the owner can push (and collaborators too)
okay I have to go now
 
user142019
> error: ISO C++ forbids declaration of '__cdecl' with no type [-fpermissive]
 
user142019
lolwot
 
user1182183
hm, so when I use a smart pointer, and do map.clear(); , all the stuff will be deleted without me needing to worry?
 
@thecoshman Ugh, publicly writeable repos would be a tad nightmarish.
"Oh no, John Stupid broke the build"
 
user142019
1:30 PM
@ThePet duh
 
@ThePet yes.
 
@R.MartinhoFernandes yeah I know, that's why I wanted to check
 
@ThePet depends
 
user1182183
hm should I go with auto_ptr, shared_ptr, unique_ptr, so many to choose from O_O
 
@Solkar Yeah. I haven't played much with it yet, but I have a few cool ideas to try out (like my context example above).
 
1:32 PM
certainly not auto_ptr
 
got to say though, I think I prefer bitbucket over all, if only it wasn't for it's stupid wiki and issue trackers permissions
 
either shared_ptr or unique_ptr but the choice seems obvious, no?
 
and not shared_ptr
 
@Abyx what?
 
that
 
1:33 PM
shared_ptr is for shared ownership duh
 
@thecoshman To be honest, the only thing I prefer about BB is the free private repos.
 
so if he wants shared ownership he needs shared_ptr
simple as that
 
@BartekBanachewicz and when do you need it?
 
user1182183
well the buttons will be in a map but can also be in a menu class so, shared it will be
 
@Abyx when there's an object that has to be kept alive for every other object accessing it? o.O
 
1:34 PM
shared thread-safe ownership %)
 
I used shared_ptr once, I think. I was reinventing std::future/std::promise.
 
nobody said anything about thread-safe
 
@R.MartinhoFernandes yeah that's a real plus :D but I liked the sit overall, but not much in it.
 
It's also irrelevant
 
@thecoshman Meh, you'll get used to it (I did too).
 
1:35 PM
We're discussing ownership, not access
 
@BartekBanachewicz then your architecture probably is bad.
 
@R.MartinhoFernandes I'm sure I will
 
@Abyx okay, explain why is it bad then.
 
@BartekBanachewicz It isn't. It is quite relevant. It's very hard to find a case where you cannot define ownership correctly with a single thread.
 
@R.Martinho: I had a sort of deja-vu seeing your comment concerning "env". I have the feeling I have been at a situation where I was struggling to achieve sth like that. I'll meditate that a little.
have a nice day, ladies and gents!
 
1:36 PM
Have fun.
 
@R.MartinhoFernandes Uh, first example that comes to mind : shader
@R.MartinhoFernandes One shader can be used by many Programs
 
@BartekBanachewicz Sorry, not following.
 
and as long as there is a Program using that Shader, it must be alive
 
Erm, FWIW, not in OpenGL.
 
so a perfect case for shared_ptr and I use it that way
 
1:37 PM
@BartekBanachewicz ...and why they should own it?
 
OpenGL program objects own the shaders.
 
@Abyx because they explicitly need it to be alive
 
The OpenGL system itself already has the ownership builtin.
 
@R.MartinhoFernandes Okey, Pipeline not Program then
 
use != own, you know
 
1:38 PM
@Abyx require alive = own
 
oooh, online editor with github... even more plus points
 
dunno about shaders though
 
@R.MartinhoFernandes anyway, that's for shader objects with only OGL data. What about your own metadata?
point is, using shared_ptr's I don't need stuff like ShaderCache or whatever
I can just construct a program, but am still able to share the shaders to other programs
I am quite sure it's not an isolated example.
Though of course unique_ptr is amazing and probably more useful in general
 
@BartekBanachewicz Dunno about those, but does that mean they designed those broken, even though they had a correct design they could copy from? Ugh.
Did you hear about this new self-hosted LOGO implementation? It's turtles all the way down.
 
@R.MartinhoFernandes If you want metadata, the fact if OpenGL Programs or Pipelines have owning semantics is irrelevant
metadata being uniform cache, for example
 
1:47 PM
@BartekBanachewicz Erm a cache sounds like something completely different.
 
@R.MartinhoFernandes it's a part of shader nevertheless
 
No, I mean different from shared_ptr.
 
ugh we are drifting away from the topic
 
So, if you want a cache, you need a cache, shared_ptr or not.
 
Point is, it's either shared_ptr or some sort of managing class
so it's like p2p compared to client-server
both make sense on different occasions, as we can see in real life, I guess.
 
1:51 PM
I still don't find it convincing. When do the programs die?
 
I am afraid I can't clearly distinguish features of both approaches WRT shared/unique ownership and translate them to flaws or benefits basing on any concrete example or even abstract concept
@R.MartinhoFernandes When geometry that's being rendered by them is no longer needed
i.e. the player moves to the next level.
 
That's it?
 
what's it?
 
yes, but if you are caching objects, and wish to hand out pointers, shared make sense, unless you want to 'rent' the objects exclusivley
 
They only die en masse at a well-known point?
 
Xeo
1:52 PM
Why do you need shared_ptr for that?
 
@R.MartinhoFernandes well, not quite. In real world you might want to load/unload models and programs on demand
 
well, I guess const& could work too
but it depends what you want to allow to be done with said objects
 
@BartekBanachewicz Yes, and when, besides switching levels?
 
@R.MartinhoFernandes the choice of opponents on a given level might be random. Or the item drop.
 
user142019
WTF
 
1:54 PM
If you want deterministic destruction at level change, then don't use shared_ptr
 
Ok. I would expect those things to be preloaded.
 
@R.MartinhoFernandes as they move around the level
 
On desktop, sure.
On mobile you have very little memory.
And usually reasonably fast "HDD"
 
Xeo
We had very little memory on the Wii and we still preferred preloading the level
 
And that's why you're using shared_ptr that doesn't guarantee when objects die? Makes sense
 
1:55 PM
@Xeo you did wii dev?
 
Xeo
ya, at the Games Academy
 
Anyway, I see no reason why my API should disallow explicit on-demand loading
Maybe it's just the fact I found it easier to test in Minicraft that way
Also, I think using shared_ptr as a natural refcounted resource is ok
 
@BartekBanachewicz FWIW, I believe you should look for reasons to allow it, not to disallow it (maybe you have them; I still think it's a point worth making)
 
if it has one reference (the one some sort of resource cache keeps), we can delete it.
 
21 hours ago, by Jerry Coffin
@R.MartinhoFernandes Years ago, I read a quote from one of the designers of OS/2 where he said something like: "A good design isn't one that gets a lot right. It's one that avoids getting anything terribly wrong." A lot of designers seem to have missed that. They think that getting a lot of things right makes up for getting other things horribly wrong -- but it rarely does, unless the horribly wrong things are so obscure they have essentially no effect on real use.
 
1:57 PM
@R.MartinhoFernandes Well some games don't have the concept of levels at all. If you want to make smooth world transitions, you might want to keep only the bare minimum.
 
Ell
ooh we're talking about opengl ownership semantics
 
In 2 months: "why aren't my objects destroyed when I want them to"
 
@R.MartinhoFernandes that's a very good point, though.
I need to keep that in mind definitely.
 
Ell
OpenGl programs don't own shaders
 
(I also like it because of the minimalistic concepts, but that's a side note)
 
Ell
1:59 PM
Shaders can be deleted after the program is compiled - so they own a copy of the compile bit I guess?
 
@Ell Hmm, yes, they do. It's right there in the docs (see AttachShader, IIRC).
@Ell We are not talking about OpenGL objects anymore though. It's just a backdrop.
 
> . If a shader object is deleted while it is attached to a program object, it will be flagged for deletion, and deletion will not occur until glDetachShader is called to detach it from all program objects to which it is attached.
@Ell ^
 

« first day (942 days earlier)      last day (3999 days later) »