« first day (321 days earlier)      last day (4634 days later) » 

8:00 PM
that's just general description, not normative text
 
It actually replicates and rephrases a lot of stuff from the C standard.
 
<quote>In addition to the facilities provided by C, ....</quote>
 
in what context?
 
It's mostly when describing the standard library.
 
not all of the Standard is binding - a lot isn't- and a lot of it is specific to only some features
 
8:01 PM
There is a lot of stuff not specified by the C++ standard that you need to look back to the C standard for.
 
mostly only when including the C Standard library headers that were included in C++
 
@TuxD Every one of those is explicitly mentioned.
There's no "if the C++ standard doesn't say anything, it's what the C standard says" rule.
 
8:14 PM
@RMartinhoFernandes That's covered by <quote>In addition to the facilities provided by C,</quote>
So it provides everything C provides + this extra stuff that is c++
 
@TuxD Where is that?
I can't find it.
 
@RMartinhoFernandes 1.1 Scope (Paragraph 2) of n3242
 
Ah, the scope description.
That isn't a "if the C++ standard doesn't say anything, it's what the C standard says" rule.
 
Its refering to the scope of the documentation. Not the scoping of variables.
 
If you say something is const (like return const object), does that mean all of the members are const as well in that temporary?
 
8:20 PM
So yes there is. <quote>In addition to the facilities provided by C, C++ provides additional ...</quote>
 
That isn't a "if the C++ standard doesn't say anything, it's what the C standard says" rule. That is just saying C++ builds on top of C.
There is a "if the C++ standard doesn't say anything, it's undefined behaviour" rule though.
 
@TuxD Those facilities are library level stuff, not language level.
 
Point in case: VLAs. They're valid C, not valid C++.
 
@RMartinhoFernandes But if it is defined in C and C++ does not contradict then it is defined.
 
@TuxD No, it isn't.
 
8:22 PM
Or something, I haven't really been following.
 
@CatPlusPlus Wrong version of C.
@RMartinhoFernandes Yes it is. We will have to aggree to disagree then
 
@TuxD It's the version of C mentioned by that paragraph you're quoting.
So I guess it's the right version of C.
 
C++11 is aligned with C99.
 
And also tried not to step on the toes of C1x
IIRC
 
Do you guys ever get sick of all this undefined/unspecified/implementation-defined behavior in C++? :)
 
8:26 PM
Nets you rep.
 
No one knows?
 
@FredOverflow drives me crazy, cause I don't know all these rules yet, so I keep getting caught out when repwhoring :P
 
@FredOverflow Yes, but it's there for a reason.
@Xaade Yes, they are all const- just like any other object aliased with a const alias. Rarely used though, because const temporaries are a dumb idea.
 
reason being?
 
8:28 PM
Now that I have a text editor that can highlight it, I think I'll try to write some Go for a change.
 
@TonyTheTiger Usually performance, sometimes implementer freedom.
 
@TonyTheTiger I'm pretty sure there's a SO question about that...
 
@TonyTheTiger We want a fast executable. Not limiting the compiler helps with that.
 
@DeadMG why dumb? I have a good reason for doing so.
 
8:28 PM
@FredOverflow link?
 
@Xaade Firstly, because when rvalue references come along, you prevent move semantics. You also prevent "swaptimization" in C++03
that means that const temporaries greatly hurt performance
 
If there were, it probably got migrated to Programmers.
 
I'm writing a class that manages keeping data synced up. However, I want a way for users to make multiple reads from synced data without having to sync every time they read.
 
38
Q: Philosophy behind Undefined Behavior

AlsC\C++ specifications leave out a large number of behaviors open for compilers to implement in their own way. There are a number of questions that always keep getting asked here about the same and we have some excellent posts about it: http://stackoverflow.com/questions/367633/what-are-all-the-c...

 
8:29 PM
and secondly, the user has to copy it to write to the data anyway, in most normal value-type scenarios
 
@TonyTheTiger Actually, it's on SE :)
@TuxD Don't pointers severely limit the compiler's opportunities to optimize? Would it be better to get rid of them? :)
 
Don't side effects severely limit the compiler's opportunities to optimize? :)
 
Absolutely they do.
 
@RMartinhoFernandes I think you're preaching to the choir.
 
If we could just get rid of both of these.
 
8:31 PM
if you have a class that's technically a value but exhibits custom reference semantics, it might make more sense to return a const value
 
We could have a super fast language.
 
@DeadMG Ooh secrets.
 
@TuxD Without side effects, pointers wouldn't make much sense anyway, right?
 
Pity it would be somewhat crippled. You need the side-effects somehow.
 
