« first day (37 days earlier)      last day (4920 days later) » 
00:00 - 12:0012:00 - 18:00

12:00 AM
@tina So, you got some programming problem for us? Or do you simply want to chat? :)
@JohannesSchaublitb What happens to the rep?
 
@Fred i think they will be taken away after the next rep recalc
 
how do i filter unanswered questions?
 
but i don't care lol
 
@tina so what is the problem at hand?
 
12:14 AM
What is "parse by value"? See comment here:
3
A: Could C++ have not obviated the pimpl idiom?

Luc HermitteMay be because the size of the class is required when passing its instance by values, aggregating it in other classes, etc ? If C++ did not support value semantics, it would have been fine, but it does.

 
Maybe "pass by value" was intended? I have no clue.
 
@Johannes: I think we need a new tag called "NAQ", never asked questions , where we can masturbate as much as we want :)
Or even better "SAQ" seldomly asked questions because that sounds like "suck" :-)
 
@FredOverflow What would you tag these questions, [c++-code-porn]?
 
@JamesMcNellis No, I'd go with NAQ or SAQ
 
Also, henceforth I will be referring to "raw pointers" as "naked pointers." (Thank you for that new term, Fred and Johannes).
 
12:24 AM
@JamesMcNellis I've never heard of that term before, I swear! I always call them raw.
@Johannes: "Iterator invalidation is a very interesting topic. Do I smell another FAQ?"
 
12:45 AM
@tina What is a sequence diagram?
 
@FredOverflow It's a UML thing.
 
@JamesMcNellis okay, but loops aren't objects.
 
@FredOverflow No, they aren't.
I'd rather see 100 more questions with a void main() in them than have to use UML again...
 
@JamesMcNellis LOL
 
@tina About halfway down this page is something about loops... Is this what you're after? ibm.com/developerworks/rational/library/3101.html
 
12:54 AM
@JamesMcNellis omg reading the ibm page with the uml is so tedious, and the code it represents is trivial. Is uml actually useful for real world code?
 
@FredOverflow No. UML is not useful for anything. It is a complete waste of time. It is an absolutely horrible thing.
 
And how do you model templates and metaprogramming with uml?
 
(I admit, having spent about ten months working on a UML model for a software project that never got built, I'm a bit biased. The worst part was that we could have built the software in less time)
 
@JamesMcNellis So UML is even worse than "design" patterns? :)
 
@FredOverflow I don't mind design patterns. I think they are sometimes overrated. What I hate is when someone goes overboard and tries to cram every design pattern he knows into a project.
 
12:57 AM
@JamesMcNellis Yeah, like StrategyFactoryManagerSingleton and stuff :-)
 
The worst form of UML is the form advocated by IBM / Rational. They have an "executable" UML where you draw UML diagrams then write snippets of code in parts of the state machines and other diagrams that you draw.
On the surface, it sounds really neat. It's not though. It's absolutely awful. It's impossible to debug because you can't easily change the generated code. It's impossible to maintain because you can't look at the source and get an overview of what it does.
 
@JamesMcNellis And yet it's "successful" in the sense that IBM sells it and people use it?
 
I think IBM paid several billion dollars to buy Rational Software.
The company I worked for until September was working to move all of its software to that process (or a similar process).
 
@Johannes: I did the ADL retag ;-)
We had a question related to ADL neulich, but I can't seem to find it. It called std::distance instead of the global distance. Can you give that the new tag? thx
 
What did we retag it to? [omg-adl-sux]?
 
1:05 AM
@JamesMcNellis argument-dependent-lookup
6
Q: Please retag from [adl] to [argument-dependent-lookup]

Johannes Schaub - litbPlease retag questions from adl to argument-dependent-lookup and (possibly) make the former a tag-synonym of the latter. Making them synonyms is not without trouble, because there are two questions that use it with different meaning - one about "AIR Debug Launcher" and one about some "ATI ADL", v...

 
Awesome
Yeah, now I remember that, and I made some joke about it or something.
(By "joke" I mean "something I found hilarious but was probably really stupid and not appreciated by anyone else")
 
