Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Array as Parameter
Topic Summary:
Created On: 3-Sep-2004 17:17
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 3-Sep-2004 17:17
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

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
Report this to a Moderator Report this to a Moderator
 7-Sep-2004 13:18
User is offline View Users Profile Print this message


Paul Howstan

Posts: 4
Joined: 29-Jun-2004

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
Report this to a Moderator Report this to a Moderator
 28-Jul-2006 12:12
User is offline View Users Profile Print this message


Thomas Langholz

Posts: 40
Joined: 20-Oct-2005

well, i know that in c++ arrays as parameter were always handeled as ref.
perhaps in dxl its the same?!

greez

thomas
Report this to a Moderator Report this to a Moderator
 28-Jul-2006 12:38
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

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
Report this to a Moderator Report this to a Moderator
 9-Aug-2006 00:38
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

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
Report this to a Moderator Report this to a Moderator
 9-Aug-2006 14:04
User is offline View Users Profile Print this message


Bob Mathis

Posts: 32
Joined: 12-Apr-2005

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
Report this to a Moderator Report this to a Moderator
 9-Aug-2006 15:25
User is offline View Users Profile Print this message


Pete Kowalski

Posts: 301
Joined: 7-Feb-2003

From Bulletproof Monk

quote:


why do hot dog's come in packages of 10 while hot dog buns come in backages of just 8

Easy!
Because you say to yourself one day, that you would really love a hot dog.

So you wander into your local supermarket and end up buying 10 hot dogs and 8 buns: you only really wanted one, but hey: you're really hungry.
After a short period of eating hotdogs you have eaten eight of them and have two left over, but no buns! What to do! A dilly of a pickle, if ever there was one! Then it dawns on you! Another packet of buns.
Next day you realise that you have 6 bread buns, but nothing to put in them. Another conundrum. Soon you figure out a way around this impasse: another pack of hot dogs! Down to the local supermarket, and a few minutes later you are the proud owner of 10 shiny new hot dogs.
Six ketchup and mustard smothered snacks later, you run out of buns, with 4 hot dogs to go! This time it doesn't take you long to figure out the solution!
Another trip to the supermarket and four hot dogs later, you find yourself with a surplus of 4 buns.
Another pack of ten hot dogs. Another four delicious meals later. Another six left-over hot dogs.
To the supermarket! A pack of 8 bread rolls! Six tasty bread covered sausages! Two lonely bread rolls!
Back once more to the supermarket for another packet of hot dogs. Two quickly devoured hot dogs, and a remainder of eight naked frankfurters. One last pack of hot dogs rolls, and the job is complete.

So, next time you feel like having a hot dog, you must realise that you are getting yourself into a lot more than you bargained for. You are committing yourself to the eventual purchase of forty times what you had originally planned for! In short; it's all a conspiracy to take your money and make you fat.


-------------------------
pete.kowalski(at)motorola.com
Report this to a Moderator Report this to a Moderator
 10-Aug-2006 00:22
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

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
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.