@DeadMG Ok, the thing is I have a structure of data that shared between C# and native C++. In order to do that I'm having to copy back and forth from my C# structure into a IntPtr (unless I'm doing this really wrong, which I'm suspicious that I am). I created a class that marshals into the structure anytime you ask the class for the data in structure form using a get method, and marshals back into the pointer everytime you set the class structure using a set method.
 
8:32 PM
purist alarm: get and set is not OO :)
 
you need to operate based on the data, not the code
 
However, I found out that every time someone tries to read member data using the get method, he's actually marshalling from the ptr, which is pointless because it's already synched from the last read.
 
i.e., allocate some unmanaged memory, and call into C++ to read and set it
 
@RMartinhoFernandes Don't quite agree. Side affects make it easier. But they are not required. Look at Functional or Single assignemnt languages. Technically no side affects. But with analysis you can do modification in place if you can show that the old version of the variable is not used after creating a new version.
 
Waaah, nobody's upboating me.
 
8:34 PM
as soon as you start copying the data, that should be a huge alarm bell
 
I agree.
 
you can even use unsafe code to modify it directly from C# if you'd prefer
 
I'm just unsure as how to share the same memory area with a native app.
 
@TuxD That's why I said "somehow". Even if pure Haskell had to get them in anyways.
 
you can't share GC memory, because the GC moves it for fun
you can, however, allocate native memory and pass it into C#, which is fine
 
8:35 PM
Which is why I have the routine I have now.
 
allocate in C++, pass to C#, and you're fine
 
The class allocates native memory, then marshals back and forth from and to a structure.
 
you should just create properties that read from a provided pointer to get the data and call into C++ to read from the pointer
 
Which works perfectly in all scenarios, it's just inefficient if I'm making a bunch of quick reads direction into the structure.
 
And again I've lost track of what we're talking about.
 
8:37 PM
@DeadMG That's a lot of overhead. Calling native code to read every value from the structure?
 
or you could just use unsafe and read it directly
 
@RMartinhoFernandes Meh, it's stupid anyway.
 
@DeadMG Can't I just alloc a GHandle and pin the managed structure to the pointer?
 
dunno, but pinning GC memory is a bad idea - pinning is like locking
this kind of interop is what unsafe was added to C# for
 
8:39 PM
It hurts performance by limiting the GC.
 
@FredOverflow Thanks for that, very interesting read :)
 
I don't understand why I can't just have a C# structure with all the marshal descriptors in place, and say this IntPtr IS a structure.
 
you can- that's what unsafe is for
 
> Edit: I seem to have tomatoes on my eyes, (...)
 
So, every code that would use values in the struct would have to be wrapped in unsafe?
 
8:40 PM
IntPtr i; // fill i
unsafe {
    CSharpStructure* pointer = (CSharpStructure*)i;
    // use pointer here
}
I'm not sure about the rules of unsafe, but I think you would just need to use them in various getters
 
and setters
 
@DeadMG Yes, you can hide the unsafeness away in some methods.
 
@RMartinhoFernandes I know that one, but usually with bananas. Or is that in the ears, I can't remember.
 
@Xaade And that
 
8:41 PM
damn, I already have marshals for the structure.... now I have to have a damn property for every field in the structure.
This just seems like too much work for something so simple.
 
better than the endless copying
it's not simple at all- C# and C++ are very different systems and converting between them is a pain
 
That's what the marshalling is for.
 
besides, most of it will be code you can copy and paste
and when you're done, you stop having to think about caching reads and that sort of stuff
 
woot, copy and paste....
2
 
8:43 PM
in fact, you could just factor it out into a method
 
I need a way to generic a property.
 
you could generate it via reflection, I think
but that could get messy™
 
You and everyone else. Not gonna happen :(
 
A method in the structure that takes a pointer.
This is so dumb. C# has a powerful marshaling object. Why the hell can't it just take an intptr and return me values....
 
> Dereferencing a pointer returned by a request for a zero-size object
can someone give an example of this UB?
 
8:45 PM
int* p = new int[0];
int i = *p;
(I guess.)
 
oh, but it's an array of zero elements, and since elem 0 is a valid access, I guess that should be valid no?
 
no, elem 0 isn't valid
 
An array of n elements only has valid indexes from 0 to index-1, not index.
 
You have zero apples. Give me the first one you have.
 
So an empty array has no valid indexes at all.
 
You have zero brain cells. Now think.
 
lol
@FredOverflow okay yes, of course :)
 
Note that the semantics of newing up an array is new T[number_of_elements], not T[highest_index]. Many beginners seem to be confused about that matter.
 
