« first day (658 days earlier)      last day (4305 days later) » 

4:02 PM
its awful quiet in here this afternoon :P
 
Slow day.
 
yup...
 
Hah... @xeo
I think I know why they worded it like this
 
Xeo
4:17 PM
?
 
In computer science, a thunk (also suspension, suspended computation or delayed computation) is a parameterless closure created to prevent the evaluation of an expression until forced at a later time. In lazy languages thunks are created and forced implicitly. In eager languages thunks can be created explicitly by wrapping an expression in a parameterless anonymous function and forced by calling it in order to emulate lazy evaluation. Some functional languages require functions to take at least one parameter, requiring the anonymous function to take a dummy parameter, usually of unit type...
anybody get this ?
 
There's one part I'm not 100% sure on. What does it say about uniqueness? Where does it say that two strings identical contents can't use the same addresses?
 
Xeo
@jalf Oh, thinking about cow?
 
if it says that the string buffer itself -- the range [begin(), end()), specifically must be unique, then I've got it
@Xeo not exactly
 
Xeo
@TonyTheLion I got an example, gimme a sec
 
4:19 PM
cool
 
with this wording, it is possible to implement a zero-length string without dynamic allocations, and without using an in-place buffer in the std::string object itself. All empty strings can reuse the same shared null byte, because str[str.size()] is not required to return the specific end-of-buffer null, which would have to be unique for all strings
and c_str() works because it's defined in terms of operator[], rather than in terms of iterators or the internal buffer, so it can return a pointer to that shared null byte
 
@TonyTheLion What about it?
 
"Shotguns and demons". My god? Is Doom 4 finally going to be an old school arcade shooter?
 
Xeo
@jalf Ah, I wondered about why data() was required to return a non-null pointer to which 0 can be added
And data() in general gets special treatment in the constructors
 
@TonyTheLion There's a nice explanation of how Haskell heap and thunking works here: blog.ezyang.com/category/haskell/haskell-heap
 
Xeo
4:23 PM
struct X{
  void foo(int){}
};

void X_foo_thunk(int i, void* p){ X* self = (X*)p; self->foo(i); }

typedef void (*callback_type)(int, void*);
void c_func_with_callback(callback_type cb, void* user_data){
  cb(42, user_data);
}

int main(){
  X x;
  c_func_with_callback(X_foo_thunk, &x);
}
@Tony ^
 
@CatPlusPlus Let me guess... with magic?
 
Xeo
Atleast as far as I understand it
 
@Xeo That's not thunk.
 
I'm kind of impressed if this is the rationale they used. They really sat down and thought about this carefully then
 
That's just callback.
 
Xeo
4:25 PM
@CatPlusPlus nevermind, I had trampolines in mind.
 
although simply putting the 0 byte inside the string object itself could've been done with "normal" wording, and that seems like it'd have been just as efficient
 
Xeo
Why can't I delete the message?
 
could even have reused the pointer to the buffer
@Xeo it's more than two minutes old?
 
@EtiennedeMartel Nah.
 
Xeo
Yeah, but wasn't it only the editing that worked within 2mins?
 
4:26 PM
@Xeo nah, deleting too, afaik
 
@CatPlusPlus But, everything works with magic in Haskell?
 
@EtiennedeMartel Nah.
@Xeo Editing and deleting.
 
Xeo
:s
 
I should cleanup my DNS config.
 
That John Carmack keynote is quite long.
 
4:28 PM
And possibly move to BIND again.
 
Xeo
@jalf interesting conclusion, though it still allows the evil stuff, right?
 
@Xeo oh, sure :)
I'm still not sure why allowing this would be an advantage though. Wouldn't it always be simpler and at least as efficient to just use an in-object "null buffer"?
just reuse the pointer to the buffer. If that's null, then you have your null byte right there
and that could be done without this over-complicated wording
I feel like I'm onto something, but there's still a piece missing
 
@CatPlusPlus thanks :)
 
I'm playing with memoization and I wonder if there's any way to find arguments types of non-template functions...
With template's it's not that hard... But I would guess for a normal function double func(const std::string &a, double b), there's no mechanism to extract the types so that I can construct something like a tuple<std::string,double> . Any ideas?
 
unless they're just playing it careful, thinking that that making this scheme possible might some day somewhere somehow pay off
 
Xeo
4:30 PM
@jalf What, reinterpret_casting the pointer to char&?
 
