I'm still confused about pointers 
Author Message
 I'm still confused about pointers

As a fortran programmer with a few weeks under forty years of
experience with FORTRAN, I have finally encountered a problem which
requires pointers.

INTEGER, POINTER :: DART1
INTEGER, POINTER :: DART2
INTEGER, TARGET :: BOARD
INTEGER, TARGET :: BULL

DART1 => BOARD
DART2 => BOARD

Assuming that BOARD is inaccessible, except via DART1 and DART2, can I
assign a new value to it?

I have assumed that if I execute

DART1 => BULL

DART2 would then still refer to BOARD

Thanks in advance

Dave Flower



Fri, 28 Nov 2008 19:50:48 GMT  
 I'm still confused about pointers


Quote:

> I have assumed that if I execute

> DART1 => BULL

> DART2 would then still refer to BOARD

That's true. For instance, run the following:

INTEGER, POINTER :: DART1
INTEGER, POINTER :: DART2
INTEGER, TARGET :: BOARD
INTEGER, TARGET :: BULL
board = 2
DART1 => BOARD
DART2 => BOARD
print *, dart1, dart2
bull = 3
dart2 => bull
board = 4
print *, dart1, dart2
end

But what do you mean by board being inaccessible? In a module and private?

Regards,

Mike Metcalf



Fri, 28 Nov 2008 20:17:10 GMT  
 I'm still confused about pointers

Quote:



> > I have assumed that if I execute

> > DART1 => BULL

> > DART2 would then still refer to BOARD

> That's true. For instance, run the following:

> INTEGER, POINTER :: DART1
> INTEGER, POINTER :: DART2
> INTEGER, TARGET :: BOARD
> INTEGER, TARGET :: BULL
> board = 2
> DART1 => BOARD
> DART2 => BOARD
> print *, dart1, dart2
> bull = 3
> dart2 => bull
> board = 4
> print *, dart1, dart2
> end

> But what do you mean by board being inaccessible? In a module and private?

> Regards,

> Mike Metcalf

Neither, it is a variable (might be local, module or COMMON) in a
separate routine, that cannot be passed as an argument

Dave Flower



Fri, 28 Nov 2008 20:31:04 GMT  
 I'm still confused about pointers


Quote:
> > But what do you mean by board being inaccessible? In a module and private?

> Neither, it is a variable (might be local, module or COMMON) in a
> separate routine, that cannot be passed as an argument

This is just a warning.  Whatever the reasons are that you cannot
pass the original variable as an argument, those same reasons may
apply also to a pointer to that variable.

$.02 -Ron Shepard



Fri, 28 Nov 2008 22:29:04 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Re-confused about ALLOCATE, ASSOCIATE, POINTER, TARGET ...

2. Embedded C++, confused about the self pointer/init

3. confused if i should be doing type checking in the code ( a confused java programmer)

4. confused if i should be doing type checking in the co de ( a confused java programmer)

5. 3D Scanners vs. Digital Stills

6. I'm *so* confused....

7. I'm confused

8. Confused about So many different Oberon's

9. Now I'm really confused!

10. I'm Very Confused

11. I'm confused about USAGE and internal storage

12. I'm confused!

 

 
Powered by phpBB® Forum Software