ID:273693
 
We all know the conventional islist()
proc/islist(list/L)
return (istype(L))


But the problem is...
var/list/K=null
var/N=list()
islist(K) // returns 0
islist(N) //returns 1


I need to know a way to differentiate var/N and var/list/K
not matter what their values are.

EDIT: made some corrections in the code
Simple, "var/N = list()" is just incorrect, don't use it.
In response to Nadrew
Nadrew wrote:
Simple, "var/N = list()" is just incorrect
Not Technically I think.

But I actually had the problem of reseting all var/list/blah of a mob to the value list() if blah was null.

But since normal vars like var/Variable could be null in some cases but I don't want to make it a list.

So what I need is check if any var/list/List is null and if it is then convert it to list()...
and note - I don't manually put List=null, it happens due to some save file loading and stuff... (cannot bother with that since ......)
//You can do
var/A = new/obj
//But that won't be correct

//You have to define variable as list
var/list/N
//And then actually create list, not leave empty "pointer"
var/list/N = list()
In response to Ripiz
From a "green" programming perspective, it's best not to initialize a list until you plan to use it. I get the feeling he's working around a problem that should be solved instead of avoided.

@OP, can you explain the context of this question a little better? I get the feeling you're going about it the wrong way. There's no useful way to check the actual type of a variable at runtime, short of just keeping a list of their names. You could play with initial(), but that would require a generally wasteful use of list() objects. (unless there's some undocumented goodie I don't know about)
In response to DarkCampainger
After my meddling around with var/list/a and var/a probably the only difference I found was the presence of .len.

I had another workaround for this, such as keeping a track of your list variables.

But one important discovery I made is lists cannot be set to their initial(compile-time) values by the initial proc.
Is that supposed to be a bug or is it just the way it is?

more clearly
var/list/List=(1,2,3)
proc/Somefreakinproc()
List=list(1,3,5)
ShowListContents(List) // a basic list content shower
List=initial(List) // doesnt work -- List becomes null on assignment
ShowListContents(List) // a basic list content shower

In response to Soul Sign
I suppose I shouldn't be surprised initial() doesn't work on lists, as they are technically objects.

One idea that crossed my mind was using the implicit path nature of new() to create the type of the variable, but that's both dangerous and only rarely possible.

There's no good way to do what you're asking. Why do you want to do it?
null is not a list. What's your problem?

What is your goal here?
In response to Jemai1
Jemai1 wrote:
null is not a list. What's your problem?

What is your goal here?
Soul Sign wrote:
I had another workaround for this, such as keeping a track of your list variables.
In response to Soul Sign
Soul Sign wrote:
Jemai1 wrote:
null is not a list. What's your problem?

What is your goal here?
Soul Sign wrote:
I had another workaround for this, such as keeping a track of your list variables.

Yea, that is the best alternative. What you are asking for is impossible at the moment.