now when you declare int a; is that considered initialized or do should you set it to zero really?
 
Dammit. Pastebin is now blocked.
I suppose they don't want me pasting source code....
 
8:49 PM
@TonyTheTiger Depends on the storage duration. Static int objects are implicitly initialized to zero.
 
@FredOverflow valid point yes, though I should have known that by know. :P
@FredOverflow just in the body of main, as I wrote it
 
If they block Ideone I'm going to have to argue against that.
 
@TonyTheTiger Reading from an uninitialized automatic object is undefined behavior.
VS aborts program execution in Debug mode if you try, which is totally valid.
@TonyTheTiger (Where did you say it was declared inside of main?)
 
@RMartinhoFernandes AH, That's what I need, ZOMG, THANKS!!!!!!!!!!
 
8:51 PM
@FredOverflow ok, so is this then UB
 
@TonyTheTiger Even if it has e.g. automatic duration it's sometimes acceptable to leave it uninitialized. For instance: int i; std::cin >> i; is idiomatic provided the extraction is close to the declaration.
 
because technically I did not init the int
 
@TonyTheTiger Yep.
 
@Xaade Thank @DeadMG, I just moved his paste somewhere you could see :)
 
afaik
 
8:51 PM
@TonyTheTiger yes
 
@DeadMG THANKS. Minimal unsafe code, no need for properties, I can use my marshaling code, and no need to copy back and forth.
 
@LucDanton oh I see
@FredOverflow oh ok, I learned something then :)
 
I knew there had to be a way to do it.
 
@Xaade What do you mean, no need for properties? The code has a property in it.
 
so if I declare an int at the top of some function that I'm only going to use a few lines later, it's better to init it to 0, and I guess int's in class, should be init to zero in the ctor?
 
8:54 PM
Is it possible to put it closer to the site of initialization at all?
 
@DeadMG I mean, I had thought you would have to write a property for every member of the inner struct.
I was braindead.
 
You do.
there's only one property because my example only has one member
 
@TonyTheTiger As a general rule, always initialize your variables unless you're sure there's a good reason not to.
 
ACK.
 
8:55 PM
@FredOverflow cool, I'll remember that :)
 
you could, of course, just return the pointer and use that, but that'd involve marking everything as "unsafe"
 
I wonder
 
You'll need to mark the properties unsafe, but the unsafety can stop there.
 
> Converting a floating point value to a value that can't be represented by the target type
I'm not sure why you'd even try and do that?
 
I find it interesting how D defined that problem out of existence. When you say int i; it is always initialized to zero, but if the compiler sees that this is not necessary, it will optimize the initialization away. If you really want uninitialized, you can still say int i = void; but that should be rarely called for.
 
8:56 PM
What if I make a struct that has one member. That member being my ACTUAL struct.
 
Beware of mutable value types.
 
A struct with itself as a member? Sounds impossible.
 
No NO
I'll take a crack at it and post.
 
that won't help
 
I herd you like structs in your structs.
 
8:57 PM
> Converting pointers to objects of incompatible types
 
you still fundamentally have the problem that you have to encapsulate the use of the pointer
 
is that like pointer aliasing rules?
 
what it points to is quite irrelevant
 
There, now my pointer is unsafe, and what it points to is unsafe, but it returns a safe struct.
One property.
 
A safe mutable struct.
 
9:03 PM
Is it not mutable?
 
CSharpStruct x; x.ManagedStruct.i = 42; won't do what you expect.
 
I got "Any idea how to turn it into a macro? I've tried but failed so far." as a comment to one of my answer. I don't know how what to say.
 
@RMartinhoFernandes what would it do?
 
@LucDanton Pretend you never saw it.
 
0
Q: How would I have to imagine pixel-based rendering in Haskell?

FredOverflowImagine an imperative rendering engine that blits sprites to a bitmap that later gets displayed. This heavily relies on the ability to efficiently mutate individual pixels in said bitmap. How would I do such a thing an a language without side effects? I guess a completely different data structure...

 
9:04 PM
@Xaade Change a copy of the struct. Which makes it pretty much a no-op.
 
@RMartinhoFernandes Why is it returning a copy?
 
Has anyone here ever done rendering without side effects? :)
 
@Xaade Because it's a value type.
Value types have value semantics.
 
@FredOverflow Possibly track changes with a monad?
 
Your property returns copies.
 
9:05 PM
@LucDanton Turn it into Lisp macro.
 
I can't believe there's no "safe" way to do this.
 
@LucDanton So is it possible to have O(1) array update with Monads?
 
But I guess that makes sense.
C# doesn't know what I'm pointing at.
 
