- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
Many another languages support a very helpful feature: with end with block
Can it one day be realized in Fortran?
Example:
Many another languages support a very helpful feature: with end with block
Can it one day be realized in Fortran?
Example:
[fortran]type TStruct real Value1 real Value2 real Value3 end type type(TStruct) Struct ! long notation
Struct%Value3 = Struct%Value1 + Struct%Value2 ! much better: with Struct Value3 = Value1 + Value2 end with[/fortran]
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The associate cosntruction is what you are after, but it is more general than just such a "with" construction.
It was introduced in Fortran 2003.
The example could become:
associate( s => struct )
s%value3 = s%value1 + s%value2
end associate
but it gets its power from:
associate( s1 => struct, s2 => someOtherStruct, s3 => aThirdOne )
...
end associate
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thank you very much for answer. I was not able to reply for a long time.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page