mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-28 20:14:56 +01:00
Rename value categories to expression categories based on [Discord discussion](https://discord.com/channels/655572317891461132/753021843459538996/1092924035517665332) regarding naming and behavior. >* let expression -> value expression >* var expression -> reference expression >* located expression -> initializing expression >So: >- "value expressions" produce values (with no associated location). "reference expressions" produce a location of an existing value. "initializing expressions" take a location and initialize it. >- A let binding is initialized by a value expression, because lets represent values (with category conversions performed as needed, but if a conversion is performed from a different category of expression, the value of the object is pinned for the lifetime of the let). >- A var binding is initialized by an initializing expression, without performing a copy (with category conversions performed as needed, calling a copy constructor if the initializer is a different expression category). >- The & operator requires a reference expression, and it's an error to give it other kinds. >- The left-hand side of . requires a value expression when calling a function with a non-addr receiver, and requires a reference expression when calling a function with an addr receiver (it's an error to give it a value expression, and for an initializing expression, a temporary is materialized). Changes * Rename "value category" to "expression category" * Rename Var and Let value categories to Value, Reference, and Initializing expression * Rename `lvalue` to `location` (most of the time)
24 lines
799 B
C++
24 lines
799 B
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#ifndef CARBON_EXPLORER_AST_EXPRESSION_CATEGORY_H_
|
|
#define CARBON_EXPLORER_AST_EXPRESSION_CATEGORY_H_
|
|
|
|
namespace Carbon {
|
|
|
|
// The category of a Carbon expression indicates whether it evaluates
|
|
// to a value, reference, or initialization.
|
|
enum class ExpressionCategory {
|
|
// A "value expression" produces a value (with no associated location).
|
|
Value,
|
|
// A "reference expression" produces a location of an existing value.
|
|
Reference,
|
|
// An "initializing expression" takes a location and initialize it.
|
|
Initializing,
|
|
};
|
|
|
|
} // namespace Carbon
|
|
|
|
#endif // CARBON_EXPLORER_AST_EXPRESSION_CATEGORY_H_
|