@JamesMcNellis Fell free to rant here:
4
Q: What are the pitfalls of ADL?

FredOverflowSome time ago I read an article that explained several pitfalls of argument dependent lookup, but I cannot find it anymore. It was about gaining access to things that you should not have access to or something like that. So I thought I'd ask here: what are the pitfalls of ADL?

> Wow, the whole answer is a copy'n'paste from Wikipedia - that's a bit much. Referencing, summarizing and quoting excerpts is fine, but only pasting a big chunk
Didn't notice that. Come on, @James provide us with a better answer!
@Wee: Ah, fresh meat!
@tina You simply say: "Would you like to come to my house? Tomorrow evening at eight?" and press enter ;)
 
@tina click on their name, and an option will come up 'invite this user...", click on that and select the room
 
1:36 AM
@FredOverflow I wrote you a story
0
A: What are the pitfalls of ADL?

James McNellisThere is a huge problem with argument-dependent lookup. Consider, for example, the following snippet: #include <iostream> namespace utility { template <typename T> void print(T x) { std::cout << x << std::endl; } template <typename T> ...

I'm pretty sure the details at the end are correct concerning name lookup and overload resolution.
I wasn't really aiming for perfect technical details; I just wanted to try and explain the code.
The code definitely demonstrates one of the biggest failings of ADL.
Now we'll see how long it takes GMan to realize I've made fun of him. Again. :-P
 
2:38 AM
Wow I don't see why that works @JamesMcNellis
Oh yes I do, ignore that.
 
3:21 AM
@CiscoIPPhone: Yeah, it's a fun rule. :-|
 
 
1 hour later…
4:29 AM
@JamesMcNellis +1 for mentioning someting rong
@tina good morning
 
4:49 AM
@tina have u found a book yet?
@tina so, no c++ book yet?
@tina well, the code you've been analyzing has been very C-like
@tina but studying from a reference manual is seldom good way
@tina you need reference manual in addition to ordinary introductory textbook, unless that textbook includes a ref manual like "The C Programming Language" does (or did)
@tina I had a truly horrible thought. please, what's the name of your "reference manual"? is the author one named "schildt", like, "herbert schildt"?
@tina ah, thanks. you scared me with this talk of "reference manual" (could be shildt)
 
5:29 AM
@tina See e.g. the section on showing loops in sequence diagrams in IBM's "UML basics"
google (or wikipedia, whatever) is your friend
what do you mean?
@tina quoting the IBM page, "The loop shown in Figure 10 executes until the reportsEnu object's hasAnotherReport message returns false" now check the figure. at the top left inside the frame you find that condition
@tina is the problem how it should look or how to create that look with your tools?
@tina just do UML by hand, pencil and paper (that's what it was designed for), if you absolutely have to model things in UML
afk
 
 
1 hour later…
7:08 AM
Sometimes I wonder if Stack Overflow is the only place there is such a large group of very vocal modern C++ fanatics.
 
@JamesMcNellis what do you mean? where are we all local to?
 
7:51 AM
yer, for like 10 minutes... then the fun of uni starts again ¬_¬
 
@tina just let it simmer? coffee, reading a book, talking a walk in the rain or sunshine
you still doing sequence diagram of that function you posted?
<code>
char SPI_SLI (char* p1, char* l2) {
point* pl2 = (point*)(l2+InfoSize);
 
afraid the most I have ever really bothered with UML is class diagrams and flow charts... though I think UML has its own crazy ass version of flow charts
 
This declares a variable named pl2 of type point*, a pointer to a point.
it's not that function?
 
and your trying to work out what this is actaully doing yer?
 
ok, continuing then. The expression l2+InfoSize) calculates a pointer InfoSize bytes into the l2 array of bytes passed into the function as argument. So, a pointer pointing to the relevant place in that byte array
do you understand that?
@tina let's take one function at a time, ok?
@tina which one do you want understand?
Do you mean the char SPI_SLI (char* p1, char* l2) function is the one you want to understand?
 
8:07 AM
theres no function calls there... their is type casting? things like ...(point*)p1,...
 
@tina Do you mean the char SPI_SLI (char* p1, char* l2) function is the one you want to understand?
OK, that's from the char SPI_SLI (char* p1, char* l2) function
OK, let's analyze the condition. Just to check we're talking about the same, can you please copy and paste the text of the condition.
 
f (SPI_SPI((point)p1, pl2[i]) == '0') return '0';
that is a self contatined line of code, it is the same as
if (SPI_SPI(*(point*)p1, pl2[i]) == '0')
{
return '0';
}
same for if(m_GB.BetweenI(pl2[i-1], pl2[i], *(point*)p1, SPATIAL_EPSILON)) return '0';
self contained line of code
 
@tina ok slooow doooown :-)
 
@tina that line of code is correct just by it self,
 
OK, so we have the following condition:
SPI_SPI(*(point*)p1, pl2[i]) == '0'
Right?
 
8:15 AM
SPI_SPI() is a function, agreed?
it takes to arguments, agreed?
 
ok. let's analyze the parts of the condition
it consists of two parts separated with ==.
the == checks for equality
 
its sort of like doing this
foo(int a, int b){
if(a > b){
return true;
}
return false;
}

if(foo(3,1) == false){
// 3 is greater then 1
}
 
the value on the right side is the character '0' (single digit zero)
the value on the left side is the result of a call to SPI_SPI function
so it calls SPI_SPI, and it checks whether SPI_SPI produces the digit zero, '0', as result
we can simplify it by naming the SPI_SPI arguments, like
SPI_SPI( a, b ) == '0'
do you understand that?
ok then.
yes.
you could rewrite the thing as
char const funcResult = SPI_SPI( a, b )
if( funcResult == '0' ) ...
 
@tina SPI_SPI is not a member function, their is no object on which SPI_SPI is called
not EVERYTHING in C++ HAS to be Object Orientated
 
@tina it's impossible to say from the presented code whether they're member functions or not
@tina if the function with the loop and condition etc. is a member function, then there is a this object. and that's the object doing the calling
@tina so, when you're talking about which object, first question is, are they member functions?
 
8:27 AM
ok, Im of now. good luck @alf
 
ok, then the object doing the calling is the object that function in turn was called on.
inside the function that's the *this object, but it's just used implicitly
instead of SPI_SPI(a, b) you could write it explicitly, like this->SPI_SPI(a, b)
:-)
if that helps you understand it. it would also serve as a check of the assumption that SPI_SPI is a member function. with explicit this->... compiler will complain if it isn't a member function
right, except you need to provide the two arguments
but please note that the only purpose of that this-> explicitness is to understand what really goes on. it's very often or most often omitted, except in beginner's code.
do you want to understand the two arguments?
ok. now, i erred when i said "right" to your rewrite
please note that 0 and '0' are two different values. the first is integer zero, the second is usually integer 48, namely the ASCII character code for digit zero character.
the original code uses '0'
yes
ok. finally, for your UML analysis, you'll need to figure out what the characters '0' and 'f' mean in this context. it's just an arbitrary choice the programmer has made.
i seem to recall similar characters in table for 9-intersection in papers on the net, so perhaps it's the same convention
but do keep in mind that whoever wrote the code was not sharpest person in the world, rather on the other end of scale... so assumptions about what things mean are best tested in some way.
(sorry for that formulation, but i think it's important for understanding this kind of code)
 
9:04 AM
ok...
i mean, shoot :-)
hm, i don't understand what you mean by "at case 0", also i don't see any call of SPI_SLI ?
i don't see any switch statement?
well those are at least 2 questions
first, "should i use 'this'". only if it helps you understand the code. it can help you be sure that the called function is a member function, because otherwise (with this->) the compiler will complain
secondly, "return back to case 0", i think you've misunderstood the code
in each case there is a return statement. that means a return from this function, no more execution of switch statement or anything else within this function
well then i don't really understand what you're asking
oh, i don't know. it's years and years since i did any UML. only general guideline: ask yourself whether this way of showing something, or that way of showing something, is most easy to understand for someone else looking at the diagrams
 
9:26 AM
Seems pseudo-code would be much better for this low level stuff
 
is using a std::string as a key in a std::map a good idea?
 
yes
:-) unless they're huge
 
the size of the strings you mean?
 
Having some problems with template function speicalisaation
 
@Tony yes
 
9:33 AM
@SujayGhosh what's your problem
 
@AlfPSteinbach cool
 
I want to specialize max funciton -- char* max ( char * str1, char*str2)
@CiscoIPPhone any diea , what I am missing out
 
where is the specialized function?
 
@tina a raw array lets you look up an object given an integer index (in a contiguous range). a map lets you look up an object given a key that might be e.g. a string. so a map is much like what's called an associative array. it even supports the array indexing notation, []
 
9:37 AM
that the proble
it should be
typename <>
the specialized function is not there , writing that is not a problem, but when I am compiling I am getting errors
 
@tina :-) no, it's not the map-of-geography kind of map. std::map is more the mathematical kind of map. like a function is a mapping of values from domain to co-domain (if i got the terminology right)
 
@SujayGhosh Actually what you have there is a template class so you need to specialize the whole class
template<>class CTutorial<char*>
{
public:
CTutorial(void);
~CTutorial(void);

char* max(char* a, char* b)
{
return a > b ? a : b;
}
};
 
and what about the original template
 
leave it the same as it is
 
awwwwwww ... where is reuse then... its copy and paste
 
9:44 AM
well no, your char* max function should be different otherwise there's no point in specializing
maybe max should be a standalone template function?
then you wouldn't have to specialize the whole class
 
well I want to make a calculatror
calculator, which can add stuff< int, float, double > .. but the catch is when char* comes in
so I would like to have a single class, and specialize the functions , isnt that possible
 
9:59 AM
I don't know how to do that, if the class is a template itself
 
10:18 AM
ok
?
 
std::map keys have to be unique right?
 
@Tony yes, but there's also std::multimap (possibly an underscore in there)
@tina i don't understand what you're talking about now. it seems to some new context.
oh i'll check out your link
 
multimap is different, it allow you to store similar keys , whereas map store an unique key
 
@tina there are three problems that make it difficult for me to understand it fully: (1) the font in the figure is difficult for me to read (it's small), and (2) it's a long time since i did any UML (i think i've mentioned that), and (3), the only thing that is relevant to your work on that, is that the diagram seems to refer to the code's data structures directly, using same expressions as in the code. explanations of those could help
return FALSE means a return from the function. so nothing more in the function is executed. the execution position goes back to the caller (which is in some other function)
by the way, that statement would more naturally be written if( !isRelated ) { return FALSE; }, and even better using C++ booleans, false instead of FALSE
i'm doing some cooking right now so not much time. but we can discuss the data structure stuff later. essentially i think you need to have seen how to transform Ungrokkable Code to More Clean Code, so, later, show you that
 
10:38 AM
ok, better to use a map with unique keys or a multimap with same keys?
 
10:59 AM
ok
i'm mostly away from keyboard now, though
 
@JamesMcNellis Awesome, thanks for the answer to ADL!
 
11:46 AM
@tina I think SPI_SLI function might be a good example to work out.
Hm, how do I paste code with formatting...
char SPI_SLI (char* p1, char* l2)
{
    point* pl2 = (point*)(l2+InfoSize);

    if(pl2[0]==pl2[(int)(*(InfoType*)l2)-1] && pl2[0]==(*(point*)p1))
        return '0';

    int i=0;
    if( *(InfoType*)l2 < 2 ) return 'F';
    for(i=1; i<(*(InfoType*)l2)-1; i++)
    {
        if (SPI_SPI(*(point*)p1, pl2[i]) == '0') return '0';
        if(m_GB.BetweenI(pl2[i-1], pl2[i], *(point*)p1, SPATIAL_EPSILON)) return '0';
    }
    if(m_GB.BetweenI(pl2[i-1], pl2[i], *(point*)p1, SPATIAL_EPSILON)) return '0';
@tina just say hi (whatever) when u see this -- as I reckon it's now exactly 1 hour since you wrote "after 1 hour"
 
00:00 - 12:0012:00 - 18:00

« first day (37 days earlier)      last day (4920 days later) »