ID:136863
 
It would be cool if byond supported this:

(new .mob.BOB(locate(1,1,1))).name="john"

Thats just an example
(not quite that useful there but I use new all the time like that in java)
var/mob/B = new/mob/bob(locate(1,1,1))
B.name = "John"
In response to Nadrew
I know that.

It would be faster on the cpu for one thing.
(every little bit counts)
In response to Nadrew
Lummox JR you know what I am talking about right?
mob/New(newloc, newname)
. = ..()
src.name = newname

var/mob/m = new(locate(1,1,1), "john")
In response to Air Mapster
ugh. I dont want to do that exact code I put up there.

I was giving an example of another way to use new that byond does not support.
In response to Winbiko
It's called different syntax, not all languages work alike, and they shouldn't.
In response to Nadrew
ya I know. But it would be useful for byond to support that. Because you can save cpu time with that.

plus it really doesnt have anything to do with sytax.
Just how the byond complier handles new.

run that command I put up there and look at the error it give you.
Winbiko wrote:
It would be cool if byond supported this:

(new .mob.BOB(locate(1,1,1))).name="john"

Thats just an example
(not quite that useful there but I use new all the time like that in java)

Thank goodness DM doesn't encourage hard-to-maintain-and-read code like that.

(Yeah I've used such syntax and occasionally it is nice...but mostly it's unreadable and unmaintainable...)
In response to Winbiko
Winbiko wrote:
ya I know. But it would be useful for byond to support that. Because you can save cpu time with that.

plus it really doesnt have anything to do with sytax.
Just how the byond complier handles new.

run that command I put up there and look at the error it give you.

It doesn't save any CPU time at all, it is just a shortcut notation. The CPU must still look up the new object's name var and set it just as it would if there were two separate lines. Just because it's happening behind the scenes does not mean it happens any differently.
In response to Shadowdarke
heh I have always been under the impression it did. oops I guess.
In response to Winbiko
Winbiko wrote:
Lummox JR you know what I am talking about right?

I do, but the tiny bit of savings you're talking about are kind of moot in an interpreted language anyway. I think the syntax you were using would make a lot of sense for something being compiled directly into assembly, but other methods should be about just as fast here.

Still, it's good that you think about optimization, because there are still lots of places where optimization techniques come in mighty handy. I'm still trying to squeeze more speed out of the map generator in Incursion, for instance.

Lummox JR