Names, Scopes, and Bindings Names, Scopes, and ... - Lrde - Epita
Names, Scopes, and Bindings Names, Scopes, and ... - Lrde - Epita
Names, Scopes, and Bindings Names, Scopes, and ... - Lrde - Epita
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Complications<br />
Overloading<br />
1 <strong>Bindings</strong><br />
1 <strong>Bindings</strong><br />
2 Symbol Tables<br />
2 Symbol Tables<br />
3 Complications<br />
Overloading<br />
Non Local Variables<br />
3 Complications<br />
Overloading<br />
Non Local Variables<br />
<strong>Bindings</strong><br />
Symbol Tables<br />
Complications<br />
Overloading<br />
Non Local Variables<br />
<strong>Bindings</strong><br />
Symbol Tables<br />
Complications<br />
Overloading<br />
Non Local Variables<br />
Overloading<br />
Operator Overloading<br />
Overloading: Homonyms<br />
Several entities bearing the<br />
same name, but statically<br />
distinguishable, e.g., by their<br />
arity, type etc.<br />
Aliasing: Synonyms<br />
One entity bearing several<br />
names.<br />
// foo is overloaded.<br />
int foo (int);<br />
int foo (float);<br />
// x <strong>and</strong> y are aliases.<br />
int x;<br />
int& y = x;<br />
Overloading is meant to simplify the user’s life. Since FORTRAN!<br />
Overloading in Caml<br />
# 1 + 2;;<br />
- : int = 3<br />
# 1.0 + 2.0;;<br />
Characters 0-3:<br />
1.0 + 2.0;;<br />
^^^<br />
This expression has type float but is here used with type int<br />
# 1.0 +. 2.0;;<br />
- : float = 3.<br />
Thank God, C was invented to improve Caml:<br />
int a = 1 + 2;;<br />
float b = 1.0 + 2.0;;<br />
Of course this is unfair: Caml has type inference.<br />
A. Demaille, R. Levillain <strong>Names</strong>, <strong>Scopes</strong>, <strong>and</strong> <strong>Bindings</strong> 39 / 55<br />
A. Demaille, R. Levillain <strong>Names</strong>, <strong>Scopes</strong>, <strong>and</strong> <strong>Bindings</strong> 40 / 55