Files
swift-mirror/stdlib/core/LogicValue.swift
Dave Abrahams 6d1095f44e Protocol names end in "Type," "ible," or "able"
Mechanically add "Type" to the end of any protocol names that don't end
in "Type," "ible," or "able."  Also, drop "Type" from the end of any
associated type names, except for those of the *LiteralConvertible
protocols.

There are obvious improvements to make in some of these names, which can
be handled with separate commits.

Fixes <rdar://problem/17165920> Protocols `Integer` etc should get
uglier names.

Swift SVN r19883
2014-07-12 17:29:57 +00:00

39 lines
1.5 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
// LogicValueType
//===----------------------------------------------------------------------===//
@prefix public func !<T : LogicValueType>(a: T) -> Bool {
return !a.getLogicValue()
}
// Short circuiting logical operators.
// FIXME: these operators should be fully generic
// BLOCKED ON: <rdar://problem/13251236> [remapping bound function type not
// implemented yet (deduced closure types)].
//
// FIXME: the generic versions of these operators probably shouldn't
// be @transparent; ideally they will be overloaded with transparent
// bool-specific operators. BLOCKED ON: <rdar://problem/11510876>
// [Implement overload resolution].
@transparent public
func &&(lhs: LogicValueType, rhs: @auto_closure () -> LogicValueType) -> Bool {
return lhs.getLogicValue() ? rhs().getLogicValue() : false
}
@transparent public
func ||(lhs: LogicValueType, rhs: @auto_closure () -> LogicValueType) -> Bool {
return lhs.getLogicValue() ? true : rhs().getLogicValue()
}