secondlifescripters Digest, Vol 22, Issue 26

Paul Borman sl42 at kryslix.com
Mon Jan 21 14:35:53 PST 2008


> Changing the behavior of things like "+=" need to be taken very  
> carefully. There's scripts out there that depend on the order of  
> evaluation of expressions, and it's really easy to mess those up.  
> Strife Onizuka has heavily promoted one hack that uses
>
>  list = (list = []) + list + something;

I fell for this early on, and used it instead of either the more  
readable:

	list += second_list;
or
	list = list + second_list;

Later I did some timing.  Turns out that using good old += is faster  
than the Onizuka construct.  I don't doubt Onizuka for a moment, but  
things have a habit of changing out from under you.  This is why an  
optimizing compiler (even at the highest level) can help.  It can  
recognize all three constructs and simply always use the one which  
currently is believed to be the best/fastest/etc.

Most languages do not have a good construct for handling events, LSL  
actually does.  At times I wish that events could nest, but I can't  
imagine how many scripts that would probably break (since many  
scripters probably done consider race conditions or memory locks).   
Actually, having an llYield() would be excellent, just watch out for  
your stack size.  It would allow you to have inline RPC between scripts.

	somecode() {
		llMessageLinked(...);
		while (flag == 0)
			llYield();
	}

	...

	link_message(...) {
		process;
		flag = 1;
	}


More information about the secondlifescripters mailing list