ID:1502225
 
(See the best response by Kaiochao.)
var/list/exampleList = new/list //Type: /list
var/mob/player //Type: /mob
var/example


What's example's type? Global? World? What? Just wondering.
global. I'm not entirely sure you can define new "world" variables.
it's just a variable with no typeset. They are OF type "var". As far as what it can store... anything you want it to. It can even be a list without being typeset as a list.

For instance, if you have var/mob/player... it's a variable identified as "player", but it's typeset as a mob. So it EXPECTS a mob. However, consider the following:

proc/test()
var/mob/M = new
var/a = M

world << a:type


In this example, a will be a /mob, but the compiler will not know it's a mob. If you run the procedure in your world, it should output /mob.


As for it being "global", that has to do with the scope of the variable, or in otherwords... what has access to the variable.

for instance...

var/myglobalvar = 1

mob/verb/test()
world << myglobalvar


and

mob/verb/test()
var/global/myglobalvar = 1
world << myglobalvar


would essentially do the same thing. The "global" modifier of the variable simply means that anything can access that variable at will.

In response to Koshigia
Oh, I know all of these examples you gave. I'm just questioning what exactly would var/whatever be a type of? Absolutely no type? Or would it be a type of itself? Or type var? It's just a random question that I wanted to discuss.
I believe they're defaulted to null.
proc/test()
var/mob/M = new
var/a = M

world << a:type


have you tried

proc/test()
var/a //or try setting it to "string" and 1 for num.

world << a:type


I'd try it, but I can't right now.
In response to Xirre
Best response
"type" is a variable defined for datums.

Numbers and strings in DM aren't objects and are currently incapable of holding their own variables (such as "type") and procs that would be accessed through the . or : operators.
You don't need a special type var to get the data type of a variable. Instead, you can use the issomething() procs to determine what kind of data a variable is holding.

So, does this proc answer the question?
proc
getdatatype(v)
if(isnull(v)) return "null"
if(isnum(v)) return "number"
if(istext(v)) return "text"
if(istype(v,/datum)||istype(v,/list)||istype(v,/savefile)||istype(v,/client))
return "[v:type]"
if(ispath(v)) return "path"
if(isicon(v)) return "icon"
if(isfile(v)) return "file"
. = "unknown"

Am I missing anything there?
In response to Multiverse7
Yes, it would answer the question I threw in any variable inside there. I didn't bother to thoroughly check all the types.

However, I know there's isarea, isobj and even istype(v,/type)

Kaiochao answers the question in a simple statement. Thank you.
You wouldn't need to check for specific objects like isarea() or isobj() since all types are derived from /datum. You just check istype(v, /datum) to see if something is derived from /datum, which would mean it has a type var that can be easily checked. That's what I did in the above proc.
In response to Multiverse7
I don't think you would need isicon() here. Icons, sounds, and matrices are all datums: /icon, /sound, /matrix.
That may be, but isicon() also catches icons in the form of files.
In response to Multiverse7
Multiverse7 wrote:
You wouldn't need to check for specific objects like isarea() or isobj() since all types are derived from /datum. You just check istype(v, /datum) to see if something is derived from /datum, which would mean it has a type var that can be easily checked. That's what I did in the above proc.

Oh, I didn't see that one. Sorry.
In response to Multiverse7
That's true, forget what I said. I think you're missing lists and maybe savefiles.
In response to Kaiochao
I updated the code.

I thought there was something I was missing. I was also missing clients.

The only thing left should be /world and the mysterious /proc and /verb objects. I haven't done any testing with procs or verbs in object form yet, so I really don't know much about them. It is undocumented, not counting the Red Book.