Yes and yes.
To control the names of various entities that Dafny uses in the target code, use the {:extern "ThisIsTheNameIWant"}
attribute. This attribute is supported on most declarations. For example, you can put one on a class and another on a method inside the class. For more examples, see the Test/dafny0/Extern.dfy
file in the Dafny test suite. If you want to look at what is generated, use the /spillTargetCode:1
flag from the command line.
For constants, use:
const MaxValue := 10000
(Note, until recently, you had to supply the type of constants explicitly, so you had to write
const MaxValue: int := 10000
If you're building the latest version of Dafny from sources, the type is inferred from the right-hand side expression.)
A nifty feature, borrowed from Ada language, is that you can insert an underscore between any two digits in numeric literals. If you work with large literals with a bunch a zeros in them, then this makes it easier for your eyes to see that you have written the correct number. For example:
const MaxValue := 10_000
const PhoneNumber := 512_555_1212
const SignedInt32Limit := 0x8000_0000
Rustan