@Xeo yeah
 
Xeo
hmm
@JohanLundberg That's rather easy
 
@Xeo Enlighten me ^^
 
Xeo
template<class F> struct extract_args;
template<class R, class... Args>
struct extract_args<R(*)(Args...)>{ typedef std::tuple<Args...> args; };
extract_args<decltype(&func)>::args
or
template<class F>
void foo(F f){ typename extract_args<F>::args tup; }
if it's a function pointer type, which you can check
 
@Xeo Interesting, That's the natural syntax but I just thought it could not work.. I'll try it out.
 
Xeo
4:36 PM
You can also generalize that even more
Oh, I think I have something to do for the next few minutes now :3
 
man, monads are so fucking abstract
mind boggling
 
It's not that abstract.
 
I've tried to understand monads before, and I think I sort of do...
 
they're an encapsulated computation
 
but I'm still not sure I see how they can make a pure language behave as non-pure
 
4:44 PM
I've got that far :P
they use type constructors
 
I/O etc
 
I/O is implemented with compiler support.
 
and, from a type ctor create another one, which is then used for computation and returns a result
but basically, it's meaningless to me
 
IO monad is there to tag side-effects and make sure they don't escape.
 
@TomW they don't, exactly. It still behaves as a pure language
 
4:46 PM
@jalf there might be a flaw with my definitions here
pure = no side-effects
 
>>= has a nice property for sequencing: it has to have a value to unpack and pass along.
 
isn't that correct?
 
So a chain of >>= can only be evaluated in one way.
 
Oh, yes now I bumped into the problem, 'cannot resolve address of overloaded function'.

double def(int a,double b,std::string c){ return b; }
double def(int a,int b,std::string c){ return b; }
//typedef extract_args<decltype(&def)>::args tupleT;
typedef extract_args<decltype(&def(1,2.3,"apa"))>::args tupleT;

How would I specify the overload?
 
Xeo
hmm
 
4:47 PM
ah - maybe I see where this is going - monads can't modify state, but they can create new instances of types in a way that makes it look like they do?
 
@TomW Side-effects are happening behind the scenes of bind.
 
As I understand it, In the case of IO, it's more a case of monads giving you a convenient way to say that "given a world in this state, I can perform an operation, and get the result of the operation, plus a world in a new, different, state". This new, different state is then used for the next IO operation you want to perform. It's still pure, in that the "world" is never modified in-place. The old one is just discarded, and a new one created to replace it
 
memoization.cpp:15:47: error: lvalue required as unary ‘&’ operand
memoization.cpp:15:49: error: template argument 1 is invalid
memoization.cpp:15:57: error: expected initializer before ‘tupleT’
 
bind is basically binding of an argument, right?
 
4:48 PM
>>= is bind.
 
yes I know that bit
but what does it mean, do?
 
It unwraps a value and passes it to a function, which can then bind it to a name.
Hence monadic binding.
 
@TonyTheLion It's the arrow sticking out of your knee.
 
do x <- doSomething
   doSomethingElse x
-- desugars to:
doSomething >>= (\x -> doSomethingElse x)
Finally done with the damn full system backup.
I really have to setup some automation for that.
 
paranoid much?
 
4:52 PM
I'm reinstalling fresh OS on the server.
 
@Xeo, I think what I bumped into is perfect forwarding with overloaded functions. codesynthesis.com/~boris/blog/2012/05/30/…
 
Xeo
@CatPlusPlus how is the desugarized version different from (C++ syntax) doSomethingElse(doSomething())?
@JohanLundberg Overloads are kinda tricky :s
 
who upvotes: stackoverflow.com/questions/11810258/… ? the error is clearly in the ... or another file altogether
 
oops
 
@Xeo doSomething returns a wrapped value, doSomethingElse takes an unwrapped value.
 
Xeo
4:54 PM
mmm
 
You could implement bind in C++, but it will probably be fugly.
 
@KeithLayne yes, monads are the arrow to my knee :)
 
Xeo
Wasn't the power behind bind that you create a version for every wrapper?
 
Also >>= is polymorphic in arguments and return value.
Okay, that's doable, I was thinking about something else.
@Xeo Yes, Monad is a typeclass.
 
