Annotated edit history of
DynamicTyping version 3, including all changes.
View license author blame.
| Rev |
Author |
# |
Line |
| 1 |
PerryLorier |
1 |
!!!Dynamic Typing |
| |
|
2 |
|
| 2 |
PerryLorier |
3 |
This is the opposite to StaticallyTyped, where type checks are done at runtime. For instance [Python] is an example of a dynamically typed language, it allows you to pass any type to a function, however some internal functions can only take specific types. |
| 1 |
PerryLorier |
4 |
|
| |
|
5 |
for example: |
| |
|
6 |
def mul(a,b): |
| |
|
7 |
return a*b |
| |
|
8 |
|
| |
|
9 |
>>> print mul(2,3) |
| |
|
10 |
''6'' |
| |
|
11 |
>>> print mul("*",3) |
| |
|
12 |
''***'' |
| |
|
13 |
>>> print mul("*","*") |
| |
|
14 |
''Traceback (most recent call last):'' |
| |
|
15 |
'' File "<stdin>", line 1, in ?'' |
| |
|
16 |
''!TypeError: unsupported operand type(s) for *: 'str' and 'str' '' |
| |
|
17 |
|
| |
|
18 |
|
| 3 |
CraigBox |
19 |
[Scheme], [Perl], [Python], SmallTalk, bash(1) are all Dynamically Typed languages, it's quite common for scripting languages to be dynamically typed. |