[J3] [EXTERNAL] Elemental type-bound functions not useful

Van Snyder van.snyder at sbcglobal.net
Tue Mar 30 02:49:41 UTC 2021


An alternative to type extension is very old: Embedding. Instead of
extending a type, create a new type with a component of the "base"
type. One important difference is that there's no run-time dispatch,
but maybe that's a good thing.
Years ago, Leslie Hatton wrote a paper "Does OO sync with the way we
think?" Maybe not.
On Mon, 2021-03-29 at 18:32 -0700, Damian Rouson wrote:
> On Mon, Mar 29, 2021 at 6:11 PM Van Snyder via J3 <
> j3 at mailman.j3-fortran.org> wrote:
> > Fortran doesn't yet have "sealed" or "inextensible" types (unless I
> > missed something that prevents creating an extension type).
> 
> One can prevent type extension by declaring a type-bound generic
> procedure with the same name as the name of the type as one might do
> to effectively write a type-bound, user-defined structure
> constructor:
> 
> type foo
> contains
>   procedure :: foo_constructor
>   generic :: foo => foo_constructor
> end type 
> 
> My thoughts are aligned with those of Tom and Vipul.   Once Fortran
> supports generic programming, I suspect it will displace type
> extension for most of my purposes. For now, I strive to limit type
> extension to extending abstract types. We sometimes have a non-
> abstract type extending an abstract type that extends another
> abstract type, but that's as deep as our hierarchies go in practice. 
> We frequently combine type extension with type-bound operators, but
> I'm not crazy about the type-guarding that this approach requires. It
> feels like the developer is being burdened with ensuring runtime type
> safety as a stand-in for compile-time type safety, which is why I
> suspect I'll replace type extension with generic programming. 
> 
> Damian
> 
> 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20210329/47f43d72/attachment.htm>


More information about the J3 mailing list