@Xaade What @DeadMG proposed works. Painfully tedious, but it works.
@FredOverflow There's an Array type in Haskell.
 
@RMartinhoFernandes I'd be surprised if it had O(1) update complexity.
 
9:06 PM
I now officially miss C++ pointers.
 
Hi all
 
> Haskell provides indexable arrays, which may be thought of as functions whose domains are isomorphic to contiguous subsets of the integers. Functions restricted in this way can be implemented efficiently; in particular, a programmer may reasonably expect rapid access to the components.
I'm not sure how fast that is.
 
read access fast, write access slow I guess
 
Have any of you guys worked on email programming ?
 
9:08 PM
@Xaade In what sense do you miss them? C++ still has pointers, doesn't it? :)
 
What's email programming?
Sending code to other people via email?
 
@Mahesh Mahesh is back :) Do you have another challenging rice chess problem for us? ;)
 
A c++ library that does email
 
@FredOverflow I miss the simplicity of C++ pointers because I can't use them in C# code, unless I want to tag everything unsafe.
 
So you mean SMTP.
Or MIME?
 
9:09 PM
@Xaade Well, C++ pointers are unsafe, so...
 
There's creating/reading email and sending email.
Well, and retrieving, which is wholly different protocol on its own.
 
I'm beginning to think it's better to pin C# data, than create unsafe data.
 
@CatPlusPlus - When I am adding content to be displayed in a newline, "\n" is being ignored and the message is displayed in the same line itself
 
That does not tell me anything.
 
I know that prevents the GC, but the ENTIRE POINT is that I have shared data that lives for the entire duration of the execution.
 
9:11 PM
Funny. In German, "Email" means "enamel" :)
 
Never ever going to GC it.
 
@Xaade It prevents GC of other stuff.
 
If you're creating HTML mails, then \n is going to get as ignored as those sent to browsers.
 
It prevents heap compacting.
 
what other stuff?
 
9:11 PM
@Xaade Other stuff in the heap.
 
@FredOverflow - I don't have any today for you :)
 
The heap cannot be fully compacted if there is a pinned object in the way.
 
@Mahesh Not every function is prepared to deal with ' \n'. What library are you using?
 
So it's like fixed system data on a hard-drive during a defrag.
 
9:12 PM
I'm beginning to not care.
 
"Kinda of" doesn't really work, does it.
 
1 min .. my phone sometimes ring and now it is
 
@Xaade Well, try it and measure!
 
measure what?
My heap?
 
See if it hurts your performance.
 
9:13 PM
@Mahesh Usually, when the phone rings, it means someone is calling ;)
 
My heap is bigger than yours!
 
My big is heaper than yours.
 
I'll rarely do this.... Most of the data will be created by native code, which means it won't be GCed either.
My heapa is bigga than yoursa.
 
Why are you using C# again?
 
What's not to love about C#?
 
9:15 PM
Well, the hope is that eventually one day, everything will be managed, and I won't have this nonsense.
And, anything is better than MFC.
 
Except PHP.
 
Agree to Disagree.
 
@Xaade Microsoft Foundation Crap
 
MFC is hell.
 
Disagree to agree to disagree.
Microsoft Fountain of Crap.
 
9:16 PM
PHP is on par with MFC or better than it. MFC is that bad.
They both function off the same idea.
 
Well, MFC works.
 
Basic stuff is easy, then pile shit on that may work and certainly doesn't have to fit into the pattern we already have.
 
Wee, cap!
 
It's like a farm with a cow, a chicken, and a pig. So you have beef, chicken, steak. Then add some alien creature from outside our galaxy, and then add some 4th dimension being that no one knows how to talk to.
 
32 to go.
@Xaade So, like Minecraft mods.
 
@CatPlusPlus Yeah, PHP is like Minecraft mods.
 
0
Q: How fast is Data.Array?

R. Martinho FernandesThe documentation of Data.Array reads: Haskell provides indexable arrays, which may be thought of as functions whose domains are isomorphic to contiguous subsets of the integers. Functions restricted in this way can be implemented efficiently; in particular, a programmer may reasonably ...

 
Have a few textboxes and a submit button, and send unencrypted data to another page.... PHP is great. Want anything more, and you'll have to sacrifice your soul to become a brainless zombie after you're done.
 
@RMartinhoFernandes thanks
 
Wow, that was quick. I already have an answer.
 
9:22 PM
Can I downvote it for some trolling fun.
 
Well, it was a whole minute and 30 seconds.
 
anyone seen this interview?
 
@RMartinhoFernandes "vector fusion" sounds interesting :)
@TonyTheTiger Yes, but it's been a while. Why don't you watch the first 5 minutes and see if it sucks you in ;)
 
Thermonuclear vectors.
 
first this:
> Not returning a value from a value-returning function (directly or by flowing off from a try-block)
 
9:24 PM
@FredOverflow It's stream fusion.
 
what's the bit about flowing off from a try block mean?
 
@RMartinhoFernandes lol confused
@TonyTheTiger I guess "What exactly happens when an exception is thrown in a try block", but without more context, it's hard to tell.
 
@FredOverflow lol, it was listed in the SO question that asks for all possible UB
 
@TonyTheTiger try { /* code */ } catch { WaterFaucet.Valve.Open(); }
 
Perhaps he/she meant a function try-block.
 
9:26 PM
Ah, one of those arcane language features that I never use.
 
@FredOverflow what feature is that?
 
i.e. int foo() try { /* stuff */ } catch(...) {} is UB if something is thrown since nothing is returned.
 
@TonyTheTiger You can have a try block between the function head and the body.
 
@LucDanton oh I see
 
9:27 PM
@LucDanton just add a return ability in the catch block.
 
You could just as well return nothing in a function without a try block, what's the big deal?
 
Yeah but that falls under the first case.
'directly'
 
> A backslash followed by a character that is not part of the specified escape codes in a character or string constant.
how is that UB, and not just a parser error?
 
Silliness?
 
You can never have enough UB!
 
9:29 PM
Ease of parser writing, I guess.
 
@FredOverflow I think you accidentally accidentally something in that sentence.
 
so I guess the compiler would ignore it but your program might behave funny, cause of a non existing escape sequence of chars
 
how can a program have static storage duration?
 
9:31 PM
@RMartinhoFernandes corrected
 
> For some reason I heard mammogram.
 
@TonyTheTiger The program is there for the entire runtime.
Or have you ever malloced a function? :)
 
@FredOverflow a program is always there as long as it's being executed, no?
@FredOverflow in my dreams, I've malloc'ed functions
 
@TonyTheTiger Exactly, that's why it has static storage duration.
 
@RMartinhoFernandes Say, I just remembered your remark about the style of my function declarations.
 
9:33 PM
@FredOverflow oh I see
 
template<int I>
typename std::add_lvalue_reference<
    typename std::tuple_element<
        I
        , tuple_type
    >::type
>::type
get();
@RMartinhoFernandes How do you declare that?
 
Gosh.
Let me try.
 
@RMartinhoFernandes What's a mammogram?
 
@FredOverflow No idea. Was on the Youtube comments of the video you posted.
 
The representation of a mammal.
 
9:35 PM
Mammography is the process of using low-energy-X-rays (usually around 30 kVp) to examine the human breast and is used as a diagnostic and a screening tool. The goal of mammography is the early detection of breast cancer, typically through detection of characteristic masses and/or microcalcifications. Mammography is believed to reduce mortality from breast cancer. Remaining aware of breast changes and physician examination are considered essential parts of regular breast care. In many countries routine mammography of older women is encouraged as a screening method to diagnose early breast ...
 
ouch
 
@LucDanton eh no
 
@TonyTheTiger Mammal, mammary. Same difference!
 
template<int I>
typename std::add_lvalue_reference<
    typename std::tuple_element<
          I
        , tuple_type
    >::type
>::type get();
 
ok, next Q: what the heck are partially overlapping object and how the heck would you ever get that?
 
9:36 PM
Not very different, I guess :(
 
@LucDanton no one ever spoke of mammery....
mammogram, OTOH, yes
 
Now that is trippy...
 
template<int I>
using return_type_of_get =
    typename std::add_lvalue_reference<
        typename std::tuple_element<
            I
            , tuple_type
        >::type
    >::type;

template<int I>
return_type_of_get<I> get();
@Luc: there :P
 
Namespace pollution alert!
template<
    int I
    , typename Tuple
    , typename Removed = typename std::remove_reference<Tuple>::type
    , typename Base = typename Removed::named_type
    , typename Ret = typename with_qualifications_of<
        Tuple
        , typename std::tuple_element<
            I
            , Base
        >::type::element_type
    >::type
>
Ret
get(Tuple&& tuple);
This should be my record, I think.
Of course the body is one using declaration and then a return statement.
 
@LucDanton that's hughe
 
9:40 PM
Yeah, perfect forwarding with generalized tuples is not convenient.
I don't know why I even do that. Is it allowed to specialize std::tuple_element?
Doesn't look like it is. Oh well.
 
So I'm trying to make the declaration above simpler but it's not that much simpler and it breaks my unit tests :|
 

« first day (321 days earlier)      last day (4634 days later) »