ID:142937
 
Code:
obj
Test
New(id as num)
world << "A new thing with ID: [id]"
New()
world << "A new thing with random ID: [rand(100)]"


Problem description:
Begin Useless Background:
I must admit, I've been away from DM for a long time. So, I'm quite out of practice. With 4.0 and a few other changes, I've decided to come back and explore it as an alternative for one of my projects. However, I have ran in to a problem with overloading.
End Useless Background:

Is there a way to do this in DM? Whenever I make a new object it always calls the last New proc and not the one that correlates to the args. I realize that doing this wouldn't be to hard with if statements and stuff, just that defeats the purpose of why I am doing it.

Why do you have two New() statements? You should really only ever need one.

You're wanting to make two objects one with an ID set by the user and another with a random ID, then you'd be looking to do something like this:
obj
Bleh
var
id = 0

mob
verb
Make_ID(d as num)
var/obj/Bleh/A = new
A.id = d
world << "My [A.name]'s ID is [A.id]"

Random_ID()
var/obj/Bleh/A = new
A.id = rand(100)
world << "My [A.name]'s ID is [A.id]"


And you should be using the parent in your obj/New().

In response to Tiberath
The object was just an example, in my actual system its not inheriting any specific type so it's unimportant. Yes, I realize that in this specific example that would be a simple solution. But, like I said this was a quick example and not the actual problem. Most languages allow overloading, it allows for a few nice ways of doing things. If I can't do it then I suppose having if statements in the New proc is the best I can do. This just seems like much more of headache.

Also, on a side note, if this is not possible shouldn't the compiler at least give a warning that there are two definitions of new and only the most recent one will be used?
In response to DoOmBringer
obj
Bleh
New()
world << "I have a random ID: [rand(100)]"
..()

New()
world << "I have a static ID: 1"
..()

mob
verb
Make_ID()
var/obj/Bleh/A = new
world << A


My tests show both are working. You didn't call the parent originally, this is a must.
In response to Tiberath
The issue is, that in a sense all I'm doing is calling the other one from within. Which means both get executed. I only want the one with the proper method signature to get executed. I've decided byond doesn't support this. Its most likely due to the added complexity it would require with the compiler. So, I'll just go around it and call specific methods that are "False" New() after creation.
There's no way to overload procs in DM. The best you can do is mess around using the is*() collection of procs on the arguments to try to figure out how the proc is being called. You can also use the args list. So, for example, you can achieve the effect you want like so:

obj/Test/New(var/id)
if(args.len)
world << "A new thing with ID: [id]"
else
world << "A new thing with random ID: [rand(100)]"


However, this does not lend itself to clean-looking code, especially when you're trying to do something more complex.