Skip to content
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

Subscripting array-valued expressions as if they were arrays #209

Closed
Beliavsky opened this issue May 25, 2021 · 3 comments
Closed

Subscripting array-valued expressions as if they were arrays #209

Beliavsky opened this issue May 25, 2021 · 3 comments

Comments

@Beliavsky
Copy link

In Julia and some another languages, you can subscript array expressions as if they were arrays. So in Julia

    (1:3).^4  = [1, 16, 81]
    ((1:3).^4)[2]  = 16

Would that be hard to implement in Fortran? It would make some code shorter by removing the need to instead
(1) declare an array
(2) set the array to an expression
(3) subscript the array

@FortranFan
Copy link
Member

FortranFan commented May 25, 2021

Given the standard allows

   associate ( x => [ 1, 2, 3 ]**4 )
      print *, x(2) 
   end associate
end

that takes care of about half the "needs", you may not get much response.

@Beliavsky
Copy link
Author

Beliavsky commented Oct 19, 2021

Steve Kargl explains some of the issues with subscripting expressions here. I will be closing this issue.

@certik
Copy link
Member

certik commented Oct 19, 2021

We should document the associate thing at https://fortran-lang.org/learn/ as a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants