« first day (1603 days earlier)      last day (3328 days later) » 

10:01 AM
who says C++ doesn't have closures
 
@Rapptz I mean it has lambdas and std::function but it's not a 1-to-1 mapping
 
..?
 
right?
with lambdas you can capture certain variables and std::function allows you to store functions
 
I'm not explicitly following.
 
assuming f is a function that returns a std::function, you can return a lambda right?
 
10:05 AM
C++ already has closures.
 
It does? where?
 
[&a](int x) { return x + a; };.
Right here.
The variable a is captured.
 
Oh I thought closures were also the function creation mechanism
and the fact that you can treat closures as rvalues (I think that's the right termonology?)
 
No..
 
Oh so it's just the "capturing' aspect?
 
10:08 AM
I have suspicion to believe you are very confused.
 
Duh, I'm a noob C++ programmer
I have to learn basically a whole new language since I've been focusing on C++03 all this time
with splotches of C++11
and WTF do they NOT TEACH THIS IS UNIV?
 
In programming languages, closures (also lexical closures or function closures) are a technique for implementing lexically scoped name binding in languages with first-class functions. Operationally, a closure is a data structure storing a function together with an environment: a mapping associating each free variable of the function (variables that are used locally, but defined in an enclosing scope) with the value or storage location the name was bound to at the time the closure was created. A closure—unlike a plain function—allows the function to access those captured variables through the closure...
 
user1804599
Clojure.
 
How is a closure different from defining a first-order function?
I mean it's basically arguments for first-class functions right?
 
The typical HoF takes a function as argument.
 
10:13 AM
@Cinch I believe we already covered this exhaustively.
 
A function on values -> zeroth order; a function on function on values -> first order; and so on
 
@Puppy This is fucking unacceptable
@LucDanton Oh cool
 
user1804599
@LucDanton But functions are values!
 
@LucDanton the recursion doesn't necessarily need to end on "values"
 
So in math, an analogy would be exponentation vs integrals/differential
because integrals act on functions
 
10:14 AM
@ScarletAmaranth Oh, right, I have it the wrong way around sort of.
 
Hmrh.
 
Morning
 
Morning.
 
Good evening
So are closures instantiated function objects?
 
Instantiated meaning what?
 
10:22 AM
uh temporary
like a stack variable
 
Then no.
 
"instantiated" only refers to templates.
 
...
I thought templates were done at compile-time?
 
@LucDanton Well, actually, I believe they are (at least the original expression).
 
@Cinch 'Temporary' has a particular meaning in C++ that doesn’t cover automatic duration variables.
 
10:23 AM
@Cinch Yes, they are.
 
Then they iterate, not instantiate I think
 
no, it's definitely instantiate.
 
Or...
Bah w/e semantics
 
you instantiate a template with the appropriate arguments.
 
I'm wrong soz
 
10:23 AM
¬_¬ the difference between 3 and 3.0f is significant at times
 
I know.
 
@Puppy (Wow so mean)
 
closures are just regular function objects that can be temporary or dynamically allocated or whatever the fuck you want to do with them.
the original lambda expression itself does indeed produce a temporary as far as I know.
 
@Cinch Then also no. E.g. a functor may have static storage duration.
 
Uh so they do they call them closures?
Pretty misleading name
 
10:25 AM
not really.
we just call them lambdas.
 
In Standardese 'closure object' refer to the result of a lambda expression. In common parlance, one might say 'functor' to mean a closure in the wider sense.
 
I thought lambdas were generic programming, not necessarily closures
 
I don’t understand the question.
 
lambdas do one and only one thing: create function objects.
 
Right?
 
10:26 AM
if you use those function objects in a generic way then that could be generic programming I guess.
but that's orthogonal as to what the lambda itself is.
 
Are lambdas related to templates?
 
no.
 
Ah but I can put a template into a lambda?
 
polylambdas are in C++14.
 
@Cinch What does that mean?
 
10:27 AM
A lambda is just a language feature to create function objects.
 
but the actual lambda itself is not a template; only the function signature is.
 
right.
there is nothing inherently special about lambdas in any way.
 
Except Lambda is a sword lady
 
they are just syntactic sugar for convenient creation of function objects.
 
10:28 AM
anyways
 
Generally speaking you can have anything you want in the body of the lambda expression.
 
so closures = function objects
 
no.
 
Function objects are 'first class functions' in C++. Though I guess maybe someone will debate that.
 
just stop using the word "closure", it is not really relevant in C++.
 
10:28 AM
But apparently people say C++ does or doens't have them
 
people are morons.
what they expect from a "closure" is irrelevant.
what matters is what C++ offers.
 
So uh aren't lambdas and function pointers sort of similar?
Ok wai tno
 
@Cinch Nah. There are more things that can act as closures (in the wide sense) than just function objects, such as regular functions. They don’t close over anything so it’s a bit of a degenerate case—however a compiler can choose to implement functions that close over things.
 
kinda.
function pointers are the shit version of function objects, of which lambdas are one way to produce.
and captureless lambdas can convert to function pointers.
 
There's a special clause to turn a non-capturing lambda to a function pointer.
 
10:30 AM
@Puppy So the "capturing" part is what makes a closure a closure?
 
1 min ago, by Puppy
just stop using the word "closure", it is not really relevant in C++.
 
@Cinch It is what makes them interesting. 'Closing over no variables' still makes some sense, so it’s no use making it an exception.
 
Hm...
According to the javascript snippet I just saw, comparing it to the C++ one...
 
@Cinch In C++ a "closure object" is the temporary created when a lambda expression is evaluated. The type of that expression is called "closure type". Whether and how these terms relate to the term "closure" used outside of C++, I can't tell.
 
@Cinch The outcome is irrelevant.
focus on what's important- the language you're actually learning.
fuck what JavaScript offers or calls it's features.
 
10:32 AM
According to the Javascript implementation, it's a function objects masquerading as a function + state
And C++ just implements it the same
so uh... they're the same thing? O.O
 
That doesn’t sound like a masquerade.
 
ok then, just don't bother to listen to my advice.
 
@Puppy Why fuck other languages?
 
@Cinch Because you're not programming or learning them. You are programming in or learning C++.
 
C++ has already borrowed from other languages
or paradigms
 
10:33 AM
where the features came from is irrelevant.
what matters is what C++ offers.
 
That's like saying history isn't important and I beg to differ but you do have a point
But regardless I use history to help me understand things
 
Oh right. I forgot to talk about my post-mortem I think.
 
then you need to stop
 
@Rapptz What are you dissecting?
 
After dealing with the whole <system_error> shenanigans I decided that std::error_condition is really lame.
 
10:34 AM
@Cinch Better question:
Why bother with the approval of others when you're perfectly convinced you know what you're talking about and are confident that closures from javascript are equivalent?
 
well
 
Which is kind of odd considering I went into this thinking that it was better than std::error_code.
 
Why come?
 
@sehe Because I'm not?
 
unless you want to discuss the history of C++, which may inform you as to why some features are that way.
but first you'd need to actually learn what they are.
so it can't benefit you until later on.
 
10:35 AM
@Cinch It doesn't appear that way. Now, if you can reduce the discrepancy there, you'll have a much much fruitful dialogue
 
@sehe idk what that means can you rephrase that?
 
also they're really not equivalent.
kinda similar maybe but definitely not equivalent.
 
What matters to him is to understand how C++ works. If putting it into relation with other languages he already knows help him understand, I don't see anything inherently wrong with that.
 
@Cinch Stop shouting so you can hear what people are saying. Perhaps it will enlighten you for the details you are unsure about
 
@sehe Oh okay yeah that's my problem good idea
 
10:37 AM
@LucDanton I don't particularly see a good use for it. Through the use of macros you can 'abstract' the error code away through the enum value. Like e.g. POSIX errno vs WSAError codes. I don't see why you'd want to abstract this even further when you can just do a comparison with the abstracted enum + std::error_code.
 
@Rapptz why are there so many abstractions for errors in C++
 
You don't wanna get into this.
 
@Rapptz That assumes there is a straightforward errno <-> WSAError bridge no?
@Cinch How many is 'so many'?
 
@LucDanton Well. There is actually.
It's actually just WSA + errno.
 
I was gonna ask which abstractions you know off :)
 
