Re: Reference return buggy notice?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 8:37 AM -0500 10/19/07, Philip Thompson wrote:
I know we went over references (C) in first semester programming. Excuse me
if this is too trivial, but why would you want to use a reference? I thought
in PHP, specifically, that it is unnecessary to use references.

A lil' embarrassed,
~Philip

~Philip:

No need to be embarrassed -- function by reference is not often needed.

Here's an example an example I ran into.

Tiger Geographical data (the stuff of Street Atlas, Google Maps, et al) is a collection of text files that contains long strings (thousands of records) of different record types (255 to be exact) and each record provides data in numerous formats (i.e., byte, unsigned integer, signed integer, short integer, long integer, FP, string, and the list goes on and on). Each record requires a different function to decipher and display the data.

Now, one could just travel down the long string each time determining what data goes to what function and then send the results to the screen along the way. However, that is very time consuming.

The way I solved it was to create a linked list that contained the memory addresses of the data and the memory addresses of the functions that were needed to work together. That way, the list of "what to do" was done only once and stored in a linked list. Please note that the linked list didn't require any decision making.

After that, when the list was initiated (a single call), then a cascade of data matched by functions was done ALL by reference. It was a series of "Here's your data, here's your function, now do your deed" and move on to the next record in the link. That was much quicker than having the program figure it out on the fly.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux