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

20:01
0
Q: How do I make a compiler in my Native Language? Like "Chinese C++"

Aritra ChakrabortyIn this question : Coding Java in non english language, for eg Spanish or Japanese there is no definite solution. I want to make a C compiler in Bengali(Indian language). But I don't know where to start. I started to study this article: Let's Build a Compiler but I don't know if I'm going the ri...

I'm almost certain: C++ optimiser does optimise passing objects if they are not changed in function, I don't have to prefix & in argument definition.
Is that true?
@BartekBanachewicz Now public: bitbucket.org/Borgleader/llogl/wiki/Home please be gentle =/
@rightfold My hair is so dynamic!
user3010322
My hair prefers duck typing.
user3010322
20:03
It does this a lot when I go to sleep.
user3010322
@Borgleader D'awww it's such a cute widdle wrapper yes it is! Yeeesss it is! ♡
I don't feel like it makes sense to have an overload for `Widget&&` in `push_back`. Isn't:

void push_back(const Widget& x) { put Widget(x) into container }
void push_back(Widget&& x) { put std::move(x) into container }

equivalent to:

void push_back(Widget x) { put std::move(x) into container }

??
Whos the cute widdle wrapper!
Try a barber. They have custom deleters for all types of hair.
user3010322
@Jefffrey Prefer the first over the second.
20:06
If it's an r-value, the constructor of Widget will move the value, but if it's anything else, a copy will be made.
@ThePhD why?
user3010322
The latter will do a copy and then a move, along with another move.
definitely prefer the second.
Ell
Ell
@rightfold what do I do each day?
well.
user3010322
The first will only do a copy at the very tip, if inecessary (with const T&)
Ell
Ell
I go to school
Xeo
Xeo
20:07
@ThePhD or move + move
user1804599
High school?
@Jefffrey: no, they are not equivalent! The first need a copy and move when using Widget but only a copy otherwise. On return, the temporary can be elided but is moved if there are overloads.
user3010322
The first will also do a move + move.
user3010322
The first basically presents an optimal solution.
Xeo
Xeo
Or even an... elision + move!
Ell
Ell
20:07
@rightfold Sixth form. I'm not sure what the equivalent is called
Xeo
Xeo
@ThePhD nope
@Xeo Can't be elided in this case.
user1804599
@Ell What software do you write?
for some reason Standard bans it.
@ThePhD I can't see where the copy is made
Xeo
Xeo
20:08
@DeadMG From where to where?
Ell
Ell
@rightfold At the minute I'm writing a swf parser
But I'm similar to you, I start lots of projects
then learn a bit/write a bit
user3010322
Using the second version:
user1804599
@Ell Sounds like a nightmare.
the two solutions are equal except that the first will perform one less move, and the second is vastly more clear and readable.
user3010322
WidgetContainer.push_back( preexisting_widget ); // copies, then moves
Ell
Ell
20:08
But then often I lose momentum :/
since the performance loss of 1 move of most classes is typically practically nothing
@DeadMG so, you agree with me?
the readability win is much more important.
Xeo
Xeo
I'm pretty sure the by-value parameter can be elided into
in addition
the first presents issues like aliasing
that the second does not.
Xeo
Xeo
20:09
which enables "elision + move" as the best possible scenario
@ThePhD the first version will copy as well :/
Ell
Ell
@rightfold It is quite nightmarish. At the minute I'm writing up all the tags in yaml to later write a code generator in ruby with all the serialization/deserialization stuff :P
user3010322
The first version copies only when the copy needs to be made.
user3010322
i.e.: into the container's storage
@Xeo I'm pretty sure it can't.
user1804599
20:09
In some cases the compiler can also inline move ctor, then detect it’s just assigning some variables and optimise the entire thing out.
@ThePhD In the expression WidgetContainer.push_back( preexisting_widget ); a copy will always be made
Xeo
Xeo
@DeadMG That would defeat the whole "want speed? pass by value" premise
assuming preexisting_widget is an l-value of course
@Xeo Well, not really, since moving most objects is basically free.
user1804599
@Ell I once wrote a part of an assembler generator in Perl.
user3010322
20:10
@Jefffrey A copy, without a move.
plus, like I said
user3010322
Directly into the container's storage.
the first presents problems like aliasing which the second doesn't.
Xeo
Xeo
@DeadMG If only for that, the first version with two overloads is the better solution
@ThePhD ok, so you are bitching about the extra move?
user3010322
20:10
What is aliasing?
user3010322
@Jefffrey Yes.
Xeo
Xeo
because moves are not free
user1804599
It read a file containing instruction descriptions and generated C++ code from that which generated machine code.
@ThePhD I see your point now :)
@Xeo what's the cost of casting?
user3010322
casting... ?
Xeo
Xeo
20:11
@Jefffrey Nothing, but the move constructor always has a cost attached
user1804599
@Jefffrey Depends on the kind of cast.
Ell
Ell
@rightfold did it work?
user3010322
std::string's move constructor is especially costful.
user3010322
Thanks to SSO.
user1804599
@Ell Somewhat.
user1804599
20:12
I implemented only one kind of instruction format.
user3010322
(in relation to something like, say, std::vector)
user1804599
Don’t know anymore which one it was.
this is an interesting discussion
@ThePhD "can be", not necessarily "is".
user1804599
I should rewrite it using template metaprogramming.
user3010322
20:13
@JerryCoffin True. I know for a fact MSVC's SSO means that moves have to check if the buffer is on SSO mode, and then performs a memcpy. If not, it then swaps pointers.
user3010322
I forget the allocation size for the SSO, but I think it's somewhere between 8 and 16 bytes, or 8 or 16 _charT
@ThePhD Right--main point is that std::string doesn't necessarily use SSO (in fact, VC++'s is nearly the only current one that does implement it).
user1804599
No matter how slow it is, it’s always fast enough.
user3010322
@JerryCoffin Mmm, delicious VC++.
user3010322
Also, @DeadMG What's this "aliasing" problem?
user3010322
I can't help it; you're just so good when you handle me, Elliot-kuun~
@ThePhD: I though on a move with SSO you could just memcpy() and blast away the source...! No need for a branch but rather a few fast assignments.
I have an assignment for you
user3010322
@DietmarKühl You have to select where the memory goes: the dyamically-allocated pointer or the stack-based memory. When I spoke to STL directly about it, he said it had to do a comparison and then perform the copy, or swap the pointers if it was dynamically allocated (check if _ptr == _mybuf._myptr or whatever the lame internal names are).
user3010322
For copy construction, if the ptr is always facing the right storage, you just memcpy and you're done.
user3010322
20:19
But for moves, you have to move the right things. If the storage is stack-based (part of the object itself that dies with the destructor), then there's no possibility to do a move.
user3010322
You have to copy.
@ThePhD: I don't see that! You'd just always memcpy() the words representing the record (plus the potential allocator but that needs to be treated separately anyway). When move-assigning you might want to move the destinition into a separate record first.
Of course, if you insist on a portable implementation (i.e., you don't access the "other" field in a union) you'll need a check to determine which part of the union you should be accessing.
@ThePhD Its pretty isnt it :D
Ell
Ell
I think insisting on a portable implementation is best :3
user3010322
The problem can be illustrated
user3010322
20:27
with the follow:
user3010322
struct small_integer_storage {
    union {
        int __res[16];
        int* __pres;
    } sso;
};

small_integer_storage target;
small_integer_storage move1;
small_integer_storage move2;
move1.sso.__res = { 1, 2, 3, 4, 5, 6, 7, 8 };
move2.sso.__pres = new int[ 230 ]( );
// Correctly move the right thing
target = std::move( move1 );
target = std::move( move2 );
user1804599
Hmm.
user1804599
If I have a variadic macro, can I put things between each of the arguments?
user1804599
I want to wrap each argument like std::declval<arg>().
sso is a POD which can be memcpy()ied. ... and reset using sso = SSO(); (assuming you'd give it a name)
you only need a check when cleaning the LHS up which is what is done in the dtor in any case.
20:33
I wish I didn't hear the truth, Scott
@Jefffrey facepalm his universal thing is much more confusing than reference collapsing ^^
But reference collapsing exists because the compiler can do what you can't
The compiler can generate references to references
which is a much more confusing idea than "Hey, look! Another C++ special rule (universal references)"
guys, question.
I can't see how it's confusing, I fail to be discombobulated
20:36
Is there an easy way to have std::basic_string<wchar_t> be constructed from const char*'s?
@Jefffrey Er, no it can't.
the compiler does not create references to references.
@rubenvb No.
ok, it collapses them later
Fuck. Then I need to fix my string class.
the compiler will collapse multiple references into a result correct reference
@Jefffrey It collapses them right away.
reference collapsing is a type-system feature and occurs immediately.
20:38
and the resulting correct reference is very intuitive in spite of what Scott says
ok, but in the deduction of the type it gets to have reference to reference
the fact that it fixes it somehow is not important to the discussion
but yeah, both of the ideas are not particularly confusing
Hmm should I install Raspbian, Arch, OpenELEC, Pidora, or RISC OS on my rapsberry pi?
I'm edging towards Raspbian or RISC OS
@Borgleader Arch.
Duh.
And mount /var/log in tmpfs.
:p
@LightnessRacesinOrbit did you ask Jalf's permission to onebox?
@ScarletAmaranth what
20:44
@ScarletAmaranth wut
nevermind! :)
I know! I'll private inherit from basic_string
fack it Raspbian it is
@rubenvb Now that's a winner whiner of an idea!
well, it's kinda icky to const char* to wstring, because, well, it's a const char *, you will have to do the conversion to a wider type somehow anyway
20:48
@ScarletAmaranth for ascii it's trivial.
(unless I am wrong :P)
Which is the only case I am interested in.
it's not about the wider type. It's usally about encoding and charsets
i.e. simple "hello world" strings in my code.
how about public inheritance (oh noes virtual destructor) and I add a constructor?
or do i need some form of delegating constructor magic?
20:49
@rubenvb there's ascii7 and ascii8, the latter is not trivial because you'll have to deal with charsets (well, unless you keep them, but that would be neither here nor there, as there is OS that by default expects latin1, cp-1252 or whatever 8-bit charset in an 16bit encoding
user1804599
> error: default template argument in a class template partial specialization
You should use ogonek
user1804599
Argh. SFINAE fuck you.
@sehe ha, lol
I wanted to.
But that would be overkill.
@rightfold I hate that too
20:52
@ScarletAmaranth Ok, maybe the actual truth is useful when understanding using, typedef and decltype rules
user1804599
My first use of Boost.Preprocessor! coliru.stacked-crooked.com/a/64e8e9dd568bec10
I mean, it makes sense. But, gah. Why is sfinae still always clumsy
@Jefffrey I can't see how the universal reference thing can be useful really
> Communication among developers
Is there a way to pull in the std::string-only non-member functions using using?
or would a conversion operator do?
21:02
It's a "name" for what actually happens.
Are you saying you don't have a use for reality?
I'm not really trying to shield anything from being used.
@rubenvb pull in where?
user1804599
I want anonymous macros.
@Jefffrey my namespace, so they can be used with my class. Although now I think that won't work, will it.
@rubenvb Only if they operated on std::string without conversion
21:03
Hmmm.
@sehe No, I can't see how not thinking about reference collapsing is useful really. With Scott's annoying "you are not prepared for the truth" sort of nonsense.
@ScarletAmaranth You can think about reference collapsing. In fact, this is basically what UR is about: an idiom to speak about common cases in the face of template argument deduction and reference collapsing.
@sehe Alright, I don't like the way he presented universal references as a mechanism to avoid thinking about reference collapsing.
When. Can't you see the substance instead of the one instance where he presented it wrong?
IIRC he spent 10 minutes repeating that only the syntax auto&& id will result in a universal reference
21:06
@ScarletAmaranth Would you say, it's not useful to refer to chess moves as "a gambit", a 'subtraction-check', or one of many combinations? Just because, well "I can't see how not thinking about tempo and direct threats/exchanges move-by-mobe is useful"?
@ScarletAmaranth So, zap
abstraction is important but not when you are even encouraged to not understand what's going on
Empty rhetorics.
You can't reverse it because you're angry at Scott being Scott
I think you just hate Scott for some reasons
That's your patience lacking, no reason to dismiss the ideas
and yes I dislike Scott, but that's really not the point :P
21:09
@Jefffrey What makes you think that. He obviously hates this particular talk/presentation/incident :)
Obviously
@ScarletAmaranth Glad you agree. Because it's pointless
no, I dislike the way that "universal references" are generally thought about
I'm out to go drinking wine, as usual
See you later mum
I am off to study moar, laters
21:10
How do you authoritatively establish the way "universal references" are generally thought about?
@ScarletAmaranth Wokays :/
user1804599
Iterators are so nice.
because AFAIK, it was Scott to crown the term with that talk - and that talk, whilst being about a useful abstraction, encourages you to basically not think about what is going on
No. It gives you handles to see the implications of && in generic code more clearly.
I made the chess analogy for a reason. A grandmaster doesn't look at the board in details until he checks his combinations. But for strategy, or quick "advantage ruling" he looks at the board in "chunks" that interact.
Ell
Ell
@rightfold I think so
If people don't remember why it works, their loss. If people forget about the interaction between chunks, that's always unique, well, perhaps they don't have the capacity.
21:14
@sehe yeah, that's how abstraction works...
It's not the fault of introducing the term "universal references".
user3010322
Lol
user1804599
@Ell What could possibly be more beautiful than this?
user3010322
I've spent all this time hammering away at making this internal SSO work.
user3010322
Shit's hard. :c
21:15
In fact, that term might prevent a lot of these people to draw the wrong conclusions over and over again.
Remember rule of three? It was too hard for the masses.
alright, you win, the term is not useless, the way he presents it is terrible, now I rly need to study :P
When is a non-virtual destructor and public inheritance a problem? If I don't add any data members to the child, is there ever a problem? Or is it just undefined behavior?
@rightfold Hmm...you have a reader that writes, and you wonder what could be more beautiful?
user1804599
It’s a tee device!
@rubenvb You get undefined behavior if you destroy a derived object via a pointer or reference to the base.
21:18
@JerryCoffin damn.
@rubenvb: when you delete a derived object through a pointer to a base without a virtual destructor you have undefined behavior.
It doesn't matter if there are data members or not at all.
user3010322
@DietmarKühl It still requires a conditional with the SSO. =[
Anyways:
0
Q: Extending std::(w)string, by adding a constructor and some member functions

rubenvbSure, the std::string interface is already bloated. But it's missing some (for me) crucial elements. For example, a std::wstring cannot be constructed from a plain const char* (which is what is needed to create one from a string literal). I'd also like to add an operator/ and a split function. A...

@ScarletAmaranth There's no need to think about reference collapsing :S
It's an arcane detail.
user3010322
@DietmarKühl Ignoring the memory leak, yes, you still need a conditional to make sure you're pointing to the right buffer: coliru.stacked-crooked.com/a/a71b4802ae1fb314
21:22
Damn. The British house of commons surely looks like comedy:
Anyone please tell me this was a dramatized television show.
nope, that looks like our Houses of Parliament and our elected idiots politicians.
Shouldn't you be returning std::basic_wstring<cT>? — 0x499602D2 26 secs ago
fail
@sehe noisy ordeal
@rubenvb Not gonna happen.
stop telling me i can't do this :-P
It's frustrating me.
well, I'm sorry that it's not possible
21:27
I was trying to avoid the conversion crap.
@rubenvb Your ideas are terrible.
@rubenvb Then stop asking
but there's nothing you can do to hide the fact that the existing Standard interfaces are hideously fucked in this respect.
there's a reason why everybody else does the whole, "Convert on I/O" thing and it's because it's the only reasonable approach.
@DeadMG Thing is, there isn't a decent alternative...
> Please don't say "don't do this", unless you can provide a way that 1) does what I want, 2) doesn't require me to write it all myself, 3) does not bloat my caller-side interface.
And this is nonsense.
21:27
3) is impossible in Standard C++.
lool
"Don't do this" is a perfectly acceptable answer.
user3010322
Hm.
Not for me. Because I knew that answer. I asked the question for an alternative to doing it another way.
You need to state the problem you want solved first.
21:28
@rubenvb There aren't any. That's why everybody does it another way.
Not describe the solution you want.
user3010322
I can't do template <std::size_t n> void mycall () as a member function delcaration in C++ ?
That last paragraph does exactly that: ask for the solution you want, not for a solution for the problem you have.
the reality is
"Use the system encoding" would only be viable if literals and many other things would respect the relevant system encoding.
but none of them do so you can't do that.
Mine do.
user3010322
21:30
OH
user3010322
Fucking
user3010322
Titty shit cocks
@rubenvb Erm, what.
They're all just alphanumeric and dots and stuff.
...
that has absolutely nothing to do with it.
user3010322
21:30
Fucking not allowed to have template members in an in-function declared class.
you're talking about core language type rules and binary data storage schemes.
user3010322
Whoever came up with these template rules needs to be kicked.
whether or not you actually use non-ASCII is irrelevant.
essentially.
"" will always require a conversion to put into a wstring.
It has no characters at all.
string(const char* c_string)
  : tstring(c_string, c_string + std::strlen(c_string)+1) {}
21:31
I mean, if you don't ever use any Unicode data then why do you even care about using wstring on Windows?
You need to implement a compiler, instead. And get a whole lot less noisy. Please.
Thank you
this works if tstring is a std::string or std::wstring.
@rubenvb Is hideously wrong and broken.
you will get a completely incorrect conversion.
@DeadMG How so? It showed the correct results.
it converts each char in the string to a wchar_t, keeping its value intact, thus the character it represents.
Well, be on your merry way :)
21:32
just like integer promotion.
(sign the form here, will you)
user3010322
@sehe I'd be happy to write a new language and a compiler for it with templates, concepts, no trigraphs or digraphs, optional arrays, strong for loops, scope-based deterministic destruction, a strong backing library, module-based source code, and much more.
at least it worked for me using a std::vector<wchar_t>.
user3010322
Just give me 2 years and 100,000 USD pls.
@ThePhD Evading my point. Not pretty.
21:34
I like how you make a point of adding "no trigraphs or digraphs".
user3010322
@R.MartinhoFernandes I don't like them. :D
@ThePhD You have to earn these things. And being loud and obnoxious about facts of life you haven't thought long enough about isn't one of the ways that usually leads there
Really, those are pretty much never a problem.
@ThePhD You're playing a childish child
It scares me that they come up so early when you think about what C++ has to fix.
21:34
@R.MartinhoFernandes Especially since none of the usual compilers even implement them unless you specifically ask them to.
It doesn't interest me at all. I'm not scared of a derpstorm's opinion. Instead I'm scared of what I do in C++ :/
user3010322
@R.MartinhoFernandes Digraphs and trigaphs get in the way of useful symbols I could be using for keywords, which is why I'd like to not implement them.
That never happens.
(<: is pretty much the only one that could possibly be a nuissance, but isn't really)
@ThePhD As Bjarne has frequently pointed out, if it weren't for C compatibility, C++ could easily be a much cleaner language -- albeit one that was unknown, unused, and mostly forgotten.
And if you tell me it happens in your code, I'll just laugh.
user3010322
21:36
@JerryCoffin I'd be more than happy having a programming language nobody uses.
user3010322
Freedom to smash the entire API and change it to suit my needs.
@ThePhD Then jump in and (as Nike says) just do it.
user3010322
Yay~
My little piece of advice would be that if you're doing to start over with something that isn't compatible with existing code, you should find a cleaner starting point than C to do it from.
@ThePhD: If you store a pointer to the start of the string, you need to have a conditional during constructor - agreed. Since I'd prefer to cram up to 15 characters into 16 bytes I wouldn't do that, however: there would be a condition upon access. I guess, that was the core misunderstanding we had. ... and, yes, I have not profiled which approach for the SSO is more effective, certainly not in a real application.
user3010322
21:41
@DietmarKühl I wasn't even going for a performant implementation. I was just wondering "how the hell is this going to work??"
@Rapptz No. /cc @Fanael. ADL only kicks in for unqualified names.
Ell
Ell
@ThePhD I don't think you would
There would be no libraries for it
user3010322
There would be libraries for it.
user3010322
The libraries I wrote myself.
user3010322
To do all the graphics programming I want to do.
Ell
Ell
21:42
Like what C++ did with C, and what wide is doing for c++, it needs compatibility to leverage existing code
user3010322
To do IO the way I would like it done.
Ell
Ell
@ThePhD How would you deliver a product in competitive time :/
user3010322
I'm not delivering any products.
8 mins ago, by sehe
@ThePhD You're playing a childish child
user3010322
This is my personal language, which I am free to implement for personal, academic, and commercial use. Since nobody else is using it, it's all mine.
user1804599
21:43
I will use it.
@ThePhD So do it already! :-)
user3010322
@JerryCoffin Already on it!
user3010322
But it'll take at least 2 years.
Hmm, fuck it, I'm going out.
user1804599
Bye.
21:44
I've been working on Wide for longer than that in total, I think.
but then again, you're not horribly sick.
-5
Q: C++field of struct if error

CrashDownWhat is hire wrong? Can someone please explain the issue to me? if statement is not working. if(restavracija[i].ocena>restavracija[x].ocena){ restavracija temp=restavracija[i]; restavracija[i]=restavracija[x]; restavracija[x]=temp; }...

re-open vote please. the problem and answer are both perfectly clear
@ThePhD I'd personally recommend starting with something a lot less ambitious. The first thing you probably want to do is a language simple enough that you can concentrate on learning to define a grammar and use parser generation tools and such to implement it (or do a hand-written grammar, if that's your preference).
DeadMG is a sick, sick puppy. He also has some illness or something
Ell
Ell
@ThePhD at least :o
Oops: s/hand-written grammar/hand-written parser/
21:52
Just wanted to let out a big warm thank for the folks that have been answering my questions here. :D
the fuck is my wallet
@R.MartinhoFernandes Second drawer on the left.
I always lose my wallet
@VaughanHilts Hi Vaughan. I'd say "You're welcome", but I don't recall having answered any of your questions. Given my memory, that doesn't mean a lot though.
Ell
Ell
@VaughanHilts No problem :) But when will you be paying us? o.O
21:57
About that...

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