sml - Difference between compile time and run time -


what difference between compile time , run time in sml?

after writing sml code, hit enter. don't understand, compiling or running it? example

- fun len [] = 0 | len (x::xs) = 1 + len xs;      /* hit enter*/ val len = fn : 'a list -> int 

after hitting enter, val len = fn : 'a list -> int result. runtime result or complile time result?

i don't understand happening behind scene.

in example seem use interpreter, difference between compile time , run time might not obvious. in principle is:

  • compile time: phase source-code compiled more low-level instructions (e.g., machine code). during phase things type inference , syntax checks done. errors guaranteed caught during phase (like type errors standard ml) can never occur during run time, nice thing, since know after successful compilation kinds of error can never occur. (compile time when compiler optimizations applied.)
  • run time: when program executed (be machine code or other representation): inputs given program , results computed.

for explicit example: during compile time checked input syntactically correct , type of len inferred. during run time program represented input executed, since there no computations in program (it defines new function len without calling it), nothing has done.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -