Hi all,
Quick question: If I have a function which populates a large array (ie.
reading rowsets), is it better to pass in a reference to a variable to
accept the data, or should I just create, populate and return the array
from the function?
Thanks in advance! 3 1877
Passing reference is preferred because passing an array back is seen as
more of a 'hack'
TeejB wrote:
Hi all,
Quick question: If I have a function which populates a large array (ie.
reading rowsets), is it better to pass in a reference to a variable to
accept the data, or should I just create, populate and return the array
from the function?
Thanks in advance!
I guess the question is: will PHP optimize this for me so that the
entire contents aren't copied out of the function, or do I have to pass
in a reference?
Benjamin wrote:
Passing reference is preferred because passing an array back is seen as
more of a 'hack'
TeejB wrote:
Hi all,
Quick question: If I have a function which populates a large array (ie.
reading rowsets), is it better to pass in a reference to a variable to
accept the data, or should I just create, populate and return the array
from the function?
Thanks in advance!
You have to pass a reference.
TeejB wrote:
I guess the question is: will PHP optimize this for me so that the
entire contents aren't copied out of the function, or do I have to pass
in a reference?
Benjamin wrote:
Passing reference is preferred because passing an array back is seen as
more of a 'hack'
TeejB wrote:
Hi all,
>
Quick question: If I have a function which populates a large array (ie.
reading rowsets), is it better to pass in a reference to a variable to
accept the data, or should I just create, populate and return the array
from the function?
>
Thanks in advance!
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Randell D. |
last post by:
Folks,
I've asked this before but never got any response but its important and I
thought I'd pitch it again (hopefully a bit clearer)...
One can pass data from one function to another either by passing a copy, or
passing by reference.
My understanding of passing by reference (putting the & before a variable
during the function declaration) means that the original data is used.
|
by: Doug Jordan |
last post by:
I am fairly new to Python. This should be an easy answer but I cannot get
this to work. The code is listed below. I know how to do this in C,
Fortran, and VB but it doesn't seem to work the same way here.
I would appreciate any help.
#try this to pass a list to a function and have the function return
#a variable
#this works
list=
def fctn(c):
|
by: dumboo |
last post by:
hi there
i m little bit confused over the following problem, i have understood wt the
following code is doing...but not able to get the actual techinical
stuff.....i have had a lot of hot debate over the following code whether its
pass by reference or pass by value...hope somebody clears it up :-)
void foo(char *s)
{
s = new char;
strcpy(s, "gotit");
}
|
by: Mr A |
last post by:
Hi!
I've been thinking about passing parameteras using references instead
of pointers in order to emphasize that the parameter must be an
object.
Exemple:
void func(Objec& object); //object must be an object
instead of
|
by: Sean Dockery |
last post by:
I have the following HTML file that I've been using for testing...
<html>
<head>
<script type="text/javascript">
<!--
function handleWindowLoad() {
var items = ;
for (var i = 0; i < 11; i++) {
items = "item" + (i + 1);
| |
by: David++ |
last post by:
Hi folks,
I would be interested to hear peoples views on whether or not 'pass by
reference' is allowed when using a Web Service method.
The thing that troubles me about pass-by-reference into a WebService is that
essentially we are passing an address of an object which resides on the
'local machine' i.e. a local machine object address. Surely when the
WebService method is called and run 'on the server', the reference type will
be...
|
by: lisp9000 |
last post by:
I've read that C allows two ways to pass information between
functions:
o Pass by Value
o Pass by Reference
I was talking to some C programmers and they told me there is no such
thing as pass by reference in C since you are just passing an address
(or a pointer value address I guess?). So I was wondering is this
correct?
|
by: Siegfried Heintze |
last post by:
Why does VB.NET V2 force me to pass by value for my set function? When I try
to change it to const byref it gives me a syntax error. It seems very
inefficient to be passing strings around by value when a reference to a
constant string object will do fine (all we are going to do is copy it). In
my case, would the byval for the set function cause a superfluous copy?
Thanks,
Siegfried
class person
dim m_name as string
|
by: Bryan Parkoff |
last post by:
I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline. I define variables and functions in the global scope. The global
variables and global functions are hidden to prevent from accessing by the
programmers. All global functions share global variables.
Only very few global functions are allowed to be reusability for the
programmers to use. Few...
|
by: raylopez99 |
last post by:
Keywords: scope resolution, passing classes between parent and child
forms, parameter constructor method, normal constructor, default
constructor, forward reference, sharing classes between forms.
Here is a newbie mistake that I found myself doing (as a newbie), and
that even a master programmer, the guru of this forum, Jon Skeet,
missed! (He knows this I'm sure, but just didn't think this was my
problem; LOL, I am needling him)
If...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |