-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
datetime and timedelta constructor validation #19
Comments
Or use the new impure elemental... If compiler support exists. Alternatively, do something creative with pointers to allow a state full error stack to be passed around and the check it when the function returns. |
@zbeekman Did not know about this feature. Is it F2008? |
@milancurcic @zbeekman can you elaborate more on both elemental impure procedures and pointers aproach? 🙏 Datetime rocks! My toy project that exploits it is not abbandoned... |
Code example not included due to licensing concerns....
comment about pointer In the end, though, using an error handling class with an error stack is the way to go, IMO. |
@zbeekman Thank you for the summary. At first I felt embarrassed that I missed this in my MRC, but then I realized it's described in the green (new) book which I don't own yet. I still own the blue book (95/2003). :) Anyhow, these are great recommendations. I like the idea of an extensible parent class with error handling methods as a most general and re-usable approach. I will take some time to digest this information. |
Get the green one! (Or see when they're going to publish their next book... maybe Fortran 2015 will be covered) |
@zbeekman I skipped the green book and got the red book last year. :) |
datetime
andtimedelta
contructor function currently do not implement and validation of input arguments to the contructor. For example, thedatetime
contructor needs to validate the following:and raise an exception if any of the above tests fail. Similarly for
timedelta
constructor.Currently, these constructors are implemented as
pure elemental
functions which allows the user to instantiate an array ofdatetime
s ortimedelta
s in a familiar Fortran array syntax. Once the above validations and raising exceptions are implemented, these functions cannot bepure
(norelemental
) anymore, because only animpure
procedure can write to standard output and stop the program. Consequently, this will require implementing a separate version of constructors that will accept arrays as actual arguments, and which will be used for overloading the contructor.The text was updated successfully, but these errors were encountered: