-
Notifications
You must be signed in to change notification settings - Fork 17
Introduce "auto" #129
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
Comments
@pklausler, mentioned that How would the syntax work? Maybe like this: auto, integer :: a = expr, b = expr, ...
auto, real :: x = 3.14159 perhaps also like this: integer, auto :: a = expr, b = expr, ...
real, auto :: x = 3.14159 So it would act like the |
I think, having
work? As for the second comment, I don't see the use case for specifying the type together with the |
Features like this really get back to the question: For whom Fortran? Should the consensus be Fortran is for certain (a limited set?) practitioners doing their computing in a manner (say individual development and/or small/isolated teams and/or much longer timescales than viewed by managers wanting "agile development") such that forcing certain verbosity and redundancy in coding instructions are to be always considered a desired "feature" of the language, then there can be a fair argument to ignore type inference facilities such as with However if Fortran is to be viewed more broadly as being suitable for large new applications also, even in the scientific and technical computing domains, and where the development may span many large teams with huge number of coders and pressing schedules and so forth, then the language development needs to keep an open mind and consider a 'bigger tent' approach. That is, support those wanting explicit typed declarations (as is the case now) but also allow type inferencing. Consider for example, the development of a 'modern' process simulator of chemical manufacturing facilities costing $$ billions with extensive handling of massive amounts of data in addition to intensive numerical computations: languages supporting features such as the ones introduced in C++ starting their C++11 revision thru' C++14, C++17, and soon C++20 (including with type inference and |
@FortranFan I can see both sides and I don't currently know if we should have it or not. As I posted in #40, I use C++ often, and I do not like the More generally, I think |
I think I would disagree, that no explicit listing of the type makes the code necessarily much less readable for two reasons:
However, there are no powerful native Fortran IDEs out there. I for instance use Clion with the Fortran plugin, which works okayish, but not as good as for C++ (especially the refactoring) |
@libavius I think you would agree that with no explicit typing, you need an IDE to help you. We should (and we will) have an IDE for Fortran, for example Flang or LFortran will in the future provide the language server for VSCode. But there is a beauty of not needing an IDE to write and to read code. That's what I mean by simple. |
@certik the prospect of a Fortran IDE sounds really promising =). I agree, that in many cases, explicit typing improves readability. In addition to the IDE stuff, I wanted to point out, that this is not necessarily always the case and that good naming can (sometimes) make explicit typing redundant. The option of having an |
It's not all-or-nothing, IDE or not (I do all my programming with a simple editory). Haskell programmers know the power of type inference and are accustomed to adding explicit type signatures where they improve readability, and avoiding them when they don't, for example. And C++ programmers learn where |
@klausler I think you are right. As long as we provide guidelines how to use |
My understanding is that one of the biggest powers of |
But sometimes it's great to have around just to save some completely redundant verbiage in C++. |
auto is very useful in C++, but I see few situations where it will be well employed in Fortran. Let's see some examples in C++:
auto was introduced in C++11 when generic programming was already well settled down, so it found a plethora of good places to be used, while, in Fortran, I don't see it will be really useful. I do believe Fortran needs support for generic programming as a scientific computing language, which is supposed to translate algorithms, not just formulas, but for the moment that is not the case. |
In a sense, Fortran already does have something roughly equivalent to
|
Just in case it helps the discussion, there is an excelent talk by Herb Sutter on CppCon 2014 where he discuss several situations where it is a good practice to employ auto: https://youtu.be/xnqTKD8uD64?t=1703 . |
Introduced by @pklausler at #40 (comment):
Golang has
var := expr;
which declaresvar
to have the type of the value ofexpr
, which is also assigned to it. The fact that an initializing declaration must necessarily have an expr does make the explicit type somewhat redundant on the statement. So I suggestAUTO :: a = expr, b = expr, ...
andAUTO, POINTER :: p => target, ...
.Further examples:
The text was updated successfully, but these errors were encountered: