![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Array as Parameter Topic Summary: Created On: 3-Sep-2004 17:17 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Wrote a function to modify an input Array. I notice there is no difference when I use the "&" before the name or not: both these behave the same:
void UpdateArray(Array NameArray), and void UpdateArray(Array &NameArray). Anybody got some thoughts on this? - Louie |
|
![]() |
|
![]() |
|
Louie,
As Ron said, the arrays are passed by Reference. If you need to keep the modified and unmodified arrays, you need a function something like: Array UpdateArray(Array inArray) { Array outArray = create(1,1) ..... Assign each cell of the array one by one using for loop Make your modifications to the outArray ..... return outArray } This way, inArray is uneffected, while outArray contains your modifications. Paul |
|
![]() |
|
![]() |
|
well, i know that in c++ arrays as parameter were always handeled as ref.
perhaps in dxl its the same?! greez thomas |
|
![]() |
|
![]() |
|
Hi Louie,
as Thomas already mentioned, the difference is: with & : You will pass a reference to the variable that points to your Array --> so you may modify the original variable, you could create the Array within your function and assign it to the referenced variable. w/o & : You will pass a pointer to the Array to your function --> so you will be able to modify the content of Array, but not the original variable that point to the Array -- that means, if you would try to create the Array within your function, it will be assigned to the local variable only! Remember : Not basic types, like Array, Skip ... will be handled like pointers in DXL, so by their nature, you will able to modify the content without needing the &. Greetings Reik ------------------------- Evosoft GmbH for Siemens Industry Sector Berlin, Germany |
|
![]() |
|
![]() |
|
Had a lot of that stuff way back in PLI in school, but only worked FORTRAN and assembly thereafter. Never had C. But the newer languages just plain screwed up. The calling function should decide whether the called library function has the right to modify any parameter values or not; thus the optional symbol should go with the call and not with the definition of the function. Whether the parameter is a simple one or a complicated one should not matter at all. If a called library function has the ability to modify a call parameter, it would have to deal with the ability to make a copy of the entire structure in case the caller denies modification rights.
The way it is now, calling functions cannot prevent library functions from modifying these values. And while I'm in a bitchy mood, will someone please explain why hot dogs come in packages of 10 while buns in backages of 8? That just chaps my hide... - Louie |
|
![]() |
|
![]() |
|
And while I'm in a bitchy mood, will someone please explain why hot dogs come in packages of 10 while buns in backages of 8? That just chaps my hide...
- Louie That's always bothered me, too, but this makes sense to me - http://www.straightdope.com/classics/a2_350.html ------------------------- Bob Mathis Robert.S.MATHIS@odot.state.or.us |
|
![]() |
|
![]() |
|
From Bulletproof Monk
quote: ------------------------- pete.kowalski(at)motorola.com |
|
![]() |
|
![]() |
|
Actually, a package of 10 buns will tend to droop when held in one hand and is too big anyway, and a package of 8 hot dogs is too small for the typical consumer.
But the real issues are these: [1] What you cut off a cow you call 'steak'; what you then scrape off you call 'hamburger'; what you then squeeze out you call 'hot dogs'. 'Beef by-products' really means 'cow by-products'. [2] 'Hot Dog Buns' have a corresponding relationship with 'Bread'. Once you grasp these realities, the number of buns or dogs in a package is irrelevant. So I lied, it really doesn't chap my hide. - Louie |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Array as Parameter
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.