Microsoft PowerPoint - MLdeclarationsm.ppt
Short Description
Tutorial Notes: Standard ML. ML-Declarations 2. Notes. ML Declarations.3. Identifiers in ML. Identifiers in ML. val declaration binds a name to a value. …
Website: webcourse.cs.technion.ac.il | Filesize: 74kb
Content
234319: Programming Languages.
Tutorial Notes: Standard ML
ML-Declarations 1
Notes
ML Declarations.1
Standard ML
Declarations
ML Declarations.2
Area of a circle:
- val pi = 3.14159;
val pi = 3.14159 : real
- fun area (r) = pi*r*r;
val area = fn : real -> real
- area 2.0;
val it = 12.56636 : real
a r e a = r
2
Example - Circle Area234319: Programming Languages.
Tutorial Notes: Standard ML
ML-Declarations 2
Notes
ML Declarations.3
Identifiers in ML
val declaration binds a name to a value.
A name can not be used to change its value !
Actually a constant
A name can be reused for another purpose
- val pi = “pi”;
val pi = “pi” : string
If a name is declared again the new meaning is
adopted afterwards
- pi;
val it = “pi” : string
but does not affect existing uses of the name
- area(1.0)
val it = 3.14159 : real
ML Declarations.4
Is permanence of names a
good feature?
LUCKY: redefining a function cannot damage the system
or your program.
BUT: redefining a function called by your program may
have no visible effect.
NOTE: when modifying a program, be sure to recompile
the entire file…
Get the file Download here
Related Books:Related Searches:
Comments
Leave a Reply