At least you guys aren't stuck writing factories in the language that shall not be named because "generics" don't work :(
 
Xeo
4:58 PM
template<class T, class F>
auto bind(wrapper<T> w, F f)
  -> wrapper<decltype(f(w.magic_get_value()))>
{ ... }
?
 
that's pretty cool.
 
wrapper<U> actually.
 
what a dick :)
 
Well, that might work.
I'm sleepy.
 
Xeo
Ah, just found my code I made for that "functional java in C++" guy
 
5:00 PM
folks
wait.... I did say it!! WOOT!
 
Somebody once mentioned here a free ebook on OpenGL.
I can’t find it back.
 
You’re awesome.
 
I know
Eh, I can't imagine State monad in C++, and it's pretty trivial.
 
Xeo
State monad does?
 
5:04 PM
Threads state along.
So lifted functions can access and update it.
 
Xeo
uhm
 
What are some good IDE's for Linux? Eclipse, QT Creator etc for developing C and C++? What do you all recommend?
Code::Blocks any good?
 
emacs and Eclipse
 
Why emacs? I used to use it a long time ago...
 
Because it's in my fingers, and I can configure it any way I like to. And no need for mouse.
 
5:11 PM
Emacs and not Eclipse FTFY
 
vim.
Welp, I hope I didn't forget to backup anything important.
Wipe time.
 
Your mom.
No wait, that's too big to backup.
 
what if I told you...
I'm hungry
 
Compiler y u no accept my code.
 
5:18 PM
 
@JohanLundberg That is nice about emacs for sure.
 
Graah, stupid web installer. I don't want swap partition, fuck off.
 
How do I initialize a non-static base class data member from an initialization list of a subclass’ ctor?
 
@TonyTheLion Same problem here.
I think I'm gonna get myself some Subway because I'm lazy and disgusting.
 
@RadekSlupik you can't, you provide a constructor of the base class that can do that and call it instead
 
5:23 PM
Why can I not?
 
Because.
 
:)) Don't know how to answer that
 
The problem is.
Entity is an abstract base class.
Oh wait. Nevermind.
 
Aight. Thanks, double-chin guy.
 
5:35 PM
I though he had fat lips.
 
5:50 PM
Everything is about bacon.
 
Especially bacon and metabacon.
 
bacon Foo(object):
    __metabacon__ = Bar
 
Phew, finally got through initial system upgrades.
 
6:14 PM
Still no Internet. Got an electrician to find my phone connection, but he didn't find anything either. Gave up and subscribed for an internet connection in my mom's apartment a few meters away. This way I'd still be able to connect to her modem wirelessly. Now it turns out the phone cables there are broken and need to be replaced. This sucks.
 
@StackedCrooked You're in Belgium right?
Use a smartphone and Mobile Vikings.
 
I've been buying 500 MB packs for my mobile phone and use it as a modem.
But 15 EUR per 500 MB is expensive.
@rubenvb Tarieven? :D
 
Mobile Vikings is €15 for 2GB.
 
Ok, that's not too bad.
 
don't tell me you don't know MV?
It's the reason I got a smartphone.
 
6:16 PM
However, I'm an anime fan. I need 300 GB monthly at least.
I'll check out MV though.
 
it's 3G, use broadband to download stuff. Use MV now to have basic internet access.
and enter my phone number when you subscribe, gets me a free month ;-)
 
3G is pretty fast these days. I'm getting faster downloads on 3G than with my old DSL line.
 
but MV is on the Base network, so coverage is very dependent on where you need it. I have HDSPALKDJFLKDJ+ everywhere I am longer than 5 minutes.
 
Maybe I can request a sim and use 3G stick to connect. I don't need to change my phone's sim.
 
yes, indeed. They have data only sim's too. That's €12 for 2GB/month. But you need to invest €15 for the card itself.
 
6:19 PM
That's not an issue.
 
@StackedCrooked if you do subscribe, please use this link: mobilevikings.com/referral/xZIiRIvJWQkVFclbxuiLSxTLSwzLuKXc
it's my referral :)
 
thanks!
 
I do plan to get a DSL connection though. Mobile solution is a temporary fix.
 
For DSL, I recommend EDPNET.
€35/month, unlimited, up to 50Mbps.
 
6:22 PM
Cellular usage on my mobile phone is 12,4 GB already :D
 
(I sound like a walking advertisement board)
 
50 Mbps is not too bad.
 
