I still have a lingering sense that using pointers to variables imposes a noticeable speed penalty on code execution time. It's an old sense. I was just thinking about it while using a simple method I have for doing Increments. It's called Increment, takes a pointer to a var and adds 1 to it.
$1->:=$1->+1 Because we don't have += in 4D. I don't know why. I wondered how much time it takes to de-reference the pointer. I wrote a couple of loops and iterated 100k times. Interpreted the difference was larger than I expected. $n:=$n+1 ~49ms Increment(->$n) ~3800ms Ok, I thought, so for a loop like that I stick to direct referencing the vars. How much effect does compiling have? A lot. $n:=$n+1 ~0ms Increment(->$n) ~50ms This is with v15.5 running on a 1 year old MacBookPro. Ten iterations per test case. So it's true using pointers instead of directly referencing variables takes more time. Of course we're talking about 100k operations here. That would really matter on large calculations performed 100s of times. For anything involving direct interface with the user, though, I don't think it's really a factor. BTW, you can get around the 'pointer penalty' by using local vars directly and then copying the results to the pointed to object. This makes a noticeable difference if you are doing things like filling arrays on the server. Say I've got a method to look up some stuff and then populate 5 arrays which I pass to the method as pointers. At size it becomes faster to declare the arrays in the method, fill them and then use COPY ARRAY to copy to the pointed to arrays. -- Kirk Brooks San Francisco, CA ======================= *The only thing necessary for the triumph of evil is for good men to do nothing.* *- Edmund Burke* ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