10:39 AM
Uh... That's 4 different things to learn (okay, not abstractions)
 
@Rapptz Sure, that time. But one instance won’t convince me: the value of error_category would manifest as long as there are enough instances where there is no such bridge.
 
main return values & error codes, exceptions, and then the two std::WHATEVER
Why?
 
@Cinch The return value of main is an error code. What are the WHATEVER?
 
@AndyProwl The problem is that he seems completely incapable of grasping how they differ, often in critical ways, and seems to prefer simply defining them as totally equivalent when they're completely not. So he ends up with a totally incorrect view. It feels very "C++, C and Java are all the same language".
 
So far 'so many' is two.
 
10:40 AM
anyway I have to go
feel free to bash him some more.
 
@Puppy which they're not
 
@LucDanton Sorry I'm not seeing the relevance of std::error_category here.
 
@Puppy lol
 
@Puppy That’s you imagining things.
 
Btw I am so pissed that even many online tutorials do not inherently teach C++11
to beginners
And then GCC is by default not C++11
 
10:41 AM
Online tutorials for C++ anything mostly suck.
 
@Rapptz If the purpose of error_category is to bridge mismatches between categories and codes; and if you haven’t found any such mismatch; then we can conclude nothing.
 
@Rapptz s/C++//
Online tutorials are always old and unfiltered
 
