Accessibility-check for GENERIC bindings' targets

This is a discussion on Accessibility-check for GENERIC bindings' targets within the Fortran forums in Programming Languages category; Hi, I just stumbled upon this problem: MODULE m1 TYPE t1 CONTAINS PROCEDURE, NOPASS, PRIVATE :: proc END TYPE t1 CONTAINS SUBROUTINE proc () END SUBROUTINE proc END MODULE m1 MODULE m2 TYPE, EXTENDS(t1) :: t2 CONTAINS GENERIC :: gen => proc END TYPE t2 END MODULE m2 Is the GENERIC binding invalid as it targets a PRIVATE specific binding? Or is this allowed in this case? I couldn't find anything about this in the draft F2003 standard's section about type-bound procedures. If the code was valid, this would mean that any PRIVATE type-bound procedure can be made accessible by ...

Go Back   Application Development Forum > Programming Languages > Fortran

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-31-2008, 04:06 AM
Daniel Kraft
Guest
 
Default Accessibility-check for GENERIC bindings' targets

Hi,

I just stumbled upon this problem:

MODULE m1

TYPE t1
CONTAINS
PROCEDURE, NOPASS, PRIVATE :: proc
END TYPE t1

CONTAINS

SUBROUTINE proc ()
END SUBROUTINE proc

END MODULE m1

MODULE m2

TYPE, EXTENDS(t1) :: t2
CONTAINS
GENERIC :: gen => proc
END TYPE t2

END MODULE m2

Is the GENERIC binding invalid as it targets a PRIVATE specific binding?
Or is this allowed in this case? I couldn't find anything about this
in the draft F2003 standard's section about type-bound procedures.

If the code was valid, this would mean that any PRIVATE type-bound
procedure can be made accessible by extending the type and defining
there a PUBLIC GENERIC binding targetting it, wouldn't it?

Thanks,
Daniel

--
Done: Arc-Bar-Cav-Sam-Val-Wiz, Dwa-Elf-Gno-Hum-Orc, Law-Neu-Cha, Fem-Mal
To go: Hea-Kni-Mon-Pri-Ran-Rog-Tou
Reply With Quote
  #2  
Old 08-31-2008, 04:08 AM
Daniel Kraft
Guest
 
Default Re: Accessibility-check for GENERIC bindings' targets

Daniel Kraft wrote:
> MODULE m1
>
> TYPE t1
> CONTAINS
> PROCEDURE, NOPASS, PRIVATE :: proc
> END TYPE t1
>
> CONTAINS
>
> SUBROUTINE proc ()
> END SUBROUTINE proc
>
> END MODULE m1
>
> MODULE m2


USE m1 here of course, sorry for the mistake.

> TYPE, EXTENDS(t1) :: t2
> CONTAINS
> GENERIC :: gen => proc
> END TYPE t2
>
> END MODULE m2
>
> Is the GENERIC binding invalid as it targets a PRIVATE specific binding?
> Or is this allowed in this case? I couldn't find anything about this
> in the draft F2003 standard's section about type-bound procedures.
>
> If the code was valid, this would mean that any PRIVATE type-bound
> procedure can be made accessible by extending the type and defining
> there a PUBLIC GENERIC binding targetting it, wouldn't it?


Thanks,
Daniel

--
Done: Arc-Bar-Cav-Sam-Val-Wiz, Dwa-Elf-Gno-Hum-Orc, Law-Neu-Cha, Fem-Mal
To go: Hea-Kni-Mon-Pri-Ran-Rog-Tou
Reply With Quote
  #3  
Old 08-31-2008, 04:13 AM
Richard Maine
Guest
 
Default Re: Accessibility-check for GENERIC bindings' targets

Daniel Kraft <d@domob.eu> wrote:

> Is the GENERIC binding invalid as it targets a PRIVATE specific binding?


No, that would not be a reason for it to be invalid.

> If the code was valid, this would mean that any PRIVATE type-bound
> procedure can be made accessible by extending the type and defining
> there a PUBLIC GENERIC binding targetting it, wouldn't it?


Private things can be made accessible in many ways. It is a fundamental
error to think that the private atribute on something means that the
entity cannot be accessed outside of the module.

The *ONLY* thing that the private attribute does is prevent the export
of the particular identifier (usually a name). It does *NOT* prevent
access to the inderlying entity by any other means that might happen to
not require using the identifier in question outside of the module.

For a trivial example, one could have an entity whose name is declared
private, but which is also the target of a public pointer. There are
other ways as well.

Another way of expressing this is that the private attribute attaches
only to the identifier(name), rather than to the underlying entity.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
Reply With Quote
  #4  
Old 08-31-2008, 04:24 AM
Daniel Kraft
Guest
 
Default Re: Accessibility-check for GENERIC bindings' targets

Richard Maine wrote:
> Daniel Kraft <d@domob.eu> wrote:
>
>> Is the GENERIC binding invalid as it targets a PRIVATE specific binding?

>
> No, that would not be a reason for it to be invalid.
>
>> If the code was valid, this would mean that any PRIVATE type-bound
>> procedure can be made accessible by extending the type and defining
>> there a PUBLIC GENERIC binding targetting it, wouldn't it?

>
> Private things can be made accessible in many ways. It is a fundamental
> error to think that the private atribute on something means that the
> entity cannot be accessed outside of the module.


Thanks Richard, your explanation was exactly what I was looking for! I
already supposed that the code was valid but wanted to get some opinions
on it (as I wouldn't really claim I know F2003 well).

Yours,
Daniel

--
Done: Arc-Bar-Cav-Sam-Val-Wiz, Dwa-Elf-Gno-Hum-Orc, Law-Neu-Cha, Fem-Mal
To go: Hea-Kni-Mon-Pri-Ran-Rog-Tou
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 03:28 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.