Skip to content

Commit 38024b4

Browse files
committed
Update language as requested by @brson, add a history section, and
add links into README.md
1 parent 2d69307 commit 38024b4

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ the direction the language is evolving in.
4343
* [0803-type-ascription.md](text/0803-type-ascription.md)
4444
* [0809-box-and-in-for-stdlib.md](text/0809-box-and-in-for-stdlib.md)
4545
* [0909-move-thread-local-to-std-thread.md](text/0909-move-thread-local-to-std-thread.md)
46+
* [0911-const-fn.md](text/0911-const-fn.md)
4647
* [0968-closure-return-type-syntax.md](text/0968-closure-return-type-syntax.md)
4748
* [0979-align-splitn-with-other-languages.md](text/0979-align-splitn-with-other-languages.md)
4849
* [1011-process.exit.md](text/1011-process.exit.md)

text/0000-const-fn.md renamed to text/0911-const-fn.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ called in constants contexts, with constant arguments.
1313
As it is right now, `UnsafeCell` is a stabilization and safety hazard: the field
1414
it is supposed to be wrapping is public. This is only done out of the necessity
1515
to initialize static items containing atomics, mutexes, etc. - for example:
16+
1617
```rust
1718
#[lang="unsafe_cell"]
1819
struct UnsafeCell<T> { pub value: T }
@@ -46,9 +47,17 @@ for such features.
4647

4748
The design should be as simple as it can be, while keeping enough functionality
4849
to solve the issues mentioned above.
49-
The intention is to have something usable at 1.0 without limiting what we can
50-
in the future. Compile-time pure constants (the existing `const` items) with
51-
added parametrization over types and values (arguments) should suffice.
50+
51+
The intention of this RFC is to introduce a minimal change that
52+
enables safe abstraction resembling the kind of code that one writes
53+
outside of a constant. Compile-time pure constants (the existing
54+
`const` items) with added parametrization over types and values
55+
(arguments) should suffice.
56+
57+
This RFC explicitly does not introduce a general CTFE mechanism. In
58+
particular, conditional branching and virtual dispatch are still not
59+
supported in constant expressions, which imposes a severe limitation
60+
on what one can express.
5261

5362
# Detailed design
5463

@@ -171,9 +180,6 @@ after 1.0.
171180

172181
# Alternatives
173182

174-
* Not do anything for 1.0. This would result in some APIs being crippled and
175-
serious backwards compatibility issues - `UnsafeCell`'s `value` field cannot
176-
simply be removed later.
177183
* While not an alternative, but rather a potential extension, I want to point
178184
out there is only way I could make `const fn`s work with traits (in an untested
179185
design, that is): qualify trait implementations and bounds with `const`.
@@ -214,3 +220,9 @@ algorithm that can handle *at least* tail recursion.
214220
Also, there is no way to actually write a recursive `const fn` at this moment,
215221
because no control flow primitives are implemented for constants, but that
216222
cannot be taken for granted, at least `if`/`else` should eventually work.
223+
224+
# History
225+
226+
- This RFC was accepted on 2015-04-06. The primary concerns raised in
227+
the discussion concerned CTFE, and whether the `const fn` strategy
228+
locks us into an undesirable plan there.

0 commit comments

Comments
 (0)