In response to Ripiz
Ripiz wrote:
If it's C++, how you handle vars in BYOND? In DM we can set var to any value, and we don't care if it's int, float, double or string. However in C++ var type has to be defined, and can't be changed. Do you have multiple Arrays?

Aside from the identifier-and-data-pointer method described by others (notably Lummox JR for confirming this method is the way BYOND's internals work), keep in mind that, thanks to C++'s support for templates, you can create generic classes to hold any kind of data and which can be freely used for others. This is exemplified by the Boost Libraries, particularly in the boost::any class (which may hold any type) and boost::variant (which may hold any of a range of types).

An example of boost::variant:
#include <iostream>
#include <string>
#include <boost/variant.hpp>

int main(void)
{
boost::variant<int, std::string> someVar;

someVar = 5;
std::cout << someVar << std::endl;

someVar = "The number 5";
std::cout << someVar << std::endl;
}


Now, if byond were to use this method, this could amount to something like so:
boost::variant<float, std::string, boost::shared_ptr<dung::object> >

boost::shared_ptr is a reference-counted pointer, dung::object would be my interpretation of the class which points to BYOND's internal objects --- mobs, objs, lists, etc.
In response to Jp
But I can't do VariableValue="text", I think
In response to TheMonkeyDidIt
TheMonkeyDidIt wrote:
Lummox JR wrote:
Almost anything that DM identifies by a reference, it stores somewhere else and does reference counting on it.

If DM handles garbage collection with reference counting, how does it handle reference islands - where two objects hold a reference to each other but all other refs have been cut? From the user's standpoint they may expect GC to take care of those, but the ref counter doesn't actually reach zero. Most interpreters will run into this problem (AFAIK) unless they add some mark & sweep in there.

We have a sweeper, but to my knowledge it actually isn't capable of doing cycle detection. The reference actually tells people though that cycles should be avoided for this reason, so anyone assuming the garbage collector will take care of it is under a false impression.

Lummox JR
In response to Stephen001
Stephen001 wrote:
C++ is typically superceded by Java or C#.NET as a general purpose application language.

I think that's only true to the extent that speed doesn't matter in a large number of apps. Java and C# are both interpreted bytecode. Because BYOND itself has to interpret bytecode, it would be a very bad thing for it to use either of those languages. JIT compilation does help, but I still don't think either of those languages would be acceptable for a system like BYOND.

Lummox JR
In response to Lummox JR
BYOND is hardly a general application, as it's implementing a VM in itself. Commercial tendecies lean to write once run anywhere languages and/or languages that deal with the most common bugs such as memory access violation or basic memory leaks.
In response to Jeff8500
The standard template library is nothing short of wonderful. You should find a reference book for it because it will probably be of more help to you than any other library.
In response to CaptFalcon33035
CaptFalcon33035 wrote:
The standard template library is nothing short of wonderful. You should find a reference book for it because it will probably be of more help to you than any other library.

Yeah, it is useful in many cases, however I didn't know about "boost" until the mention of it in this post, it's quiet good, you can limit the "type" a variable can have or give it access to all types, etc etc.

AFAIK, with templates you can't limit "types".
In response to Haywire
Boost is awesome.
In response to Haywire
Haywire wrote:
Yeah, it is useful in many cases, however I didn't know about "boost" until the mention of it in this post, it's quiet good, you can limit the "type" a variable can have or give it access to all types, etc etc.

Boost is a very useful and interesting set of libraries. I'd suggest digging through the documentation to see libraries that could be relevant to you (for starters, I suggest Smart Ptr). Most of the libraries are template-class headers only (so there are no .lib files to link against), and much of them use templates extensively for optimization (that is, many calculations are done compile-time so there is zero runtime overhead). For more on that topic, I'd refer you to a template-programming book such as C++ Templates: The Complete Guide.

AFAIK, with templates you can't limit "types".

The Boost libraries aren't written with magic. Mostly, they're written using template code.
Page: 1 2