I should make a C++11 tutorial after I learn it
 
Necessity of life where static hosting is cheap - and it's easier to leave the old garbage there than to remove it
 
If most colleges still teach C++03 WTF learns C++11 for real?
 
10:44 AM
You
 
@LucDanton The purpose of std::error_category is to provide a string message to the enumerator values and to provide equivalences if needed. It's not so much a 'mismatch' between categories and codes, it's for equivalences of std::error_code and std::error_condition. In fact the only time I could imagine needing to do such a mapping would be if an std::error_condition is a set of multiple std::error_codes but I haven't ran into this scenario yet.
 
And many others
 
Programmers.
 
@Cinch Pro tip: "WTF" does not a sound argument make
 
@Cinch Your college teaches C++03? Then it's light years ahead of most other colleges, which tend to teach "C with classes" (also known as "C/C++").
 
10:45 AM
@FredOverflow Yeah I have a PhD teaching my class
I asked him "Why no C++11?"
 
@Rapptz std::error_code also has a message() though?
 
"Books and $$$ he said"
and yeah, they basically teach C with classes
but he's also a fanatic with operator overloading
 
@LucDanton You can't create an error_code without a category.
The message comes from the category.
 
"Every class should have its operators overloaded" or something liek that
We also haven't touched std::string yet
 
@Cinch lol why
 
10:46 AM
IDK
 
@Rapptz oh, it’s a convenience thing
 
@LucDanton Yes, but it's also method/purpose obfuscation
and that's frustrating
 
@Cinch What have you touched instead? char*?
 
@FredOverflow lol yes
We've done linked list
 
@FredOverflow no, they're next level; const char*
 
10:47 AM
I just got done with the Tower of Hanoi problem
and then I'm working on a non-recursive version of that
 
@Rapptz I still think the 'portable errors' aspect is worthwhile, e.g. what about the dlopen/dlsym Windows equivalent? Surely you can’t map codes 1-to-1 there?
 
Does dlopen use integers for errors?
 
Sort of, it has its own dlerror. So most of the time you get a nullptr and then you check the error.
 
@ScarletAmaranth Oh god.
lol const char*
 
FWIW the error is portable, just the value isn't.
 
10:50 AM
Sometimes you get a nullptr, check for the error, but there is none because nullptr was the right value!
 
We've only just gotten to <iostream>
 
Which is kinda the point of std::error_condition, portable error code values.
 
it's pitiful it's already halfway through
 
@Rapptz Well, yes. What else?
 
But I can't blame them
 
10:51 AM
@Rapptz My point exactly!
 
@LucDanton Just clarifying!
I don't see the point of a portable numeric value.
 
So now you can make a portable API that still forwards whatever error the underlying API actually returned, while sticking with a high-level error abstraction.
@Rapptz Ya know, same deal as native_handle.
^well that’s the non portable one
 
> Slightly different to some of the conversations other people are having here, but I've just had to tell my six yr old that he can't be a formula one driver as he would be starting too late.
wait what. ^ that strikes me as grossly exaggerated (unless 6yo is a couch potato already)
 
the portable one is because you want your API to report errors!
 
@LucDanton You can do ec == ns::error::no_memory as a high level error abstraction and ns::error would be an std::error_code-compatible enum without touching std::error_condition though.
you also avoid the whole shenanigans of mapping the portable error value to a non-portable one.
I guess that's really my issue.
 
10:55 AM
@LucDanton awesome
 
2
Q: How can dlerror() return NULL if dlopen() fails?

Mike AlbrenI am working on system that loads all *.so modules library automatically by call a script. I tried to update one of the modules to support XML-RPC. I used the library ibxmlrpc-c3-dev on Ubuntu 10.10. The problem that dlopen() fails after my changes and dlerror() returns NULL. The compilation doe...

relevant
 
Indeed, more details may turn out to be helpful. Generally, I'd recommend to debug with gdb and fix with vim. — Michael Krelin - hacker Dec 17 '11 at 19:35
well... super advice right there. "Fix with vim"
 
:fix obv
 
@Rapptz Something was bugging me: I made the mistake again of mixing up _category and _condition again. All this time I was talking about error_condition (which was on-topic, thankfully enough). Sorry for the tangents it generated.
"Use your keyboard to input the correct code."
 
FWIW through this conversation I thought of a scenario that might seem like a use case for std::error_condition but I'm not sure if it can fix the issue outright.
Which I guess you touched upon a bit earlier
i.e. API 1 has an error for something that API 2 doesn't have
 
10:59 AM
I’m really surprised, I thought you had implemented several things on top of Posix/the Windows API already.
 
I have!
there's a lot of compat stuff there
 
The functions don’t always match, I don’t see how the errors can.
 
The only times I've ran into those is WinAPI's initialisation errors.
 
Did you try dlopen/dlsym?
 
nop.
 
11:02 AM
That’s one where the functions don’t match, I’m fairly sure.
memmap?
 
Outside of my gripes with the error condition thing I didn't really like the API design philosophy I had to do.
It was very repetitive
and it made default parameters very awkward
 
Yeah I can see that.
@Rapptz I don’t like default parameters, at least as done in C++.
I don’t feel like they really help anyone.
 
they have uses
in my case it was stuff like
this int should usually be 10 99.99% of the time but if you want to change it you can
 
Yeah I’m doing something like that atm.
 
You need to provide a self contained example. You never specify what apply is, to begin with. I just spent 15 minutes reading that linked question+answers and still can't work out what you are most likely referring to. — sehe 10 secs ago
 
11:05 AM
Who names anything apply :v
 
@Rapptz There is no such proposal for nullable stuff or variants!
that means it sucks
 
Have you already been using C++14 in your personal projects?
 
Yeah, it’s on everywhere.
I need generic lambdas for tuples/variadics, also unrestricted lambda bodies.
But also sometimes I forget a late -> decltype( … ) and it only blows up in my face much later :(
 
Apparently gcc 4.9 supports auto f() { return 10; }
 
11:10 AM
I’m also starting to use more generalized constexpr.
 
I actually haven't touched C++14 yet.
My base minimum to compile code is usually gcc 4.8
 
Library-wise I like off-shoring to std::integer_sequence :v
 
lol probably
 
So I'm a little bit confused now :) changing the typename...Ts from the select_ method? This will occur in an more or less unusable source code, because it will be a specialization for the class User, isn't it? — Felix 38 mins ago
so much confusion there
 
C++14 makes some of my C++11 code kinda useless at times.
not complaining though
 
11:12 AM
I can’t wait for GCC to get fold expressions so that I get rid of a handful of #include "annex/tuple/algorithms.hpp". It feels wrong to bring so much in to achieve so little.
 
A long time ago, before C++14 was a thing I was hoping poly lambdas would be a real thing so there could be a saner LINQ library in C++. Still kinda waiting for that but I stopped caring about LINQ a long time ago.
 
It’s a bit early, no? GCC 5 still in development after all.
 
well poly lambdas are a thing now
don't see what gcc 5 would help there
 
I’m like 100% in trunk these days, I completely missed it’s in the releases.
 
stage 4 atm
should be released sometime this month
I'm too lazy to rebuild all my libraries lol
:(
 
11:16 AM
$ git --version
git version 1.9.1
lol why does LinuxMint 17.1 come with a 10 months old git?
 
Eh, it could be pushed back, too. The issue tracker is well-filled up, which is a bit unusual at this point.
 
I couldn't get OpenSSL or any SSL library to compile btw.
Feels bad. :L
 
Which (if any) C++ logging facility do you guys use?
Own library? Boost?
 
@FredOverflow 17.1 doesn’t seem to be a super recent release, and it has long-term support.
 
@StackedCrooked I don't use one but someone in the lounge, @wilx, has their own logging library that seems to be fairly popular.
 
11:18 AM
@Rapptz You’re no ninja master!
 
user1804599
@StackedCrooked Here's a pro tip: the only logging library you need is a function to compose two functions and a function to write to a file descriptor.
 
@LucDanton Honestly I don't mind compiling anything except libcurl and OpenSSL.
It's left me scarred.
 
@райтфолд ELI5?
 
Oh I found it.
 
@LucDanton Oh, it's from November? I thought it was only a couple of weeks old.
 
@StackedCrooked I would use log4cplus. But I am biased. :)
 
@wilx Nice!
I like that the loglevel is part of the macro name instead of a param.
 
user1804599
% target/closure-library/closure/bin/build/depswriter.py --root_with_prefix="lib ../../../../lib" --root_with_prefix="$HOME/mill-example/ ../../../../../mill-example" > target/deps.js && node -e 'require("./target/closure-library/closure/goog/bootstrap/nodejs");require("./target/deps.js");goog.require("main");main.main(true,function(){main.main(false,function(){});});'
 
user1804599
Google Closure is so terrible at finding modules.
 
I'm using a library based on the Dr Dobbs article.
Which uses syntax like COMPANY_LOG(Info) << "Test";
But I'd prefer something like company_log_info() << "Test";
(Company is placeholder for company name.)
 
11:25 AM
I think these feature macros.
Is MSVC going to add these
 
user1804599
 
both GCC and Clang have them
they seem very useful
 
user1804599
The generated code is absolutely gorgeous: gist.github.com/rightfold/da77913fd8a4e5925b27
 
@Rapptz What are you talking about exactly..?
 
@StackedCrooked Feature test macros.
#if defined(__cpp_generic_lambdas) && __cpp_generic_lambdas >= 201304
 
11:27 AM
Ah.
 
means that the compiler supports generic lambdas.
etc for other features
 
You can do it the blunt way like autogen.sh :P
Generate a small test program and check if it compiles.
 
disgusting :v
 
I know...
 
I'm not sure if <filesystem> is going to work in MinGW.
I have no reason to believe it will.
I didn't really think about this until today.
 
11:30 AM
I also don't like if code is strongly connected to the buildsystem.
 
user1804599
@Rapptz No need to.
 
user1804599
They already define all the ones they support.
 
@райтфолд Source?
> We currently have no plans to implement feature-test macros. -- STL
alrighty.
 
Why do you want them?
 
user1804599
11:34 AM
@Rapptz They don't need to.
 
I suppose it could be useful for libraries like boost.
 
it's useful for testing features between compiler versions (and types) without resorting to checking the versions.
 
user1804599
For all features MSVC supports, there is already such a macro defined.
 
?
what macro is that
 
Essentially the version number does map to a set of features.
So you can implement the feature checkers yourself :P
 
11:36 AM
Still
There's also __has_include.
arguably the coolest macro out there
 
What does it mean?
Checks for included header?
 
Checks if you can include a header
 
Oh, that's cool.
 
#if __has_include(<codecvt>) would be great!
lol
 
user1804599
val writer = new PrintWriter(args(1), "UTF-8")
try {
  import writer.println
  println("goog.require(\"std\");")
  // ...
} finally {
  writer.close()
}
 
user1804599
11:50 AM
This importing mechanism is great.
 
user1804599
I initially wrote to stdout, and now I don't have to change any of the code since I can just shadow the original println method by importing a different one!
 
My leg still hurts.
 

« first day (1603 days earlier)      last day (3328 days later) »