D
DevNull
Hello everyone,
I decided to pick c++ back up after not really having used it much in
10 years.
Just as a point of refference, there was no standard C++ last time I
used regularly.
Anyways coming back, I've fallen in love with all the improvements in
the language such as the STL. Congrats to anyone who worked on it,
you did an excellent job.
To teach myself c++ again, I decided a good first project would be to
implement a scripting language against a MUD server/client system I
originally designed in C.
Thus far I've made what I feel is incredible headway, and thanks to
this newsgroup I've gotten over a number of humps.
To make a long story short, I'm a bit confused. I went head first,
and decided the std::deque would be an ideal structure for
implementing my scripting languages stack.
Now I've had a chance to look at the boost spirit library and numerous
others, and it looks like a structure called std::stack is the
preffered method of implementing alot of the things I've implemented.
But there's a problem and I can't quite get my head around it.
std::stack is a FILO object whereas std::deque at least as I'm using
it, can be FIFO or FILO. In my case, instructions go in via push_back
and get removed via pop_front making it effectively a FIFO object.
But std::stack has push and pop methods which operate only on the top
of the stack.
To me at least it seems more natural to push an object to the bottom
and pop it from the top, which means that instructions get executed in
the order they are added.
But it looks like I'm wrong here, as I said almost every example I can
find uses std::stack, can someone smarter than me (pretty much
everyone except the guy selling viagra), explain why the std::stack
implementation is considered superior so much so that I cannot find a
single example of a VM using std::deque?
Thanks in advance!
I decided to pick c++ back up after not really having used it much in
10 years.
Just as a point of refference, there was no standard C++ last time I
used regularly.
Anyways coming back, I've fallen in love with all the improvements in
the language such as the STL. Congrats to anyone who worked on it,
you did an excellent job.
To teach myself c++ again, I decided a good first project would be to
implement a scripting language against a MUD server/client system I
originally designed in C.
Thus far I've made what I feel is incredible headway, and thanks to
this newsgroup I've gotten over a number of humps.
To make a long story short, I'm a bit confused. I went head first,
and decided the std::deque would be an ideal structure for
implementing my scripting languages stack.
Now I've had a chance to look at the boost spirit library and numerous
others, and it looks like a structure called std::stack is the
preffered method of implementing alot of the things I've implemented.
But there's a problem and I can't quite get my head around it.
std::stack is a FILO object whereas std::deque at least as I'm using
it, can be FIFO or FILO. In my case, instructions go in via push_back
and get removed via pop_front making it effectively a FIFO object.
But std::stack has push and pop methods which operate only on the top
of the stack.
To me at least it seems more natural to push an object to the bottom
and pop it from the top, which means that instructions get executed in
the order they are added.
But it looks like I'm wrong here, as I said almost every example I can
find uses std::stack, can someone smarter than me (pretty much
everyone except the guy selling viagra), explain why the std::stack
implementation is considered superior so much so that I cannot find a
single example of a VM using std::deque?
Thanks in advance!