How's this done with the new system? I am not an expert on this, but I have the feeling that adding new syntactic features that don't really add much functionality-wise, might confuse GM users.
So, how would such a system work exactly? When using
mylist = ds_list_create(); mylist.insert( 1, myvalue ); mylist.destroy();is mylist a local variable holding the list index? Which means that mylist is stored in some instance. So we can do
(other.mylist).insert(1, value)?Also, can I store the list index in a(nother) variable? E.g. can I now say
var li; li = choose(mylist1, mylist2) li.insert(1, value)
What would show_debug_message(mylist) do? Can I store the list index in a variable? Also can several instances each have their own mylist (e.g. if I want every enemy instance contain a list of visited nodes)? Can I pass the variable to another instance, e.g. when an enemy wants to know if the enemy it collides with has visited node X)? Can I make a list whose index is global? And how would this be indicated? I'm guessing
(global.mylist).insert(1, myvalue)How can I make my own script for lists? With the current setup I can make a ds_list_swap and have the list index as argument0 and I can then just do
//ds_list_swap(ind, pos1, pos2) var temp; temp = ds_list_find_value(argument0, argument1) ds_list_replace(argument0, argument1, ds_list_find_value(argument0, argument2)) ds_list_replace(argument0, argument2, temp)With the proposed list syntax, how would such a swap script be defined in GML, in such a way that we can use mylist.swap(pos1, pos2)? Could you give an example of that?
Finally, can we have something like
mylist.typeto find out whether it's a list or a stack, instance, resource, particle type, etc.? E.g. by using
if mylist.type = ds_list
{
//code to execute if mylist is a list
}where ds_list is a built-in constant?Edit: also, what about an existence check? You cannot do
mylist.exists()because if mylist doesn't exist, I would expect an unknown variable error. If this error won't appear, this would be an inconsistency in the system, because right now it's a rule in GML that everything to the left of a dot, has to be defined.
As you can see, this whole concept raises a lot of questions I'm really not sure about. And that while the current system seems to work fine for me (or at least not worse than the proposed system).
Edited by Erik Leppen, 25 January 2011 - 07:33 PM.



This topic is locked









