ID:1517570
 
(See the best response by Multiverse7.)
Code:
/proc/test(mob/user)

/proc/test(mob/user as mob)


Problem description:
test(123) is still acceptable arg either of the two
Best response
The "as argument type" format is only used if a verb is called directly as a user command. It should also work for a proc that is added to a verbs list, but that probably isn't what you want.

What you will have to do is check the argument type within the proc itself.
For example:
if(!ismob(user))
CRASH("The argument entered was not a mob.")
else if(!user:client)
CRASH("The argument entered was not a valid user.")

That should conditionally crash the procedure if the argument is found to either not be a mob, or not be a user. CRASH() also outputs the message provided in addition to the debugging output.

I hope this helps.
What you're doing when you put /mob/user is saying that you're going to store a /mob in this argument. However, that is just for the compiler to know what properties and procedures are safe to use on it. It does not automatically verify that you are passing that type to it, which is why overloading is not part of BYOND.
What's the point of using mob/user or anything inside a proc argument?

Edit:
What's the point of using
/proc/test(mob/a)

if you can just
/proc/test(a)
It's to be able to access the argument as though it's that type.

In DM, you essentially need to declare an argument to be of a particular type, to make use of it's procedures, variables etc, via the . operator.
So
/proc/test(a)
var/mob/b = a
b.use()

and
/proc/test(mob/a)
a.use()


is just the same?
Essentially, yes.

Obviously from a readability point of view, the second one has the type within the procedure signature, so you know what it's expecting to receive, which is a big help.
They work the same, yes.

Also when Stephen mentioned that this is specific to the . operator, the other option would be the : operator. This would also give the same - it checks that a path exists at runtime on a. This is not as safe to do though, as the compiler only checks that it exists somewhere in the code, not on the type you're using.

/proc/test(a)
a:use()

Thank you Pirion for explaining about the : operator.