j3-fortran / fortran_proposals

Proposals for the Fortran Standard Committee
178 stars 15 forks source link

Traits Proposal #142

Closed everythingfunctional closed 4 years ago

everythingfunctional commented 4 years ago

Proposal for traits as a method of enabling more generic programming capabilities.

See #125

everythingfunctional commented 4 years ago

This is just a rough draft. It needs somebody with more experience writing these to help me use the write terms and verbiage, and to make sure we cover all the necessary points.

certik commented 4 years ago

@everythingfunctional thanks for starting this!

We discussed all kinds of aspects at the original issue. Let's start with this:

everythingfunctional commented 4 years ago

So far I haven't specified anything that would force an implementation to use one or the other. I was leaning towards runtime polymorphism though, as it aligns with the current runtime polymorphism already available through inheritance.

I know you were hoping for compile time, but I really think that is better done with templates than traits. I could be persuaded to change it if there is a significant consensus otherwise.

certik commented 4 years ago

So traits and templates interact. I've been learning Rust recently, and I like so far how they did it. Although I am still confused what exactly is compile time and runtime --- I'll write up C++ / Rust rosetta stone to clarify that soon. And I think it will be helpful for our discussions here too. So far it seems to me what Rust did is exactly what we should do in Fortran also, but I still need more time to learn.

In order to move things forward --- I think you can do your best clarifying things the way you see fit in the meantime. That will be helpful either way. I will let you know once I made some progress.

certik commented 4 years ago

Thanks! I am going to merge it now and upload.

certik commented 4 years ago

I uploaded it here:

https://j3-fortran.org/doc/year/20/20-109.txt

(I had to fix up a few things #150.)