notebook/notes/c17/index.md

11 KiB

title TARGET DECK FILE TAGS tags
C17 Obsidian::STEM c17
c17

Overview

An object is a region of data storage in the execution environment, the contents of which can represent values. We say an object type is complete if there is sufficient information to determine the size of objects of that type. Otherwise we say it is incomplete.

An lvalue is an expression (with non-void object type) that potentially designates an object. An rvalue is the "value of the expression."

%%ANKI Basic What does an object refer to? Back: A region of data storage in the execution environment, the contents of which can represent values. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic What does a value refer to? Back: The contents of an object when interpreted as having a specific type. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Cloze A {value} refers to the contents of an {object} when interpreted as having a specific type. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Types are partitioned into what two categories? Back: Object types and function types. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic What is an object type? Back: A type that describes objects. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic What is a function type? Back: A type that describes functions. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic What two parts characterize a function type? Back: The return type and the number/types of its parameters. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic What does it mean for an object type to be complete? Back: There is sufficient information to determine the size of objects of that type. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic What does it mean for an object type to be incomplete? Back: There is insufficient information to determine the size of objects of that type. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic What is an lvalue? Back: An expression (with non-void object type) that potentially designates an object. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Why are lvalues named the way they are? Back: The name is an acronym for locator value. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic What is an rvalue? Back: The value of an expression. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Why are rvalues named the way they are? Back: The name is an acronym for right value. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic What object type can an lvalue not have? Back: void Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic What object type can an lvalue have? Back: Any object type other than void. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Can an lvalue designate an object? Back: Yes. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Can an lvalue designate a function? Back: No. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Is x an lvalue or rvalue in the following snippet?

int x = 10;

Back: An lvalue. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Is int an lvalue or rvalue in the following snippet?

int x = 10;

Back: Neither. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Is 10 an lvalue or rvalue in the following snippet?

int x = 10;

Back: An rvalue. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Why is x an lvalue in the following?

int x = 10;

Back: Because x refers to a memory location. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Is x an lvalue or rvalue in the following snippet?

void x;

Back: Neither. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Is x an lvalue or rvalue in the following snippet?

void *x;

Back: An lvalue. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Is y an lvalue or rvalue in the following snippet?

int y = x + 10;

Back: An lvalue. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Is x an lvalue or rvalue in the following snippet?

int y = x + 10;

Back: An rvalue. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic In the second line, is ptr an lvalue or rvalue?

int *ptr = &x;
*ptr = 10;

Back: An lvalue. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic In the second line, is *ptr an lvalue or rvalue?

int *ptr = &x;
*ptr = 10;

Back: An lvalue. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Is getValue an lvalue or rvalue in the following snippet?

int getValue () {
  return 42;
}

Back: Neither. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Is getValue() an lvalue or rvalue in the following snippet?

int d = getValue();

Back: An rvalue. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Why is getValue in the following snippet neither an lvalue nor an rvalue?

int getValue() {
  return 42;
}

Back: The function name is just syntax. That is, it isn't an expression. Reference: “ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Are variables typically lvalues or rvalues? Back: lvalues. Reference: ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Are constants typically lvalues or rvalues? Back: rvalues. Reference: ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Are array elements typically lvalues or rvalues? Back: lvalues. Reference: ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Are dereferenced pointers typically lvalues or rvalues? Back: lvalues. Reference: ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Are temporary values typically lvalues or rvalues? Back: rvalues. Reference: ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Does x have complete or incomplete object type in the following?

void x;

Back: Incomplete. Reference: ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Does x have complete or incomplete object type in the following?

int x;

Back: Complete. Reference: ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

%%ANKI Basic Does x have complete or incomplete object type in the following?

void *x;

Back: Complete. Reference: ISO: Programming Languages - C,” April 12, 2011, https://port70.net/~nsz/c/c11/n1570.pdf.

END%%

Bibliography