[AccessD] DotNet passing by value

Mike & Doris Manning mikedorism at verizon.net
Fri Aug 26 07:47:44 CDT 2005


When you declare the variable, you can set the default.

Dim bolTest as Boolean = False

Doris Manning
mikedorism at verizon.net

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John W. Colby
Sent: Friday, August 26, 2005 8:34 AM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] DotNet passing by value

Does this imply that it makes a copy of every object before passing a
pointer to that copy of the object?  That seems like a lot of overhead.  And
is there any way to set the default to true "by reference"?  I am accustomed
to "by reference", and know what that means, and am accustomed to thinking
about whether I am modifying the original object.

John W. Colby
www.ColbyConsulting.com 

Contribute your unused CPU cycles to a good cause:
http://folding.stanford.edu/

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Shamil
Salakhetdinov
Sent: Friday, August 26, 2005 8:25 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] DotNet passing by value


John,

AFAIK VBA passes ByVal strings by reference but it first makes the copy of
the string to the heap memory... The same should be true for  VB.NET/C#. So,
one million bytes' length string will be copied to the heap memory and then
passed internally by ref. Heap memory is handled by virtual memory
management system - it should work rather well if one has speedy moderrn
HHDs for automatic swapping...

But of course passing one million bytes long strings as a ByVal parameter
isn't a good idea at all....

> As you know, everything in .net is an object
Yes, everything is an object but scalar types are used internall as they are
usually used in unmanaged systems - this optimization is done by .NET
Framework compilers. When a scalar type has to be treated as an object it is
getting "boxed" - boxing is a  ,NET Framework term:

See also:

Writing Faster Managed Code: Know What Things Cost
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/fastmanagedcode.asp

Shamil

----- Original Message ----- 
From: "John W. Colby" <jwcolby at colbyconsulting.com>
To: "'Access Developers discussion and problem solving'"
<accessd at databaseadvisors.com>
Sent: Friday, August 26, 2005 3:21 PM
Subject: RE: [AccessD] DotNet passing by value


> Oooops...
>
> >.. passing anything else (including strings) by value.
>
> Should have said "by reference", i.e. placing a pointer to the object 
> on
the
> stack.
>
> John W. Colby
> www.ColbyConsulting.com
>
> Contribute your unused CPU cycles to a good cause: 
> http://folding.stanford.edu/
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John W. 
> Colby
> Sent: Friday, August 26, 2005 7:11 AM
> To: dba-vb at databaseadvisors.com; 'Access Developers discussion and
> problemsolving'
> Subject: [AccessD] DotNet passing by value
>
>
> As you might be aware, VB.Net (and I assume the other .net languages 
> as
> well) pass all variables by value.  But what does this mean, and is it
true.
> As you know, everything in .net is an object, even common variables 
> such
as
> an integer or decimal etc.  Passing by value (in other languages) 
> means placing a COPY of the variable (or object in this case) on the 
> stack as
the
> function is called.  In VBA for example, when you pass by value, it 
> really does ONLY for the simple data types, passing anything else 
> (including
> strings) by value.
>
> Imagine passing a string, which could be a million bytes, by value - 
> literally making a copy and passing that into the stack.  IIRC the 
> total stack space for a given program in an Intel machine is something 
> like 128 kbytes which means that passing a single (huge) string by 
> value could
cause
> a stack overflow.  Now DotNet comes along claiming to pass everything 
> by value.  Is this more doublespeak?  And if so, what is the truth?
>
> John W. Colby
> www.ColbyConsulting.com
>
> Contribute your unused CPU cycles to a good cause: 
> http://folding.stanford.edu/
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com





More information about the AccessD mailing list