« first day (448 days earlier)      last day (4512 days later) » 

sbi
9:00 PM
Look what google found me:
9
Q: mix-in vs inheritance

Johndwhat is the difference between mix-in and inheritance

 
Ell
hmm yeah
im trying to make something like
 
sbi
@Ell The more important question is: Do I feel like spending my precious free time by listening to your problems? :) Try me, maybe it's an interesting problem. But please don't be offended when I prefer to go to bed. It's 10pm here and I've had a long and quite, erm, interesting day.
 
Ell
std::map<KeyType, MappedType>
dont worry I wont be offended :)
where MappedType has a function like setKey(KeyType) and getKey(KeyType). As an example I might have std::map<Coordinate, Monster>
and I can access monsters like this `monsters[Coordinate(1,2)]
but also, i should be able to change the monsters coordinate like this my_monster.setKey(Coordinate(2,6)
and its position in the map will also change
sorry it is difficult to describe, do you understand where I am coming from?
 
sbi
@Ell Seems fishy. If the KeyType already is in the MappedType, why do you use a map at all? A set seems more fitting.
@Ell Yeah. But it sounds like a 2-dimensional sparse array is more what you're after.
 
Ell
because, i want both the map and the mapped object to be able to change the key for the mapped value... if you understand :s
 
sbi
9:05 PM
@Ell That's what I said: this is no material for a map.
 
Ell
of course
 
You can not store coordinates on a monster, if you have a map from coordinate to one.
 
Ell
I could just use a set and then search through it every time i access something o.O
@CatPlusPlus why not? (if i understand what you're saying)
 
The more you duplicate the data, the harder it is to maintain integrity.
 
sbi
Also, it seems wrong from a design POV to have monsters have a coordinate attribute. The room I'm currently in is not some property of me, like my sex or the color of my eyes.
 
9:07 PM
You'll get inconsistency bugs sooner or later.
Where a monster is on key (2,1) but its coordinate attribute is (6,9)
And then what.
 
Ell
@CatPlusPlus thats the whole thing Im trying to do, have it so the keys are automatically synchronised
 
Don't make your life harder than necessary.
 
Ell
its just an excersize really :P
 
Also what @sbi is saying.
 
sbi
@Ell Have them only in one location, and synchronization isn't necessary anymore.
 
Ell
9:09 PM
@sbi so then how do I change the key of the mappedtype from a function inside mappedtype, where there is no access to the map
and I would argue that the room you're in is a property of you, why wouldnt it? if you can change it - by walking into a different room - why isnt it a property?
 
sbi
@Ell You can't. A pawn on the chess board doesn't change the field it's standing on. One of the players grabs it and puts it to another tile.
@Ell In order to walk to another room, I'd need to have access to the map.
 
Ell
@sbi but what about things that can move? like a... robot or something :p
in my opinion
 
sbi
@Ell When I am moving from one room of my apartment to another, I am changing the properties of those rooms ("room is now empty", "someone is in this room now"). I can do this myself because I have access to the apartment. I know its layout, I can even change it ("grab that end of the couch, please, we're carrying it to the next room").
 
Ell
hmmm
i suppose I could look at it that way
@sbi don't you think you can look at it both ways? or do you think things having a position property is wrong?
 
sbi
@Ell If the objects in your game have a position attribute, you don't need that map representing the space. You could just iterate over all the objects, check their coordinates, and display them at the right place.
However, then it would be hard to find out if any object is at a specific location, because you'd have to enumerate the list of objects. So I think it makes more sense to have a data structure that represents the game's space and position the objects in there.
 
Ell
9:18 PM
@sbi but what about when an object wants to find its own position?
 
Give 'em GPS.
 
sbi
@Ell What would it need that for?
 
Ell
@sbi well for example if it needs to find the distance between itsself and a goal position
 
@Ell when it need position, you can give it as a method parameter
 
Ell
@Abyx so lets say each has an update() method, do you think having an update(Position your_position) method is cleaner?
 
9:21 PM
update(Context& context) would be better
 
Ell
@Abyx well yeah thats just details but you understand the gist. Do you not think an object should know its own position?
 
btw, probably your update method does too much
 
sbi
@Ell In order to move something from one coordinate to another, the entity doing the moving, be it an algorithm in the object's class or somewhere else, needs access to the coordinates.
 
Ell
@Abyx this is entirely hypothetical
 
I don't see anything wrong with object knowing its position
 
Ell
9:24 PM
@sbi you mean to its own coordinates? or other objects coordinates? or the map containing the objects?
 
sbi
@Ell The map.
 
Ell
@sbi but if it knows its own coordinates, why does it need access?
Sorry if I'm frustrating you by argueing - I don't mean to
 
sbi
@Ell In order to move to a specific coordinate, an object needs to know whether that coordinate is actually accessible.
 
Ell
I just think if this was handled automatically behind the scenes it would be very convenient - or do you not think this would be used much?
 
sbi
IMO updating the game should be done from a function that's part of the game. It might delegate the algorithmic work to decide which way an object will move to a member function in the object's class, but then it needs to pass all necessary information (like a callback "call this if you want to know whether a direction is currently possible") to that member function.
 
Ell
9:28 PM
@sbi fair point actually. I'll have to think about that one
@sbi when you say a function thats part of the game, do you mean like the game loop?
 
sbi
@Ell Yeah, probably.
 
Ell
okay. This issue for me always occurs whenever I attempt to implement A*
because to me searching a list of nodes and checking eaches x and y position doesn't seem right when i could use a map[x, y, object]
but then when I do that, I find it messy to get the surrounding nodes because I have to search the map for self/this/whatever
 
sbi
@Ell What nodes?
IIRC, when I made a game like this, an object's update() function would only decide whether the object would want to go up, down, left, or right. It would then call back (into the map, ultimately, but it wouldn't know that) to ask whether it could go there. If not, it would pick another direction.
 
Ell
like finding adjacent nodes for example
 
sbi
@Ell It's one design goal to put the knowledge about an object, including its movement pattern, into the object itself. Another, conflicting POV, however, is the pawn-player model: A player moves the pawn. A perfect design would, IMO, combine these two conflicting goals. A pawn doesn't moves on itself, it is moved. However, how it moves is encoded in it being a pawn, and it would be nice to store this in the object.
 
Ell
9:34 PM
@sbi which is what in my opinion, a sort of synchronised map would do
@sbi as in, both the map and the mapped value can change the key
hmm kk so the pawn still wouldnt move itsself?
 
sbi
@Ell If you want, do it that way. But at least do not store the key in two places.
@Ell IMO an ideal design wouldn't do this.
 
Ell
@sbi so an ideal design the pawn would have access to the coordinates but still couldn't change them itsself?
 
sbi
@Ell No.
 
Ell
hmm interesting
 
sbi
In an ideal design, the pawn wouldn't even know there's a chessboard. All it knows is that it would like to go, erm, "up", or, if for some reason that isn't allowed, it might prefer to go "right", etc.
 
Ell
9:37 PM
i wonder what other people think - do you think I'm a minority?
but I disagree when things are supposed to be aware of their surroundings - like animals/humans/robots
okay when its a pawn - it shouldnt but when its a human, it should
is this question off topic for programmers.se?
@sbi sorry for keeping you up :P
 
sbi
@Ell Have you ever tried to play one of those chess games where humans are used as chess pieces on a big "board"? Those humans do not act autonomously, they are directed by two players. The reason is that 1) you need a centralized intelligence, and 2) you don't have an overview of the board when you're on it.
@Ell I suppose it would. I'm hazy on their rules, though.
@Ell I dunno. But how is that relevant? Most programmers prefer Java to C++. Does that make them right? :)
 
Ell
@sbi hmm I suppose they dont have an overview, but why does therer need to be a centralised intelligence?
haha fair enough :P
 
sbi
@Ell That's fine. I'm well able to say good night and leave if I want to.
 
2
Q: How tightly coupled is the compiler's brace-initializer-list to the type `std::initializer_list`?

rubenvbCan I achieve the same effects without the C++ header <initializer_list>? Does class initializer_list have to live in namespace std (does the compiler require this)? I'm fine with a solution that works on the big five (GCC, MSVC, Intel, Clang, Comeau)

posted some comment
i don't understand this
can someone please elaborate on this comic xD
 
@JohannesSchaublitb did you ever seen pacman? (game)
 
sbi
9:43 PM
@Ell Because 16 players following their own ideas about how a game should be played will certainly wreck it.
 
Ell
@JohannesSchaublitb he is throwing up cherries and balls that he ate
 
hmm no i haven't -.-
weird
 
sbi
@JohannesSchaublitb What? What's this world coming to?!
 
Ell
@JohannesSchaublitb google.com/pacman
@JohannesSchaublitb play it, its fun
@sbi speaking of pacman, each ghost has different ai ;)
@sbi nevermind that is irrelevant - i am mixing ai and rules now :P
 
sbi
@Ell I bet that was originally implemented in assembler. No OO there. No objects. No member functions.
 
Ell
9:45 PM
fair play
 
ah it means he barked
 
Ell
@JohannesSchaublitb yeah ;)
 
sbi
@Ell I remember my kids spending hours at google playing it when this was the doodle.
 
Ell
yeah :P it's quite addictive :p
 
@JohannesSchaublitb I answered your comment
The question sprung from an attempt of bypassing all/most of the std library to provide a completely unrelated replacement.
 
9:57 PM
@rubenvb what is "initializer-list initialization"? {1, 2} works fine for struct A { int a, b; };. it does not need initializer_list<int>.
it's still not clear what you ask in your question
 
@JohannesSchaublitb list initialization: e.g. 12.6.1/2. Any non-trivial class needs initializer_list to define those semantics.
 
and struct A { template<typename ...T> A(T... t); };. too works for {1, 2}
 
There is an assymetry between aggregates and other classes in this respect.
 
@rubenvb what "semantics"?
 
list initialization
 
10:01 PM
not true. an aggregate can be nontrivial, and the above class with a constructor template can take any one-level initializer list.
 
well, my choice of words isn't the best. Yet why then does std::vector need a constructor with std::initializer_list?
 
why would it not use it
it'S completely unclear what "semantics" you are after
 
someType A = { someVariable, othervariable, {somefancyOtherVar, 5}};
 
for struct A { A(int, string, tuple<int, bool>); } we can say A a = { 1, "foo", { 42, true } }; and that's perfectly fine. no initializer_list<> anywhere.
 
OK. Now I don't understand the use/"reason of existence" of std::initializer_list at all.
yet for a vector it's still necessary?
 
10:04 PM
it sounds like you should make a question asking for that instead of making a question that possibly makes false assumptions
 
Well, the assumptions came from my own trials
perhaps from bad trials, but still.
You weren't around yesterday ;-)
this won't work: pastebin.com/aWMN9fav
it needs std::initializer_list
I find it weird I can't do this without resorting to another class. Variadic templates don't need a class template_parameter_pack or similar...
 
can someone explain to mee how this call is working
void foo(something) {
if(something) {
foo(something 1)
foo(something 2);
}
}
not too familiar with recursion :)
 
where is my downvote chat message button...
 
@rubenvb for starters, you can do template<typename ...T, typename std::enable_if<std::is_same<T, int>::value, int>::type ...> A(T ...t);
 
@JohannesSchaublitb Did you delete your comment here? I think it was useful.

http://stackoverflow.com/questions/8773346/how-to-initialize-a-dynamic-int-array-elements-to-0-in-c/8773350#8773350
 
10:13 PM
@Mysticial ouah already said it
 
@JohannesSchaublitb So you are trying to say variadic templates can completely replace the need for a initializer_list class?
 
@JohannesSchaublitb ouah's comment covers the case for integers. It "looked" like your comment also included "all data type" which would imply floating-point as well? Then you deleted it.
 
i don't say that at all
@Mysticial no i only covered ints
i would only have covered floats by accident :)
 
@JohannesSchaublitb Ah ok. I didn't get a chance to read it more closely before it disappeared.
 
10:15 PM
GCC segfaults on my constructor template though, on ideone at least :)
as i'm now on windows7 i haven't got a recent GCC at hand
 
Ell
use tdm :P
 
i will use mingw-w64
i heard good things about it
 
it's good, I build toolchains for them
 
Ell
mingw64? i thought it was just mingw for 64 bit?
 
I haven't uploaded my latest GCC 4.7 build unfortunately. I think the autobuilds have 4.7
 
10:21 PM
hmm tdm-gcc says "It combines the most recent stable release of the GCC toolset with the free and open-source MinGW or MinGW-w64 runtime APIs to create a LIBRE alternative to Microsoft's compiler and platform SDK."
 
@Ell MinGW-w64 provides headers+crt for both architectures.
 
so they seem to be using mingw-w64 but replace their gcc
 
@JohannesSchaublitb Do not use TDM, he modifies GCC
 
so i better use original mingw-w64
 
so it won't accept options GCC should
yes
 
10:22 PM
ohh
 
and messes with DLL naming
 
Ell
@rubenvb tdm does?
 
@Ell for tdm64 yes
he renames the 64-bit runtime dll's with _64 suffix or something
 
no, mingw-w64 is completely separate from mingw and provides better stuff
 
Ell
10:23 PM
oh kk
@JohannesSchaublitb what better stuff?
 
@Ell newer msvcr* version API, secure _s API, winpthreads for std::thread
etc
 
i remembered i had nightmares finding .lib for normal mingw that implement certain windows functionality required by LLVM
mingw-w64 would have provided them xD
 
Ah, nothing like eating half of an onion.
 
I have to go.
Cya
 
Ell
@rubenvb adios
 
10:30 PM
@rubenvb thanks for your experts advice xD
i see you provide personal builds of it
or should i take the automated builds?
 
Ell
@JohannesSchaublitb hes gone i think :o
 
Ell
sorry :/
 
Hello!
Please, where I could talk with someone about compilers? I think that this is the wrong room, right?
 
Ell
no this is okay
what about compilers?
 
10:39 PM
Compiling phases...
I know that there are three main phases:
Scanning, parsing and semantic analysis.
 
Ell
o.O im not really knowlegable on the subject but you may as well fire your question away
yeah
then the compiling itsself
 
Yes
But I have a trouble
 
Ell
what with exactly?
 
On my book there is a scheme in which there are two more phases: error handling and internal tables construction.
I haven't understood if these two phases are part of the greater one, or are external...
 
Ell
sorry you should probably ask a question on the main site
i am not knowlegable enough on this subject
 
10:46 PM
Okok, I can wait.
 
@JohannesSchaublitb Never heard of mingw-w64 before. Looks, cool. Thanks!
 
@StackedCrooked sourceforge.net/projects/mingw-w64/files/… courtesy rubenvb
 
Is he a contributor?
 
It's under personal builds directory. Perhaps anyone is free to commit personal builds. Or somethings.. Heh.
Well, that could also count as a contribution.
I was once listed as a contributor on release notes when all I did was ask a question on the mailing list.
I still liked that :D
 
10:56 PM
@StackedCrooked: yeah more often you send in complete patches, which gp unanswered for about a year, until all at once they turn up in the changelist and you don't get credited ;)
 
Oh, hey, somebody likes onions.
 
@JohannesSchaublitb still trying to parse the code snippet mentally. LOL
 
11:11 PM
room topic changed to Lounge<C++>: Public service announcement: this is not an Objective-C room. Thank you. [c++] [c++11] [c++-faq]
3
 
Where is the objective c room?
 
Not here.
 
Hmm okay :)
 
Hahaha. I lol-ed
 
Subjective-C++: A new language. The compiler uses your code as a rough guideline for generating a program.
9
 
11:24 PM
That's C++, basically.
 
11:36 PM
-2
Q: Partial re-initialization of C++ object through constructor

hpcI am looking for an optimal pattern for partial re-initialization of a C++ object. With partial re-initialization I mean that some members (step_param in the code example) need to keep its values and other members (value in the code example) are re-init'ed. Important point: The bloat and red...

Oh. My.
How the hell people come up with stuff like this.
 
@CatPlusPlus Probably Jerry Coffin wasted his time providing a sound answer.
.
 
Could someone make me an example of sintactic tree?
 
@unNaturhal syntactic? Abstract Syntax Tree? Wikipedia, I venture
In computer science, an abstract syntax tree (AST), or just syntax tree, is a tree representation of the abstract syntactic structure of source code written in a programming language. Each node of the tree denotes a construct occurring in the source code. The syntax is 'abstract' in the sense that it does not represent every detail that appears in the real syntax. For instance, grouping parentheses are implicit in the tree structure, and a syntactic construct such as an if-condition-then expression may be denoted by a single node with two branches. This makes abstract syntax trees diff...
 
Abstract but referred to a generic programming language
 
A concrete abstract tree.
 
11:51 PM
@unNaturhal I'm sure you think you uttered a few words that make sense together. I'm just unable to extract that meaning at this time
 
@unNaturhal use google docs drawing, and make a picture of the structure of 2+3*4
there are many ways to depict it
one is as the usual tree with root in the air
the convention with root in the air wasn't introduced until the early 1970's, though, so you might choose to draw it with the root down (as Donald Knuth did originally)
or you can draw it as circles within circles. the biggest circle is the full expression.
or you can draw it like the DOS tree command's output.
which is pretty much like the folder list in the left pane of any Explorer-like GUI shell
is that enough to get you get going?
 
You missed the "send me teh treez" part.
 
she didn't provide the e-mail address of the teacher, did she?
 
Yes but... There are too many difference between what you say and what is written on my book. It makes an example of parse tree that is totally different by what you explained
 
ditch the book
 
11:56 PM
@unNaturhal: stupid of us. We failed to see you faxed us a copy of the book?
 
@sehe, do you really think to be funny at this time of the night?
 
Is there any revisions of C++?
Does the language develop these days?
 
@unNaturhal what makes you think so?
 
@AlfPSteinbach, If you want, I could try to drow the parse tree that is on my book.
 

« first day (448 days earlier)      last day (4512 days later) »