[J3] [EXTERNAL] Re: Auto-generic & Type-bound question

malcolm at nag-j.co.jp malcolm at nag-j.co.jp
Tue Nov 4 05:37:25 UTC 2025


Hi folks,

Auto-generic type-bound procedures is already in the requirements, with the caveat "if possible".

No-one has spent time on crafting precise specifications, let alone syntax, as this was considered lower priority than getting all the other stuff right.

It does not look impossible on the face of it, in fact it looks quite small (assuming lack of controversy about syntax), but it remains to be seen if there is time to craft specs/syntax/edits.

Cheers,
--
..................Malcolm Cohen, NAG Oxford/Tokyo.

-----Original Message-----
From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Brad Richardson via J3
Sent: Tuesday, November 4, 2025 5:55 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: Brad Richardson <everythingfunctional at protonmail.com>
Subject: Re: [J3] [EXTERNAL] Re: Auto-generic & Type-bound question

I had at one point brought this up. If I recall the answer was that it hadn't even been considered when JP01 was written, and that we didn't have syntax for it. I don't recall anyone else expressing concern with that at the time, but maybe I hadn't made the point obvious enough.

I think Malcolm's ideas for new syntax are probably fine. I'm not quite seeing why the naive syntax couldn't be defined to mean the right thing here, but just food for thought. I.e.

type :: T
contains
  procedure :: tbp_gen_fun => gen_fun
end type

generic function gen_fun(self, x)
  class(T), intent(in) :: self
  type(real, double precision, integer), intent(in) :: x
  type(T) :: gen_fun
end function

There is no reason you couldn't have a passed-object dummy, it simply wouldn't be a generic dummy argument. My above example demonstrates that.

Tom's idea for a deferred type-bound generic really gets tricky though. You'd generally want to be able to define an abstract interface with the auto-generic, but we've forbidden that at this point. That said, you can use the interface from actual procedures to define the interface for deferred type-bound procedures, so you could accomplish the idea by just defining an auto-generic procedure with no executable statements and that is not otherwise used. Whether we agree on syntax for that might be a question though. I.e. given the above definition of gen_fun

type, abstract :: abs_T
contains
  procedure(gen_fun), deferred :: abs_gen_fun end type

I do think all of this is fodder for F203X given our tight time-table.

Regards,
Brad Richardson


On Thursday, October 30th, 2025 at 2:43 PM, Tom Clune via J3 <j3 at mailman.j3-fortran.org> wrote:

> Hi Reuben,
> 
> Again - I’m not advocating any particular position. If Data finds you suggestion “doable” with our tight time constraints, then great.
> 
> My point was merely that up until now, it has always been possible to crate a completely “virtual” abstract base classes. (Quite possibly I’m ignoring some edge cases.). And I suppose even with your suggestion it remains possible, but would require manually specifying all the combinations of interfaces specified by the concrete autogeneric. Obviously this is not essential, but it would be a natural “ask” once your suggestion is accommodated.
> 
> Cheers,
> 
> - Tom
> 
> 
> Sent from my iPad
> 
> > On Oct 30, 2025, at 3:33 PM, Reuben D. Budiardja reubendb at ornl.gov wrote:
> > 
> > Hi Tom,
> > 
> > Sorry I am not following what you were asking (perhaps a concrete / less abstract examples would help ... :D ).
> > 
> > But in any case that seems like a bigger feature / hole to fill in.
> > 
> > I think what I am advocating for is a lot smaller. We just need to make the new feature (auto-generic) "available" to work with the feature we have (type-bound genericity).
> > 
> > Best,
> > Reuben
> > 
> > > On 10/30/25 15:16, Tom Clune wrote:
> > > Without expressing any strong opinion on the matter, I can see that if we plug this not-quite-so-small-hole, then one might ask about abstract base classes? I.e., would we want some way to express a set of abstract auto-generic interfaces with the expectation that concrete subclasses would satisfy (directly or indirectly)? Also seems like a nice thing to do, but a much larger feature.
> > > Have to leave some room for F203x.
> > > Sent from my iPad
> > > 
> > > > > On Oct 30, 2025, at 3:10 PM, Reuben D. Budiardja via J3 j3 at mailman.j3-fortran.org wrote:
> > > > > Thanks Malcolm.
> > > > > I really think we should do this. Otherwise it would seem like a gap in the language. We already have genericity with type-bound procedures so it would make sense that there should be a way to make auto-generic procedures type-bound.
> > > > > I'm perfectly happy with the syntax you suggested (or something similar to that).
> > > > > If we do do this, another question is how should we handle passed-object dummy argument? Should we allow that?
> > > > > Best,
> > > > > Reuben
> > > > > On 10/30/25 01:38, malcolm--- via J3 wrote:
> > > > > No, the PROCEDURE statement requires a specific procedure.
> > > > > And type-bound generics are set of specific type-bound procedures, not a set of specific procedures.
> > > > > We could, in principle, have a type-bound generic that is a 
> > > > > set of anonymous specific type-bound procedures. That would, 
> > > > > however, require different syntax as we already have a meaning for GENERIC :: generic-identifier => binding-name-list viz all the names in that list are specific type-bound procedures.
> > > > > I agree it would be useful.
> > > > > A possible syntax would be
> > > > > GENERIC :: generic-identifier => 
> > > > > GENERIC(generic-subprogram-name) Or just add the form GENERIC(generic-subprogram-name) to the list in the type-bound GENERIC statement we have.
> > > > > It might look a bit ugly, but... I think it would work.
> > > > > Cheers,
> > > > > --
> > > > > ..................Malcolm Cohen, NAG Oxford/Tokyo.
> > > > > -----Original Message-----
> > > > > From: J3 j3-bounces at mailman.j3-fortran.org On Behalf Of Reuben 
> > > > > D. Budiardja via J3
> > > > > Sent: Thursday, October 30, 2025 9:06 AM
> > > > > To: General J3 interest list j3 at mailman.j3-fortran.org
> > > > > Cc: Reuben D. Budiardja reubendb at ornl.gov
> > > > > Subject: [J3] Auto-generic & Type-bound question Hi, I have 
> > > > > questions on auto-generic and type-bound (I failed to ask this clearly in the discussion earlier).
> > > > > 1. Is something like the following part of the feature currently?
> > > > > type :: T
> > > > > ...
> > > > > contains
> > > > > procedure, public, pass :: gensub end type contains generic 
> > > > > subroutine gensub(T, a)
> > > > > class(T) :: T
> > > > > real([real32, real64]) :: a
> > > > > ...
> > > > > end subroutine gensub
> > > > > end type
> > > > > 2. If not (1), is this addition at all feasible? I think it would be useful. Or is this a bad idea?
> > > > > Thanks!
> > > > > Reuben



More information about the J3 mailing list