fortran-language-server icon indicating copy to clipboard operation
fortran-language-server copied to clipboard

allow dotted syntax for derived type member variables

Open michaelkonecny opened this issue 6 years ago • 5 comments

I realise this is a non-standard extension, however, it's quite wide-spread and I prefer it to the percent symbol, simply because of much better readability.

type mytype
    integer :: member1
    integer :: member2
end type

type(mytype) :: mytypeInstance

mytypeInstance%member1 ! go to definition works fine here
mytypeInstance.member2 ! this is not recognised properly

It should at least be an option for people who have grown accustomed to this syntax.

michaelkonecny avatar Sep 07 '18 22:09 michaelkonecny

I would certainly consider supporting this feature (optionally), but I have never seen it used personally. Do you know what compilers support it? I couldn't find any documentation on it with a quick internet search (Intel/GCC).

hansec avatar Sep 07 '18 22:09 hansec

I use it with Intel, not sure about GCC. Intel won't even issue any warnings unless you use the -stand compiler flag as per this discussion: https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/539584

michaelkonecny avatar Sep 08 '18 00:09 michaelkonecny

I hesitate to add this feature since not only is it a non-standard extension but it is not officially documented either. I agree that the dotted syntax is cleaner and it does appear to be used in some fields. However, I don't think the language server should include support for any extensions that aren't at least a documented part of one of the main compilers (Intel, GCC, Cray, etc.).

I will leave this issue open for discussion. If a lot of people find this useful I am not strongly opposed to adding it.

hansec avatar Sep 10 '18 15:09 hansec

I understand.

I will probably just fork the server and add this for my personal use meanwhile, as I don't want to change all my code.

michaelkonecny avatar Sep 10 '18 19:09 michaelkonecny

It works under ifort without any additional options. In gfortran one needs to enable "DEC compatibility mode". From the documentation:

-fdec-structure Enable DEC STRUCTURE and RECORD as well as UNION, MAP, and dot (’.’) as a member separator (in addition to ’%’). This is provided for compatibility only; Fortran 90 derived types should be used instead where possible.

PaulXiCao avatar May 19 '19 12:05 PaulXiCao