ID:1832233
 
(See the best response by Lummox JR.)
Code:
 var/x[5]={0,0,0,0,0}


Problem description:

So can I make this work??
Best response
In DM the correct syntax is:

var/x[5] = list(0,0,0,0,0)
// or
var/list/x = list(0,0,0,0,0)

Bear in mind if this is a datum or atom var, not a local var belonging to a proc, it's best if you don't initialize this until you need it. Thus you'd want the declaration to simply be:

var/list/x
Why shouldn't I initialize it?? I only have 6 instances of the class, will it cause significant performance penalty or as a rule of thumb?
It's a performance penalty when objects initialize vars that they don't need to. Like for instance, this is a sure-fire way to cause your game with a big map to take a long time initializing:

turf
var/mylist[0]

Will most turfs ever need that list? Almost certainly not. The act of initializing the var for every turf means:

1) A nameless init proc has been created. Even if you defined turf/New(), the init proc will run alongside it and incur extra overhead.

2) Since all datums don't setup any space for vars until one of their vars is changed from the default for their type, memory has to be allocated to store the var.

3) A new list has to be created.

If that happens for every turf, it gets to be a nightmare. Not great on running time or memory.

For most objects, this kind of thing isn't as big a concern. You'll have way fewer objs in your world than turfs. But it's still best to initialize on demand whenever you can.