functional programming - How can Erlang support both single assignment and dynamic typing? -


let me start saying computer science enthusiast, relatively little knowledge of subject. question is: if single assignment idea variable (e.g., a) can assigned single value without value change (a = 1, a = 2 -> error) how can language have dynamic typing? if value of variable cannot change, surely cannot change type... right?

if language dynamically typed means not possible determine type of given expression without running program. doesn't have mean variables have able change type, it's not possible tell type variable has without running program.

so take piece of code example:

a =     if some_condition -> 42;     true -> "hello"     end 

here can not know whether number or string without knowing whether condition true or false (which can't know without running code can arbitrarily complex expression). in statically typed language above illegal, in erlang allowed.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -