« first day (4001 days earlier)      last day (949 days later) » 

5:44 AM
Hello
 
6:10 AM
Hello!
 
World!
 
 
2 hours later…
7:51 AM
I'm creating A C++ interface for a library in which I'm defining a bunch of public classes with constructors that take 0 or more args. Is there are any way I can prevent my library users from shooting themselves in the foot by instantiating them accidentally as Foo foo() (instead of Foo foo or Foo foo{}), thus confusing the compiler with a so-called "most vexing parse"?
On second thought, I guess should make this an actual SO question...
 
@Will no, you can't really solve parsing issues with library design
maybe if you call all your classes like Please_Google_Most_Vexing_Parse_Foo
 
@PeterT Haha, I see. Yeah, I kinda thought so. Oh well, not really my problem then, I guess...
 
Thought std::initializer_lists might've helped, but they don't work with niladic arguments (0 arguments)
 
BTW, I'm not really sure what's so vexing about MVP cases where the instantiation happens inside a function body: C++ doesn't allow nested functions (aside from lambdas), so can't the compiler just rule out the function definition scenario in such cases?
Anyway, thanks for the feedback, @PeterT, @Lapys.
 
Did you post it as a StackOverflow question? 🤔
 
8:05 AM
@Lapys Not yet. Reckon it's worthy?
 
Well, a question I'd bring up is why prevent initialization like Foo foo; or Foo()? 🤷🏾‍♂️
 
From what POV do you mean that?
As the library designer I'm only interested in reducing footguns, so to speak.
 
From either the users or designers (but mostly the users)
Can't see a problem other than syntactic ambiguity on the user's end i.e.: can't tell function calls & class instantiations apart
 
Sure, for anyone remotely experienced in C++ it's a non-issue, but for beginners coming from other programming languages using parentheses is an easy mistake to make I feel: it's almost universal syntax for instantiation outside of C++, no?
 
you can't make your libraries mission to teach beginners C++
 
8:12 AM
Yes.. not to sound pretentious or gate-keepy, but uhm.. let beginners learn..?
Also aside from the fact that enforcing {}-only instantiation seems hard in C++
 
Right. I'm not disagreeing with that, but I also feel that depends on the intended audience to an extent. Plus, I'm the guy who has to clean up bogus bug reports and stuff :p
 
Compiler bug reports, colleagues' bugs, or bugs for software you're working on?
 
A mix of all of those...
But, anyway, point taken. Seeing as it can't be helped either way, I'll stop worrying about it now.
 
 
2 hours later…
nwp
10:06 AM
 
10:26 AM
How about this instead:
 
nwp
That does not look like it pays 24€ an hour.
 
11:03 AM
A keyboard can make you 24€ an hour? I would definitely get a dozen ...
 
nwp
Unfortunately having multiple doesn't make me more productive.
 

« first day (4001 days earlier)      last day (949 days later) »