Prev: How to pass function names as arguments when function returns an array?
Next: mpi conditional point to point communication
From: Richard Maine on 15 Feb 2010 19:09 Woody <ols6000(a)sbcglobal.net> wrote: > One point of confusion was that I created the module containing only > the interfaces because I didn't want to have the interface code in > more than one place. I resolved this by changing the interfaces from a > module to code that was INCLUDEd in the appropriate places. Yes. I also don't like the verbosity and redundancy of interface bodies. F2003 has ways to avoid that. First, there are abstract interfaces. You can declare an interface by itself without it (yet) being the interface of any particular procedure. I might describe it as being like a derived type, where you declare what the type is like without (yet) being the type of any particular variable. You can later use procedure statements (also new to f2003) to declare procedures to have that interface. That allows you to declare the interface once, but use it multiple times. I see it as particularly useful when one is using procedure pointers. It is also possibel go go further and not even write the interface body once. If you have a procedure with the appropriate interface, you can basically declare something else to have the same interface as the first one. That's another option in the procedure statement. -- Richard Maine | Good judgment comes from experience; email: last name at domain . net | experience comes from bad judgment. domain: summertriangle | -- Mark Twain
From: Richard Maine on 15 Feb 2010 19:14
Woody <ols6000(a)sbcglobal.net> wrote: > I see from what you said that interfaces are often unnecessary when > pgm units are in modules. Slight correction in terminology. It is interface bodies (and interface blocks) that are often unnecessary. You still have the interfaces - they are just there "automatically" without you having to type them out. While that's a bit of a terminology nit, it is one that has caused people to write incorrect code when they get it wrong. They read that an explicit interface is required in some situation, they equate "interface" with "interface body", so they try to write an interface body (even though they have a module procedure), and that does more harm than good. In fact, I recall a draft of one textbook that even got that wrong. It was an old one, and I think that error got fixed before publication. (I think it was a draft I was reviewed and pointed out the error in instead of the first edition; it was long enough ago that memory blurs). -- Richard Maine | Good judgment comes from experience; email: last name at domain . net | experience comes from bad judgment. domain: summertriangle | -- Mark Twain |