ID:161062
 
What happens when you return a value in New()? How would you be able to retrieve the value?
var/datum/something=new(something_or_other)

Doing that gives the something var a reference to that newly created object right? So how is it possible to get a value from New()?

The reason I ask is because I saw something returned in Deadron's BaseCamp library in client/New() and I was wondering why he would ever do that.
Are you talking about this?
client
New()
var/result = ..()
base_Initialize()
return result


All he's doing is returning ..(), although I'm not quite sure why he chose to do it this way when he could have just used .=..() instead.
In response to Nickr5
Yea, that's what I'm talking about. I see no reason in returning a value in the first place if you're not really going to use it, which is why I wonder.
In response to Kakashi24142
Here's the section of the DM reference on it:
New proc (client)
Returns:
The newly connected mob, client.mob, or null to disallow the connection.
Default action:
Look for an existing mob with the same key as the player. If found, connect the player to that mob (mob.Login()). Otherwise, look for a prototype mob with the same key as the player. If found, create a mob of that type and connect the player to it. Otherwise, create a mob of type world.mob, give it the same name and gender as the player's key, and connect the player to it. If TopicData is not null, call client.Topic(TopicData). Finally, the player's mob is returned.

This does nothing when you create an object using new(), but if you later call that object's New() manually the value will return. For example:

Vector
var x, y, z

New(x,y,z)
src.x = x
src.y = y
src.z = z
return GetMagnitude()

proc
GetMagnitude()
return (x*x + y*y + z*z)

mob/verb/test()
var/Vector/vector = new(2,2,2) // returns the new vector
usr << vector.New(2,2,2) // retruns 12


My guess is that Deadron returned the value due to a habit. I tend to return values whenever I can even when it won't do anything.
If you noticed, you don't ever create a /client object yourself with new(). Therefore, that logic does not apply here: client is a special built-in object datatype, and client/New() is a special built-in proc, which is different than the common datum/New() and as such (and this is why there are separate entries for them in the DM Reference, which you should read). I believe client/New() uses the value returned; if you don't return a valid mob to connect the player to, the player will be disconnected.

Remember the majority (or a lot at least) of built-in object procs and vars (I think all built-in lists) are un-ordinary and have special or otherwise out-of-the-norm behavior.

Yes, as 'Peanut said, in a common New() returning has no effect because new() returns the object instance reference rather than New()'s value (bear in mind they are also separate procs).