About first-,second- and third-class value

Posted by forest58 on Stack Overflow See other posts from Stack Overflow or by forest58
Published on 2010-04-05T14:29:49Z Indexed on 2010/04/05 14:33 UTC
Read the original article Hit count: 189

Filed under:

First-class value can be

  1. passed as an argument
  2. returned from a subroutine
  3. assigned into a variable.

Second-class value just can be passed as an argument.

Third-class value even can't be passed as an argument.

Why should these things defined like that? As I understand, "can be passed as an argument" means it can be pushed into the runtime stack;"can be assigned into a variable" means it can be moved into a different location of the memory; "can be returned from a subroutine" almost has the same meaning of "can be assigned into a variable" since the returned value always be put into a known address, so first class value is totally "movable" or "dynamic",second class value is half "movable" , and third class value is just "static", such as labels in C/C++ which just can be addressed by goto statement, and you can't do nothing with that address except "goto" .Does My understanding make any sense? or what do these three kinds of values mean exactly?

© Stack Overflow or respective owner

Related posts about programming-languages