@StackedCrooked how on earth is that possible?
@StackedCrooked it's the fastest DSL available in Belgium
 
@rubenvb I've been buying 500 MB packs for 15 EUR :(
 
@StackedCrooked that's too stupid for words.
 
6:25 PM
I need internet man.
 
DSL, MV, hacking the neighbour's wifi, seriously man...
you can buy a new PC with what you save.
 
Hacking the neighbour's wifi..
Never thought of that.
 
Every time you hack someone's wifi network, a kitty dies.
 
Yeah, I can't do that.
 
It's not hacking if they use WEP.
 
6:31 PM
Or MAC address filtering :D
 
Woah, my server now boots in few seconds.
 
Xeo
@CatPlusPlus Nobody in my vicinity has that, thanks to default WPA2-PSK on modern routers. :'(
 
WPA2 is crackable too.
I thought.
ah no. Brainfart.
 
You need a freaking huge wordlist though.
 
packet sniffing
 
Xeo
6:38 PM
> This is an automated notification sent from our account security system. You login your account successfully at 4:27 on August 3th form the 125.87.108.* range, but our system shows the 125.10.151.* IP range exists a large number of hackers. As too many customer complaints, the 125.98.104.* IP range has been blacklisted.
gotta love scam mails
 
@rubenvb Lol dictionary attacks.
 
@CatPlusPlus oh yeah, John the Ripper's password mangling tool: smallnetbuilder.com/wireless/wireless-howto/…
can you use non-ASCII stuff in WPA passphrases?
 
@Xeo Did you try "abcdefg", "password", "admin" or "123456"? Because some people actually use these >.<
 
Routers these days come with random keys preset.
Dictionary attacks are pretty much a waste of time.
 
Xeo
Or semi-random, including the device's mac address in the password
 
7:35 PM
hmm
 
hmm?
 
so what is everyone up to? :)
 
Writing pr0n sites, bug trackers and chat protocol specifications.
 
being fucking awesomesauce as usual
 
Why would you fuck awesomesauce?
Today is the most quiet day in the history of this room.
 
7:45 PM
IKR
 
me too
Today I gave a negative amount of fucks.
 
