replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - What was the reason behind this rule?
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What was the reason behind this rule?

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
DanRRight



Joined: 10 Mar 2008
Posts: 2908
Location: South Pole, Antarctica

PostPosted: Tue Apr 01, 2025 5:43 pm    Post subject: What was the reason behind this rule? Reply with quote

Was always puzzled why this is allowed only if you set variable i as a PARAMETER and not as regular variable?

Code:
integer :: i = 1
integer :: j = 1-i
*** Error 538: I is not a PARAMETER, so cannot appear in an initialisation expression
Back to top
View user's profile Send private message
Kenneth_Smith



Joined: 18 May 2012
Posts: 797
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Tue Apr 01, 2025 6:19 pm    Post subject: Reply with quote

In Fortran, only constant expressions are allowed in an initialization expression.

A constant expression can comprise of:
1. Literals (constant values)
2. Named constants declared with the parameter attribute
3. Intrinsic functions that operate on constants
4. Arithmetic expressions using constants

Such expressions are evaluated at compile time and not at run time. Only parameters are known at compile time.

If Fortran allowed variable-dependent initialization, it would lead to undefined behavior because the compiler wouldn't know the correct value at compile time.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group