This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compile Time Constants...

 
Dan Silva
Ranch Hand
Posts: 86
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does it mean to be a compile time constant?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A compile time constant is one that can't be set or changed after compilation.

Examples:


The first is a compile time constant.
The compiler knows that the value will be 1 and that it can never change.

In the second example the assignment of SET_AT_RUNTIME is delayed until the construction of the class. The compiler has no idea what SET_AT_RUNTIME will be.

In the third example the value depends on another class which could change after this class has been compiled so it isn't a compile time constant.
[ March 01, 2008: Message edited by: Ben Souther ]
 
Dan Silva
Ranch Hand
Posts: 86
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic