Sign in

username:

password:



Not a member?

Search oopic



Search tips

Subscribe to oopic



Ads

Discussion Groups

Discussion Groups | | call by reference

call by reference - Brian Lloyd - Mar 10 0:47:49 2008

I have a function that I need to return two values, one in the=20=20
function name itself and one as a parameter. How do I pass a pointer/=20
address and how do I dereference a pointer inside my function? I can't=20=20
find this anywhere in the manual or in Dan's book.

Yes, I could use a global variable but I would prefer not to.

--

Brian Lloyd Granite Bay Montessori
brian AT gbmontessori DOT com 9330 Sierra College Blvd.
+1.916.367.2131 (voice) Roseville, CA 95661, USA
http://www.gbmontessori.com

I fly because it releases my mind from the tyranny of petty things . . .
=97 Antoine de Saint-Exup=E9ry

PGP key ID: 12095C52A32A1B6C
PGP key fingerprint: 3B1D BA11 4913 3254 B6E0 CC09 1209 5C52 A32A 1B6C

=20

=20


(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )


Re: call by reference - ooPIC Tech Support - Mar 10 3:24:03 2008

Pointers do not exist in the ooPIC "world view". The simplest way (and
perhaps the only way) is to use a global variable. It is not as pretty
as using a reference in the argument list, but philosophically they are
both side-effects, so...

DLC

Brian Lloyd wrote:
> I have a function that I need to return two values, one in the
> function name itself and one as a parameter. How do I pass a pointer/
> address and how do I dereference a pointer inside my function? I can't
> find this anywhere in the manual or in Dan's book.
>
> Yes, I could use a global variable but I would prefer not to.
>
> --
>
> Brian Lloyd Granite Bay Montessori
> brian AT gbmontessori DOT com 9330 Sierra College Blvd.
> +1.916.367.2131 (voice) Roseville, CA 95661, USA
> http://www.gbmontessori.com
>
> I fly because it releases my mind from the tyranny of petty things . . .
> — Antoine de Saint-Exupéry
>
> PGP key ID: 12095C52A32A1B6C
> PGP key fingerprint: 3B1D BA11 4913 3254 B6E0 CC09 1209 5C52 A32A 1B6C
>
>
>



(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )

Re: call by reference - Brian Lloyd - Mar 10 13:42:39 2008


On Mar 9, 2008, at 11:50 PM, ooPIC Tech Support wrote:

> Pointers do not exist in the ooPIC "world view".

Ah. That probably explains why I can't find a reference to reference.

> The simplest way (and
> perhaps the only way) is to use a global variable.

I was trying to avoid that, especially when explaining things to my
students. I try not to use shortcuts because I want them to learn good
programming practices from the beginning.

> It is not as pretty
> as using a reference in the argument list, but philosophically they
> are
> both side-effects, so...

I agree. It is a just an elegance thing.

Brian Lloyd
Granite Bay Montessori School 9330 Sierra College Bl
brian AT gbmontessori DOT com Roseville, CA 95661
+1.916.367.2131 (voice) +1.791.912.8170 (fax)

PGP key ID: 12095C52A32A1B6C
PGP key fingerprint: 3B1D BA11 4913 3254 B6E0 CC09 1209 5C52 A32A 1B6C



(You need to be a member of oopic -- send a blank email to oopic-subscribe@yahoogroups.com )