is there any situation where RAII is unusable? (talking with a die-hard C dev here, he kind of hates C++, says it's too complicated)
 
Yeah.
When you don’t want to manage anything.
Or when destruction is too slow (and benchmarks show you that) so you want to do it later.
 
@RadekSlupik if you don't want to manage anything, there's no problem IMHO.
 
There isn’t.
 
7:53 PM
@RadekSlupik can't you cleverly extend object lifetimes by moving them to a "delete later" pool?
 
That’s also possible.
 
guys!
please be unquiet!
 
There is no reason not to use RAII in C++.
 
@rubenvb RAII is a general principle, that the lifetime of a resource should be implicitly controlled by if/when the resource is being used. I don't see how that principle can never be "unusable"
 
I think I have him convinced.
 
7:55 PM
you use the resource, it should be kept alive. You're done using it, it should go away
Of course, "go away" doesn't necessarily mean "call delete". It might mean "return it to a memory pool", or "unlock the mutex", or a dozen other things.
 
@rubenvb He probably does RAII in C, too. Only in C the dtor is not explicitly called.
 
yeah, I bet.
He's just always saying C++ is too complicated.
 
int *foo = malloc(42 * sizeof(int));
// use foo...
free(foo);
Something very similar to RAII in C, only explicit. ^
 
IMO, it's not really RAII then. The point in RAII imo is that it's implicit. If you make it explicit, it's just, well, ordinary code
but that's just how I understand the term :)
 
@RadekSlupik RAII but not SBRM
 
7:58 PM
Hi all
 
Hi.
Only RAII makes your life easier.
 
Hi @RadekSlupik
 
That’s why RAII is better than manually releasing resources.
 
in C, you can have a simple form of SBRM as follows:
 
troll
 
7:59 PM
#define SBRM(I, E) for(bool b = (I, true); b; b = (E, false))
 
Trollin' trollin'
 
unfortunately, it modifies the meaning of break and continue
 
Can you give an example of its usage? Those identifiers are overly descriptive.
 
I guess it's the more advanced features of C++ that make RAII so necessary and invalidate the plain new/delete combo.
 
@rubenvb You mean exceptions? Yeah, that's advanced alright.
 
8:00 PM
FILE *f; SBRM(f = fopen(....), fclose(f)) { ... }
 
@EtiennedeMartel or temporaries binding to const references etc...
 
wait, I think that it can "break" is a feature
consider placing "if(!f) break;" into the body
 
@rubenvb Oh, right, forgot about that.
 
@JohannesSchaub-litb Ah. That’s nice. Only return doesn’t work, and that’s one of the reasons you would use RAII.
 
@RadekSlupik return works fine
ah wait i see what you mean now
 
8:01 PM
It won’t call fclose.
 
I would always use a plain old goto in C for that sort of stuff.
Clang’s blocks extension makes it easier.
 
GCC has the "destructor" extension
 
You can write a function with which takes three blocks and executes them in order.
 
makes implementing RAII in C possible
 
8:02 PM
Blocks are like lambdas.
 
This question is not tagged C++ neither it is C++ specific but i needed a general opinion. stackoverflow.com/questions/11811060/… Is regex the right way to solve such problems?
 
typedef void (^ctx_mngr)(void);

void with(ctx_mngr ctor, ctx_mngr code, ctx_mngr dtor) {
  ctor();
  code();
  dtor();
}

int main() {
  FILE *f;
  with(^{
    f = fopen("foo");
  }, ^{
    // use f...
  }, ^{
    fclose(f);
  });
}
This can be further specialized so you can have void with_file(char const* filename);.
 
What are those ^?
 
@RadekSlupik that's f-ugly.
 
Bitwise xor?
 
8:05 PM
Blocks. Clang language extension.
 
They are lambdas.
@rubenvb It’s C. Of course it’s ugly.
 
@RadekSlupik lol
It's GNU C.
 
Blocks are an apple thing
they are also implemented in GCC (apples's one only, IIRC)
 
They work in Linux, IIRC.
 
8:06 PM
They were in GCC forever.
 
@RadekSlupik "return" won't work there either, will it?
 
@JohannesSchaub-litb It will return from the block, so it will work.
 
but it won't return from main
 
No, that’s the point.
You want the resource to be deallocated first.
You need a boolean flag with a __block storage qualifier, and an if-statement for that. xD
 
8:08 PM
the point of C++ RAII is not that you cannot anymore return from a function
 
I like how everyone agrees on how important RAII, but no two people here agree on what it is
 
You know what? Fuck C.
 
is there a faq on brace initializers?
 
The only program that was written in C whose code I’ve ever liked was Git.
I am going to rewrite Git in C++. Torvalds would love it.
12
> Git implementation in a horrible language.
 
@RadekSlupik there's a C library for git on github: libgit2
 
8:16 PM
@rubenvb I know. I have used it, and it’s too immature.
 
indeed. Last I read, it couldn't perform a checkout.
 
@RadekSlupik Most C code is valid C++. So you just need to recompile with a C++ compiler and the job is done.
 
@StackedCrooked It would still not be idiomatic C++.
I want idiomatic C++11.
And a license that is not idiotic.
 
Idiomatic C++11 is still a work in progress.
 
@RadekSlupik CC0
 
8:23 PM
zLib license.
 
I always use either BSD or zLib license for everything.
 
isn't zlib pretty much PD?
that's used as a fallback for MinGW-w64.
when PD would fail.
 
@RadekSlupik Do it in Haskell.
 
@CatPlusPlus Hmm. Not a bad idea, actually.
 
8:41 PM
`template <class T> friend class Blah;` befriends Blah for all T's
How can I befriend only, e.g. Blah<U>?
 
friend class Blah<U>;
 
@RadekSlupik What if Blah<U> actually uses the object that's befriending it, in a way that I have a cyclic dependency? Can I forward declare one of the templates?
 
I don’t know.
template<class T> class Blah;?
 
@RadekSlupik I tried that.. but it didn't work, let me check the error message again
No, it worked, I was mistaken. Thanks.
Kudos :)
 
auto foo = bar(); If bar returns a reference will it be captured as such, or by value?
 
8:48 PM
No problemo.
@StackedCrooked by value.
Use auto& foo = bar(); if you want the reference.
 
Oh right, it's the same rules as template deduction.
 
path ++ "/.git" feels evil. Is there a cross-platform way to concat path components in Haskell?
 
lol
 
8:53 PM
import System.FilePath
path </> ".git"
 
Aight.
 

« first day (658 days earlier)      last day (4305 days later) »