Skip to content

Commit ef7f5d4

Browse files
committedJan 3, 2015
Revert "Add documentation and test for Val{T}"
1 parent fc4c69d commit ef7f5d4

File tree

4 files changed

+3
-48
lines changed

4 files changed

+3
-48
lines changed
 

‎NEWS.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ Library improvements
143143

144144
* The `randexp` and `randexp!` functions are exported ([#9144])
145145

146-
* A new `Val{T}` type allows one to dispatch on bits-type values ([#9452])
147146

148147
Deprecated or removed
149148
---------------------
@@ -160,12 +159,12 @@ Deprecated or removed
160159
`trunc{T<:Integer}(T,x)`, `floor{T<:Integer}(T,x)`, etc.. `trunc` is now
161160
always bound-checked;`Base.unsafe_trunc` provides the old unchecked `itrunc`
162161
behaviour ([#9133]).
163-
162+
164163
* `squeeze` now requires that passed dimension(s) are an `Int` or tuple of `Int`s;
165164
calling `squeeze` with an arbitrary iterator is deprecated ([#9271]).
166165
Additionally, passed dimensions must be unique and correspond to extant
167166
dimensions of the input array.
168-
167+
169168

170169
Julia v0.3.0 Release Notes
171170
==========================
@@ -1141,4 +1140,3 @@ Too numerous to mention.
11411140
[#9261]: https://github.com/JuliaLang/julia/issues/9261
11421141
[#9271]: https://github.com/JuliaLang/julia/issues/9271
11431142
[#9294]: https://github.com/JuliaLang/julia/issues/9294
1144-
[#9542]: https://github.com/JuliaLang/julia/issues/9542

‎doc/manual/types.rst

+1-30
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ surrounded by curly braces::
692692
This declaration defines a new parametric type, ``Point{T}``, holding
693693
two "coordinates" of type ``T``. What, one may ask, is ``T``? Well,
694694
that's precisely the point of parametric types: it can be any type at
695-
all (or any bits type, actually, although here it's clearly used as a
695+
all (or an integer, actually, although here it's clearly used as a
696696
type). ``Point{Float64}`` is a concrete type equivalent to the type
697697
defined by replacing ``T`` in the definition of ``Point`` with
698698
:class:`Float64`. Thus, this single declaration actually declares an
@@ -1243,35 +1243,6 @@ If you apply :func:`super` to other type objects (or non-type objects), a
12431243
julia> super((Float64,Int64))
12441244
ERROR: `super` has no method matching super(::Type{(Float64,Int64)})
12451245

1246-
"Value types"
1247-
-------------
1248-
1249-
As one application of these ideas, Julia includes a parametric type,
1250-
``Val{T}``, designated for dispatching on bits-type *values*. For
1251-
example, if you pass a boolean to a function, you have to test the
1252-
value at run-time:
1253-
1254-
.. doctest::
1255-
1256-
function firstlast(b::Bool)
1257-
return b ? "First" : "Last"
1258-
end
1259-
1260-
println(firstlast(true))
1261-
1262-
You can instead cause the conditional to be evaluated during function
1263-
compilation by using the ``Val`` trick:
1264-
1265-
.. doctest::
1266-
1267-
firstlast(::Val{true}) = "First"
1268-
firstlast(::Val{false}) = "Last"
1269-
1270-
println(firstlast(Val{true}()))
1271-
1272-
Any legal type parameter (Types, Symbols, Integers, floating-point numbers,
1273-
tuples, etc.) can be passed via ``Val``.
1274-
12751246
Nullable Types: Representing Missing Values
12761247
-------------------------------------------
12771248

‎doc/stdlib/base.rst

-4
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,6 @@ Types
438438

439439
Compute a type that contains the intersection of ``T`` and ``S``. Usually this will be the smallest such type or one close to it.
440440

441-
.. function:: Val{c}()
442-
443-
Create a "value type" instance out of ``c``, which must be an ``isbits`` value. The intent of this construct is to be able to dispatch on constants, e.g., ``f(Val{false}())`` allows you to dispatch directly to an implementation ``f(::Val{false})``, without having to test the boolean value at runtime.
444-
445441
Generic Functions
446442
-----------------
447443

‎test/core.jl

-10
Original file line numberDiff line numberDiff line change
@@ -502,16 +502,6 @@ begin
502502
@test is(g(a),a)
503503
end
504504

505-
# dispatch using Val{T}
506-
begin
507-
local firstlast
508-
firstlast(::Val{true}) = "First"
509-
firstlast(::Val{false}) = "Last"
510-
511-
@test firstlast(Val{true}()) == "First"
512-
@test firstlast(Val{false}()) == "Last"
513-
end
514-
515505
# try/finally
516506
begin
517507
after = 0

0 commit comments

Comments
 (0)
Please sign in to comment.