[Draft] Change @noreturn to unconstructible return type

This is a language that has put protocol centerstage. It stands to reason express something as essential using a protocol.

protocol Nothing {}

seems more than rational

No, this doesn't make sense as a protocol. You should not be able to conform to Nothing, but you could conform to this protocol. You *should* be able to cast anything to Nothing, which this definition doesn't allow. You should be able to call any method, property, or subscript on Nothing* (none of them will actually work), but Nothing has no methods. A `protocol Nothing` is, frankly, the exact *opposite* of what Nothing should be.

Interesting viewpoint. My only issue with it is that it tends to perpetuate the magic that exists between compiler and stdlib: there are many areas where they seem to be gratuitiously joined at the hip by shared secret hanshakes.

···

* At least notionally. It wouldn't be wrong to omit that as clever, but pointless.

--
Brent Royal-Gordon
Architechies

Why? The compiler flags an error if it can statically prove a trapping

overflow will occur. Why shouldn't it flag an error if it can statically
prove a force unwrap will fail?

If one of the associated values is Bottom/None/Never, how is my code

improved by the fact that I still need a case for it in a `switch`
statement?

Nice points! I tried to keep things as simple as possible, but it looks
like such special cases would really help here.

I wonder if perhaps your experience with Haskell has given you a false

impression of how this would work in Swift. Haskell is a pervasively lazy
language. Every operation in Haskell is lazy and you have little control
over when anything executes. Because of this, `undefined` values can
persist for long periods of time and spread deep into your code. But Swift
is not pervasively lazy; it is (relatively) simple and obvious to figure
out when a given piece of code will run. When you run a
Bottom/None/Never-returning expression, it does not return. Period. There
is no "it does not return six files away from where you wrote it".

We need Never to be subtype of any type, including structs and final
classes, but it's difficult to wrap my head around this while we don't have
subtypes in Swift.
Anyway, I see little to no problems with this. Just the proposal is going
to become longer than I expected :)

- Anton

···

2016-06-06 11:12 GMT+03:00 Brent Royal-Gordon <brent@architechies.com>:

> The following names were suggested: NoReturn, Bottom, None, Never.
> I would pick None, because it looks like opposite to Any and fits nicely
in generic types.

I discussed all of these options and more. The issue I see with None is
that it could easily be interpreted as Void to those without a C
background. (Actually, it's probably the most *natural* name for what we
call Void.) `func x() -> None` reads like it returns nothing. `func x() ->
Never` reads like it does not return.

> I would prefer the type to be simple, and be implemented as a case-less
enum (not a bottom value, as in Haskell).
>
> None should be a usual enum, with no compiler magic except that
functions returning None are equivalent to current @noreturn.

Could you elaborate on this? I think it would be really useful to have a
bottom type—useful to the point that, within minutes of deciding to think
of examples, I quickly came up with some really good ones. Why don't you
like having a bottom type?

> Example 1.
> let x: None?
> // ...
> let y = x!
>
> It will trap in runtime not because we discover scary bottom thing, as
in Haskell, but because x had value Optional.none at that moment and we
asserted otherwise.

I'm not sure what you mean by this. There is no "scary bottom thing";
Bottom or None or Never or whatever you call it is still an empty type, and
the unwrap still fails because the value is `.none`, not `.some`. The only
difference is that you can say something like `let total = basicBooks +
fatalError("implement pro books counting")` in an expression and it will
compile, since Bottom/None/Never is a subtype of `basicBooks`'s type—it's
simply one that will never actually be created.

I wonder if perhaps your experience with Haskell has given you a false
impression of how this would work in Swift. Haskell is a pervasively lazy
language. Every operation in Haskell is lazy and you have little control
over when anything executes. Because of this, `undefined` values can
persist for long periods of time and spread deep into your code. But Swift
is not pervasively lazy; it is (relatively) simple and obvious to figure
out when a given piece of code will run. When you run a
Bottom/None/Never-returning expression, it does not return. Period. There
is no "it does not return six files away from where you wrote it".

> We could prove that it is always true in this case, but compiler must be
stupid about this.

Why? The compiler flags an error if it can statically prove a trapping
overflow will occur. Why shouldn't it flag an error if it can statically
prove a force unwrap will fail?

> Example 2.
> Compiler should allow including None in structures. Error will show up
in constructor, when we will not be able to initialize the field.

Well, you can assign the field from a call to something like
`fatalError()`, but of course that will crash at runtime. (That's true
whether we use a bottom type or an empty type, by the way.)

> Example 3.
> None in an enum case makes that case never appear in values of such a
type. But compiler can not know about that.

Again: Why? If one of the associated values is Bottom/None/Never, how is
my code improved by the fact that I still need a case for it in a `switch`
statement? What's the advantage of not being able to eliminate dead code,
or call out code that will inevitably fail? We already want these things
for other uses of Bottom/None/Never, like dead code elimination after a
precondition fails. Why not here?

--
Brent Royal-Gordon
Architechies

My preference from the current suggestions would be Never.

-Thorsten

···

Am 06.06.2016 um 15:24 schrieb Thorsten Seitz via swift-evolution <swift-evolution@swift.org>:

Ceylon uses `Nothing` for the bottom type.

-Thorsten

Am 05.06.2016 um 20:39 schrieb Charlie Monroe via swift-evolution <swift-evolution@swift.org>:

While None is probably the best way to describe the opposite of Any, it would be often mistaken for .None (i.e. Optional) by newcomers to the language.

I'd personally prefer calling it "Nil" (capital N), which really means "nonexistent". The same way ObjC had "nil" for "id" and "Nil" for Class. Possibly, to avoid confusion with nil, calling it Null? Though that might get confused with NSNull, once the NS prefix gets dropped.

Or "Nothing" as in Scala.

On Jun 5, 2016, at 8:26 PM, Антон Жилин via swift-evolution <swift-evolution@swift.org> wrote:

The following names were suggested: NoReturn, Bottom, None, Never.
I would pick None, because it looks like opposite to Any and fits nicely in generic types.

I would prefer the type to be simple, and be implemented as a case-less enum (not a bottom value, as in Haskell).

None should be a usual enum, with no compiler magic except that functions returning None are equivalent to current @noreturn.

Example 1.
let x: None?
// ...
let y = x!

It will trap in runtime not because we discover scary bottom thing, as in Haskell, but because x had value Optional.none at that moment and we asserted otherwise.
We could prove that it is always true in this case, but compiler must be stupid about this.

Example 2.
Compiler should allow including None in structures. Error will show up in constructor, when we will not be able to initialize the field.

Example 3.
None in an enum case makes that case never appear in values of such a type. But compiler can not know about that.

- Anton
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

I agree. For this reason, my email continued after that paragraph. I deliberately ended the last sentence of that paragraph with "But wait, that's not really..."

There is a really really good reason why Haskell doesn't have a named "bottom type" like "None" or "Void". The bottom type has type `forall a. a`, corresponding to the mathematical fact that from "false" follows anything. Assigning a bottom type to a variable makes only sense in Haskell, because it uses lazy evaluation. With strict evaluation, a bottom type is just confusing at best. And a `Nothing` type corresponds to Haskell's `Void` type, not to its bottom type - a really exotic type that is seldom used. Its not consistent to have a @noreturn-function return `Nothing` instead, because `Nothing` that's not a proper type. You can write a foo-function that is really unintuitive:

func foo() -> NoReturn {
   let x = fatalError("crash please")
   print("1+1=2")
   return x
}

Shouldn't we all just try to understand the rationale for the current language behavior before we try to propose changes?

E.g. with the proposal, the following function:

@noreturn func error<T>(msg: String = "") -> T {
    fatalError("bottom: \(msg)")
}

has to be written as

func error<T>(msg: String = "") -> T {
    fatalError("bottom: \(msg)")
}

It still returns bottom, but there is no way to say so in the declaration. The proposal just made the language less expressive!

See also:
https://en.wikibooks.org/wiki/Haskell/Denotational_semantics
for a more in-depth explanation why "bottom" is not an ordinary type with a name.

-Michael

···

Am 06.06.2016 um 00:53 schrieb Charles Srstka <cocoadev@charlessoft.com>:

On Jun 5, 2016, at 5:41 PM, Michael Peternell via swift-evolution <swift-evolution@swift.org> wrote:

Am 05.06.2016 um 20:26 schrieb Антон Жилин via swift-evolution <swift-evolution@swift.org>:

The following names were suggested: NoReturn, Bottom, None, Never.
I would pick None, because it looks like opposite to Any and fits nicely in generic types.

I would like to call the type `Void`. `Void` is a type with zero possible values. The current `Void` would have to be renamed to `Unit`, the data type with exactly one possible value. Less C, More Haskell :) But wait, that's not really Haskell-ish, and it's not C-ish either.

That is the most confusing possible thing that this could possibly be called. Seeing a Void return will cause anyone coming from a C, C++, ObjC, etc. background to think of something that is definitely *not* a no-return function.

Joe Groff wrote:

## Impact on existing code

The number of `@noreturn` functions in the wild is fairly small, and all of
them I can find return `Void`. It should be trivial to migrate
existing `@noreturn` functions to use `-> NoReturn`.

Clang allows `_Noreturn` [C11] and `__attribute__((noreturn))` [GCC] functions
to have a non-void return type.

NSApplicationMain and UIApplicationMain have an integer return type, but they
never return. (There might be similar functions in other libraries). If these
functions could add `_Noreturn` without breaking binary compatibility, should
SE-0102 be rejected?

### Naming `NoReturn`

The best name for the standard library uninhabited type is up for debate.
`NoReturn` seems to me like the name most immediately obvious to most users
compared to these alternatives:

Would an `Unreachable` type name match the SIL and Clang terms?

<https://github.com/apple/swift/blob/master/docs/SIL.rst#unreachable&gt;
<Clang Language Extensions — Clang 18.0.0git documentation;

If empty "ad hoc enums" were available, you wouldn't need to choose a name!

<http://thread.gmane.org/gmane.comp.lang.swift.evolution/19210&gt;

Off-topic:

* Could "incomplete struct types" also be imported as empty enums?
* Would the Swift.OpaquePointer then become a generic type?

-- Ben

I would prefer the type to be simple, and be implemented as a case-less enum (not a bottom value, as in Haskell).

None should be a usual enum, with no compiler magic except that functions returning None are equivalent to current @noreturn.

I think it would be more useful if the compiler allowed `Never` in every type context (i.e. whatever type `T` was expected, an expression of type `Never` would be allowed), making expressions like the following compile:

    let unwrapped: Int = optional ?? fatalError("explanation why this must not happen")

— Pyry

I dunno, I think @noreturn is clearer than any of these. It tells you that the function… won’t return. None, Never, etc. could be mistaken as a synonym for Void, whereas @noreturn is pretty hard to miss.

FWIW, in the rejection of SE-0097, this was what the core team had to say about it:

1) For noreturn, the core team prefers to explore a solution where a function can be declared as returning an non-constructable “bottom” type (e.g. an enum with zero cases). This would lead to something like:

  func abort() -> NoReturn { … }

Interesting... There are other cases that would exist for which NoReturn seems the wrong name... but they knwo better I guess.

···

On Jun 5, 2016, at 9:47 PM, Pyry Jahkola via swift-evolution <swift-evolution@swift.org> wrote:

This will require some new support in the compiler, but should flow better through the type system than @noreturn in function composition and other applications. Joe Groff offered to write a proposal for this.

— Pyry

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Bringing up an old idea, we could rewrite `rethrows` using Never and throws type specification:

func call<T, E>(block: () throws E -> T) throws E -> T

But this requires some compiler magic: non-throwing functions should effectively become functions throwing Never.

This is very clever, and a very natural way to design things *if* Never is a proper bottom type, instead of just an empty enum. I don't even think you can really describe this as "compiler magic": Just as a function with no return type implicitly returns Void, so a function with no throw type implicitly throws Never.

(Incidentally, the `E` should be `E: ErrorProtocol`, I believe, since you can only throw ErrorProtocols. That's why Never needs to be a proper bottom type: it needs to conform to `ErrorProtocol`.)

···

--
Brent Royal-Gordon
Architechies

I'm against using Nil as it would have a very different meaning than Nil (or Null) in all other C-based languages.

Well said :)

···

On Jun 6, 2016, at 8:25 AM, David Hart via swift-evolution <swift-evolution@swift.org> wrote:

On 06 Jun 2016, at 05:56, Charlie Monroe via swift-evolution <swift-evolution@swift.org> wrote:

Adding a Nil *type* is a bit different than casting dozen of identifiers to (void*)0...

On Jun 5, 2016, at 10:54 PM, T.J. Usiyan <griotspeak@gmail.com> wrote:

*please* let us not repeat the mostly avoidable challenging-to-explain-to-newcomers-and-vetarans-alike situation that we had in Obj-C with regard to `nil`.

nil
Nil
NULL
NSNull
nullptr
kCFNull
__DARWIN_NULL

are the representations of 'don't have' that come to mind.

On Sun, Jun 5, 2016 at 2:39 PM, Charlie Monroe via swift-evolution <swift-evolution@swift.org> wrote:
While None is probably the best way to describe the opposite of Any, it would be often mistaken for .None (i.e. Optional) by newcomers to the language.

I'd personally prefer calling it "Nil" (capital N), which really means "nonexistent". The same way ObjC had "nil" for "id" and "Nil" for Class. Possibly, to avoid confusion with nil, calling it Null? Though that might get confused with NSNull, once the NS prefix gets dropped.

Or "Nothing" as in Scala.

> On Jun 5, 2016, at 8:26 PM, Антон Жилин via swift-evolution <swift-evolution@swift.org> wrote:
>
> The following names were suggested: NoReturn, Bottom, None, Never.
> I would pick None, because it looks like opposite to Any and fits nicely in generic types.
>
> I would prefer the type to be simple, and be implemented as a case-less enum (not a bottom value, as in Haskell).
>
> None should be a usual enum, with no compiler magic except that functions returning None are equivalent to current @noreturn.
>
> Example 1.
> let x: None?
> // ...
> let y = x!
>
> It will trap in runtime not because we discover scary bottom thing, as in Haskell, but because x had value Optional.none at that moment and we asserted otherwise.
> We could prove that it is always true in this case, but compiler must be stupid about this.
>
> Example 2.
> Compiler should allow including None in structures. Error will show up in constructor, when we will not be able to initialize the field.
>
> Example 3.
> None in an enum case makes that case never appear in values of such a type. But compiler can not know about that.
>
> - Anton
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

+1 for Never, as 'foo() -> Never' reads as 'foo returns never' i.e. close to 'never returns'. Or we just need NoReturn as replacement for @noreturn, and then think about true bottom type and its name separately.

···

On 06.06.2016 16:37, Thorsten Seitz via swift-evolution wrote:

My preference from the current suggestions would be Never.

-Thorsten

Am 06.06.2016 um 15:24 schrieb Thorsten Seitz via swift-evolution <swift-evolution@swift.org>:

Ceylon uses `Nothing` for the bottom type.

-Thorsten

Am 05.06.2016 um 20:39 schrieb Charlie Monroe via swift-evolution <swift-evolution@swift.org>:

While None is probably the best way to describe the opposite of Any, it would be often mistaken for .None (i.e. Optional) by newcomers to the language.

I'd personally prefer calling it "Nil" (capital N), which really means "nonexistent". The same way ObjC had "nil" for "id" and "Nil" for Class. Possibly, to avoid confusion with nil, calling it Null? Though that might get confused with NSNull, once the NS prefix gets dropped.

Or "Nothing" as in Scala.

On Jun 5, 2016, at 8:26 PM, Антон Жилин via swift-evolution <swift-evolution@swift.org> wrote:

The following names were suggested: NoReturn, Bottom, None, Never.
I would pick None, because it looks like opposite to Any and fits nicely in generic types.

I would prefer the type to be simple, and be implemented as a case-less enum (not a bottom value, as in Haskell).

None should be a usual enum, with no compiler magic except that functions returning None are equivalent to current @noreturn.

Example 1.
let x: None?
// ...
let y = x!

It will trap in runtime not because we discover scary bottom thing, as in Haskell, but because x had value Optional.none at that moment and we asserted otherwise.
We could prove that it is always true in this case, but compiler must be stupid about this.

Example 2.
Compiler should allow including None in structures. Error will show up in constructor, when we will not be able to initialize the field.

Example 3.
None in an enum case makes that case never appear in values of such a type. But compiler can not know about that.

- Anton
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

E.g. with the proposal, the following function:

@noreturn func error<T>(msg: String = "") -> T {
   fatalError("bottom: \(msg)")
}

has to be written as

func error<T>(msg: String = "") -> T {
   fatalError("bottom: \(msg)")
}

It still returns bottom, but there is no way to say so in the declaration. The proposal just made the language less expressive!

Can you not see how strange this code is? You're saying the function cannot return, and then providing a return type. What does that even mean?

And Pyry is also correct: `func error(msg: String = "") -> Never` gives you the "assign to anything" semantics you're looking for anyway. What it does *not* allow you to do is something like:

  @noreturn func error(msg: String = "") -> ErrorProtocol

But again, what is that supposed to mean? If you're planning to fill in the implementation later and are just temporarily `fatalError()ing`, why are you marking it `@noreturn`, undermining its use as a stub? And if you intend it to stay `@noreturn`, why are you specifying a return type it will never actually return?

If you're *not* returning an unconstrained generic type—a use case `Never`'s subtype-of-all-types nature intrinsically covers—what *is* the use case where you need to specify both a return type *and* that the function never returns *in* the function's signature?

···

--
Brent Royal-Gordon
Architechies

Ceylon demonstrates other uses for the bottom type than just marking @noreturn methods, e.g. (mixing Ceylon and Swift syntax freely here)

class Iterable<Element, Absent = Null> {
  var last: Element | Absent // remember that optionals in Ceylon are modeled as union type T | Null
  ...
}

Iterable<String> // a possibly empty iterable where last: Element | Null, i.e. last: Element?
Iterable<String, Never> // a non-empty iterable where last: Element | Never, i.e. last: Element

This achieves type safety for `last` (and a couple of other methods not shown here) with respect to the property of an iterable statically known to be non-empty.
This is very elegant IMHO.

-Thorsten

···

Am 06.06.2016 um 19:46 schrieb Jacob Bandes-Storch via swift-evolution <swift-evolution@swift.org>:

What about `PreconditionFailure`? If you obtain an instance of this type, it means a precondition has failed.

Jacob

On Mon, Jun 6, 2016 at 9:48 AM, Joe Groff via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
`Never` seems reasonable to me too. I'll add that to the proposal as an alternative.

-Joe

> On Jun 5, 2016, at 11:37 AM, T.J. Usiyan via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>
> I vote for Bottom or Never. None does not convey "this should not occur or be evaluated".
>
> On Sun, Jun 5, 2016 at 2:26 PM, Антон Жилин <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
> The following names were suggested: NoReturn, Bottom, None, Never.
> I would pick None, because it looks like opposite to Any and fits nicely in generic types.
>
> I would prefer the type to be simple, and be implemented as a case-less enum (not a bottom value, as in Haskell).
>
> None should be a usual enum, with no compiler magic except that functions returning None are equivalent to current @noreturn.
>
> Example 1.
> let x: None?
> // ...
> let y = x!
>
> It will trap in runtime not because we discover scary bottom thing, as in Haskell, but because x had value Optional.none at that moment and we asserted otherwise.
> We could prove that it is always true in this case, but compiler must be stupid about this.
>
> Example 2.
> Compiler should allow including None in structures. Error will show up in constructor, when we will not be able to initialize the field.
>
> Example 3.
> None in an enum case makes that case never appear in values of such a type. But compiler can not know about that.
>
> - Anton
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

This isn't my understanding of the idea. My understanding is that instead of a generic function, you'd write `error` as:

    func error(_ msg: String = "") -> Never {
        fatalError("bottom: \(msg)")
        // or equivalently, since fatalError() also returns Never:
        //return fatalError("bottom: \(msg)")
    }

And because `Never` is a real bottom type (this is probably the extra compiler support needed that Chris Lattner referred to), you can use this function in any type context, meaning that it behaves as if it's of type `∀x. String → x`:

    // Example 1:
    func someImplementationDetail(input: Int) -> [String] {
        // ...
        return error("unimplemented for now")
    }

    // Example 2:
    var ints: [Int] =
    ints.append(error("FIXME"))

    // Example 3:
    let e: Either<String, String> = ...
    let s: String = e.left ?? e.right ?? error("impossible")

I would even consider specifying that every empty enum type behaves like this, and that `Never` was just the default you should probably use, defined in the stdlib as:

    /// The bottom type, or return type of functions that do not return.
    /// This enum is intentionally empty.
    enum Never {}

In other words in my imagination, there would be no magic in the type `Never` per se, but in the treatment of empty enums in general.

— Pyry

···

On 06 Jun 2016, at 22:40, Michael Peternell via swift-evolution <swift-evolution@swift.org> wrote:

E.g. with the proposal, the following function:

@noreturn func error<T>(msg: String = "") -> T {
   fatalError("bottom: \(msg)")
}

has to be written as

func error<T>(msg: String = "") -> T {
   fatalError("bottom: \(msg)")
}

It still returns bottom, but there is no way to say so in the declaration. The proposal just made the language less expressive!

@noreturn func error<T>(msg: String = "") -> T {
    fatalError("bottom: \(msg)")
}
has to be written as
func error<T>(msg: String = "") -> T {
    fatalError("bottom: \(msg)")
}
It still returns bottom, but there is no way to say so in the declaration.
The proposal just made the language less expressive!

Do we need to? One of use cases of this feature is to prototype using
unimplemented functions, i.e. lying about return type. In other cases,
return type of this function should be NoReturn/Never, as well.

You can write a foo-function that is really unintuitive:

func foo() -> NoReturn {
   let x = fatalError("crash please")
   print("1+1=2")
   return x
}

This is called "unreachable code", and this should give the same warning as
is currently given in such cases. Also you can currently create
sufficiently complex unreachable code that does not trigger a warning, and
nothing will change in that aspect.

Thinking about bottom-like behaviour, it would be a strict extension of
functionality of Never, so it can be discussed later in a separate proposal.

- Anton

···

2016-06-06 22:40 GMT+03:00 Michael Peternell <michael.peternell@gmx.at>:

> Am 06.06.2016 um 00:53 schrieb Charles Srstka <cocoadev@charlessoft.com > >:
>
>> On Jun 5, 2016, at 5:41 PM, Michael Peternell via swift-evolution < > swift-evolution@swift.org> wrote:
>>
>>> Am 05.06.2016 um 20:26 schrieb Антон Жилин via swift-evolution < > swift-evolution@swift.org>:
>>>
>>> The following names were suggested: NoReturn, Bottom, None, Never.
>>> I would pick None, because it looks like opposite to Any and fits
nicely in generic types.
>>
>> I would like to call the type `Void`. `Void` is a type with zero
possible values. The current `Void` would have to be renamed to `Unit`, the
data type with exactly one possible value. Less C, More Haskell :) But
wait, that's not really Haskell-ish, and it's not C-ish either.
>
> That is the most confusing possible thing that this could possibly be
called. Seeing a Void return will cause anyone coming from a C, C++, ObjC,
etc. background to think of something that is definitely *not* a no-return
function.

I agree. For this reason, my email continued after that paragraph. I
deliberately ended the last sentence of that paragraph with "But wait,
that's not really..."

There is a really really good reason why Haskell doesn't have a named
"bottom type" like "None" or "Void". The bottom type has type `forall a.
a`, corresponding to the mathematical fact that from "false" follows
anything. Assigning a bottom type to a variable makes only sense in
Haskell, because it uses lazy evaluation. With strict evaluation, a bottom
type is just confusing at best. And a `Nothing` type corresponds to
Haskell's `Void` type, not to its bottom type - a really exotic type that
is seldom used. Its not consistent to have a @noreturn-function return
`Nothing` instead, because `Nothing` that's not a proper type. You can
write a foo-function that is really unintuitive:

func foo() -> NoReturn {
   let x = fatalError("crash please")
   print("1+1=2")
   return x
}

Shouldn't we all just try to understand the rationale for the current
language behavior before we try to propose changes?

E.g. with the proposal, the following function:

@noreturn func error<T>(msg: String = "") -> T {
    fatalError("bottom: \(msg)")
}

has to be written as

func error<T>(msg: String = "") -> T {
    fatalError("bottom: \(msg)")
}

It still returns bottom, but there is no way to say so in the declaration.
The proposal just made the language less expressive!

See also:
Haskell/Denotational semantics - Wikibooks, open books for an open world
for a more in-depth explanation why "bottom" is not an ordinary type with
a name.

-Michael

You are thinking of it as a return type, but that's not how you should think of it, really - that's an example of what it may be used for, but it should not be the only aspect.

It should be the opposite of Any, which (excluding None), seems to be Nothing. Or Singularity :)

6. 6. 2016 v 16:12, Vladimir.S via swift-evolution <swift-evolution@swift.org>:

···

+1 for Never, as 'foo() -> Never' reads as 'foo returns never' i.e. close to 'never returns'. Or we just need NoReturn as replacement for @noreturn, and then think about true bottom type and its name separately.

On 06.06.2016 16:37, Thorsten Seitz via swift-evolution wrote:
My preference from the current suggestions would be Never.

-Thorsten

Am 06.06.2016 um 15:24 schrieb Thorsten Seitz via swift-evolution <swift-evolution@swift.org>:

Ceylon uses `Nothing` for the bottom type.

-Thorsten

Am 05.06.2016 um 20:39 schrieb Charlie Monroe via swift-evolution <swift-evolution@swift.org>:

While None is probably the best way to describe the opposite of Any, it would be often mistaken for .None (i.e. Optional) by newcomers to the language.

I'd personally prefer calling it "Nil" (capital N), which really means "nonexistent". The same way ObjC had "nil" for "id" and "Nil" for Class. Possibly, to avoid confusion with nil, calling it Null? Though that might get confused with NSNull, once the NS prefix gets dropped.

Or "Nothing" as in Scala.

On Jun 5, 2016, at 8:26 PM, Антон Жилин via swift-evolution <swift-evolution@swift.org> wrote:

The following names were suggested: NoReturn, Bottom, None, Never.
I would pick None, because it looks like opposite to Any and fits nicely in generic types.

I would prefer the type to be simple, and be implemented as a case-less enum (not a bottom value, as in Haskell).

None should be a usual enum, with no compiler magic except that functions returning None are equivalent to current @noreturn.

Example 1.
let x: None?
// ...
let y = x!

It will trap in runtime not because we discover scary bottom thing, as in Haskell, but because x had value Optional.none at that moment and we asserted otherwise.
We could prove that it is always true in this case, but compiler must be stupid about this.

Example 2.
Compiler should allow including None in structures. Error will show up in constructor, when we will not be able to initialize the field.

Example 3.
None in an enum case makes that case never appear in values of such a type. But compiler can not know about that.

- Anton
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

"Nothing" feels like it collides too much with the concept of a function
that returns, but returns nothing (i.e., Void), however.

If I read a function declaration from left to right:

    func foo() -> Nothing

I read that as "a function foo that returns nothing". That sounds like a
Void function to me. On the other hand:

    func foo() -> Never

I read that as "a function foo that returns never". That's perfectly clear
to me.

When it comes to naming things like this, I don't think we should try to
shoehorn in the arguably more "pure" names when it runs the risk of causing
confusion with Swift's C-based ancestry. I'd argue that it's more important
for the language to be clearly readable than to satisfy a notion of
absolute adherence to pure formal semantics that only theorists would
completely understand. The main audience here is still app developers and
perhaps backend developers, not academics.

···

On Mon, Jun 6, 2016 at 8:16 AM Charlie Monroe via swift-evolution < swift-evolution@swift.org> wrote:

You are thinking of it as a return type, but that's not how you should
think of it, really - that's an example of what it may be used for, but it
should not be the only aspect.

It should be the opposite of Any, which (excluding None), seems to be
Nothing. Or Singularity :)

6. 6. 2016 v 16:12, Vladimir.S via swift-evolution <
swift-evolution@swift.org>:

> +1 for Never, as 'foo() -> Never' reads as 'foo returns never' i.e.
close to 'never returns'. Or we just need NoReturn as replacement for
@noreturn, and then think about true bottom type and its name separately.
>
>> On 06.06.2016 16:37, Thorsten Seitz via swift-evolution wrote:
>> My preference from the current suggestions would be Never.
>>
>> -Thorsten
>>
>>> Am 06.06.2016 um 15:24 schrieb Thorsten Seitz via swift-evolution < > swift-evolution@swift.org>:
>>>
>>> Ceylon uses `Nothing` for the bottom type.
>>>
>>> -Thorsten
>>>
>>>> Am 05.06.2016 um 20:39 schrieb Charlie Monroe via swift-evolution < > swift-evolution@swift.org>:
>>>>
>>>> While None is probably the best way to describe the opposite of Any,
it would be often mistaken for .None (i.e. Optional) by newcomers to the
language.
>>>>
>>>> I'd personally prefer calling it "Nil" (capital N), which really
means "nonexistent". The same way ObjC had "nil" for "id" and "Nil" for
Class. Possibly, to avoid confusion with nil, calling it Null? Though that
might get confused with NSNull, once the NS prefix gets dropped.
>>>>
>>>> Or "Nothing" as in Scala.
>>>>
>>>>> On Jun 5, 2016, at 8:26 PM, Антон Жилин via swift-evolution < > swift-evolution@swift.org> wrote:
>>>>>
>>>>> The following names were suggested: NoReturn, Bottom, None, Never.
>>>>> I would pick None, because it looks like opposite to Any and fits
nicely in generic types.
>>>>>
>>>>> I would prefer the type to be simple, and be implemented as a
case-less enum (not a bottom value, as in Haskell).
>>>>>
>>>>> None should be a usual enum, with no compiler magic except that
functions returning None are equivalent to current @noreturn.
>>>>>
>>>>> Example 1.
>>>>> let x: None?
>>>>> // ...
>>>>> let y = x!
>>>>>
>>>>> It will trap in runtime not because we discover scary bottom thing,
as in Haskell, but because x had value Optional.none at that moment and we
asserted otherwise.
>>>>> We could prove that it is always true in this case, but compiler
must be stupid about this.
>>>>>
>>>>> Example 2.
>>>>> Compiler should allow including None in structures. Error will show
up in constructor, when we will not be able to initialize the field.
>>>>>
>>>>> Example 3.
>>>>> None in an enum case makes that case never appear in values of such
a type. But compiler can not know about that.
>>>>>
>>>>> - Anton
>>>>> _______________________________________________
>>>>> swift-evolution mailing list
>>>>> swift-evolution@swift.org
>>>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>>>
>>>> _______________________________________________
>>>> swift-evolution mailing list
>>>> swift-evolution@swift.org
>>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution@swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

I'd argue that it's more important for the language to be clearly readable than to satisfy a notion of absolute adherence to pure formal semantics that only theorists would completely understand.

The semantics might help a person better understand the philosophy of the language. The @noreturn methods are *not* being written very often, and definitely not by newcomers, who are usually fine knowing there's fatalError and that's it. For a person who has a deeper insight into the language, semantic consistency may be good thing.

···

The main audience here is still app developers and perhaps backend developers, not academics.

On Mon, Jun 6, 2016 at 8:16 AM Charlie Monroe via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
You are thinking of it as a return type, but that's not how you should think of it, really - that's an example of what it may be used for, but it should not be the only aspect.

It should be the opposite of Any, which (excluding None), seems to be Nothing. Or Singularity :)

6. 6. 2016 v 16:12, Vladimir.S via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>>:

> +1 for Never, as 'foo() -> Never' reads as 'foo returns never' i.e. close to 'never returns'. Or we just need NoReturn as replacement for @noreturn, and then think about true bottom type and its name separately.
>
>> On 06.06.2016 16:37, Thorsten Seitz via swift-evolution wrote:
>> My preference from the current suggestions would be Never.
>>
>> -Thorsten
>>
>>> Am 06.06.2016 um 15:24 schrieb Thorsten Seitz via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>>:
>>>
>>> Ceylon uses `Nothing` for the bottom type.
>>>
>>> -Thorsten
>>>
>>>> Am 05.06.2016 um 20:39 schrieb Charlie Monroe via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>>:
>>>>
>>>> While None is probably the best way to describe the opposite of Any, it would be often mistaken for .None (i.e. Optional) by newcomers to the language.
>>>>
>>>> I'd personally prefer calling it "Nil" (capital N), which really means "nonexistent". The same way ObjC had "nil" for "id" and "Nil" for Class. Possibly, to avoid confusion with nil, calling it Null? Though that might get confused with NSNull, once the NS prefix gets dropped.
>>>>
>>>> Or "Nothing" as in Scala.
>>>>
>>>>> On Jun 5, 2016, at 8:26 PM, Антон Жилин via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>>>>>
>>>>> The following names were suggested: NoReturn, Bottom, None, Never.
>>>>> I would pick None, because it looks like opposite to Any and fits nicely in generic types.
>>>>>
>>>>> I would prefer the type to be simple, and be implemented as a case-less enum (not a bottom value, as in Haskell).
>>>>>
>>>>> None should be a usual enum, with no compiler magic except that functions returning None are equivalent to current @noreturn.
>>>>>
>>>>> Example 1.
>>>>> let x: None?
>>>>> // ...
>>>>> let y = x!
>>>>>
>>>>> It will trap in runtime not because we discover scary bottom thing, as in Haskell, but because x had value Optional.none at that moment and we asserted otherwise.
>>>>> We could prove that it is always true in this case, but compiler must be stupid about this.
>>>>>
>>>>> Example 2.
>>>>> Compiler should allow including None in structures. Error will show up in constructor, when we will not be able to initialize the field.
>>>>>
>>>>> Example 3.
>>>>> None in an enum case makes that case never appear in values of such a type. But compiler can not know about that.
>>>>>
>>>>> - Anton
>>>>> _______________________________________________
>>>>> swift-evolution mailing list
>>>>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
>>>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>>>
>>>> _______________________________________________
>>>> swift-evolution mailing list
>>>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
>>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

My opinion is based on this message:

>
> FWIW, in the rejection of SE-0097
> <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160530/019879.html&gt;,
> this was what the core team had to say about it:
>
> /1) For noreturn, the core team prefers to explore a solution where a
> function can be declared as returning an non-constructable “bottom”
> type (e.g. an enum with zero cases). This would lead to something like:/
> /
> /func abort() -> NoReturn { … }/

I.e. we need some type that will reflect "NoReturn" at first. Then, probably, it can be used as bottom type. IMO `Never` is the best candidate at this moment. For me it also can mean "never can have an instance of this type" or "never be created" or "never be user" etc

···

On 05.06.2016 23:16, L. Mihalkovic via swift-evolution wrote:

On 06.06.2016 18:26, Tony Allevato wrote:

"Nothing" feels like it collides too much with the concept of a function
that returns, but returns nothing (i.e., Void), however.

If I read a function declaration from left to right:

    func foo() -> Nothing

I read that as "a function foo that returns nothing". That sounds like a
Void function to me. On the other hand:

    func foo() -> Never

I read that as "a function foo that returns never". That's perfectly clear
to me.

When it comes to naming things like this, I don't think we should try to
shoehorn in the arguably more "pure" names when it runs the risk of causing
confusion with Swift's C-based ancestry. I'd argue that it's more important
for the language to be clearly readable than to satisfy a notion of
absolute adherence to pure formal semantics that only theorists would
completely understand. The main audience here is still app developers and
perhaps backend developers, not academics.

On Mon, Jun 6, 2016 at 8:16 AM Charlie Monroe via swift-evolution > <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

    You are thinking of it as a return type, but that's not how you should
    think of it, really - that's an example of what it may be used for, but
    it should not be the only aspect.

    It should be the opposite of Any, which (excluding None), seems to be
    Nothing. Or Singularity :)

    6. 6. 2016 v 16:12, Vladimir.S via swift-evolution
    <swift-evolution@swift.org <mailto:swift-evolution@swift.org>>:

    > +1 for Never, as 'foo() -> Never' reads as 'foo returns never' i.e.
    close to 'never returns'. Or we just need NoReturn as replacement for
    @noreturn, and then think about true bottom type and its name separately.
    >
    >> On 06.06.2016 16:37, Thorsten Seitz via swift-evolution wrote:
    >> My preference from the current suggestions would be Never.
    >>
    >> -Thorsten
    >>
    >>> Am 06.06.2016 um 15:24 schrieb Thorsten Seitz via swift-evolution
    <swift-evolution@swift.org <mailto:swift-evolution@swift.org>>:
    >>>
    >>> Ceylon uses `Nothing` for the bottom type.
    >>>
    >>> -Thorsten
    >>>
    >>>> Am 05.06.2016 um 20:39 schrieb Charlie Monroe via swift-evolution
    <swift-evolution@swift.org <mailto:swift-evolution@swift.org>>:
    >>>>
    >>>> While None is probably the best way to describe the opposite of
    Any, it would be often mistaken for .None (i.e. Optional) by newcomers
    to the language.
    >>>>
    >>>> I'd personally prefer calling it "Nil" (capital N), which really
    means "nonexistent". The same way ObjC had "nil" for "id" and "Nil" for
    Class. Possibly, to avoid confusion with nil, calling it Null? Though
    that might get confused with NSNull, once the NS prefix gets dropped.
    >>>>
    >>>> Or "Nothing" as in Scala.
    >>>>
    >>>>> On Jun 5, 2016, at 8:26 PM, Антон Жилин via swift-evolution > <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
    >>>>>
    >>>>> The following names were suggested: NoReturn, Bottom, None, Never.
    >>>>> I would pick None, because it looks like opposite to Any and fits
    nicely in generic types.
    >>>>>
    >>>>> I would prefer the type to be simple, and be implemented as a
    case-less enum (not a bottom value, as in Haskell).
    >>>>>
    >>>>> None should be a usual enum, with no compiler magic except that
    functions returning None are equivalent to current @noreturn.
    >>>>>
    >>>>> Example 1.
    >>>>> let x: None?
    >>>>> // ...
    >>>>> let y = x!
    >>>>>
    >>>>> It will trap in runtime not because we discover scary bottom
    thing, as in Haskell, but because x had value Optional.none at that
    moment and we asserted otherwise.
    >>>>> We could prove that it is always true in this case, but compiler
    must be stupid about this.
    >>>>>
    >>>>> Example 2.
    >>>>> Compiler should allow including None in structures. Error will
    show up in constructor, when we will not be able to initialize the field.
    >>>>>
    >>>>> Example 3.
    >>>>> None in an enum case makes that case never appear in values of
    such a type. But compiler can not know about that.
    >>>>>
    >>>>> - Anton
    >>>>> _______________________________________________
    >>>>> swift-evolution mailing list
    >>>>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
    >>>>> https://lists.swift.org/mailman/listinfo/swift-evolution
    >>>>
    >>>> _______________________________________________
    >>>> swift-evolution mailing list
    >>>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
    >>>> https://lists.swift.org/mailman/listinfo/swift-evolution
    >>> _______________________________________________
    >>> swift-evolution mailing list
    >>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
    >>> https://lists.swift.org/mailman/listinfo/swift-evolution
    >> _______________________________________________
    >> swift-evolution mailing list
    >> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
    >> https://lists.swift.org/mailman/listinfo/swift-evolution
    > _______________________________________________
    > swift-evolution mailing list
    > swift-evolution@swift.org <mailto:swift-evolution@swift.org>
    > https://lists.swift.org/mailman/listinfo/swift-evolution

    _______________________________________________
    swift-evolution mailing list
    swift-evolution@swift.org <mailto:swift-evolution@swift.org>
    https://lists.swift.org/mailman/listinfo/swift-evolution

IMHO there is a deep relationship between this discussion, 0092 and a serie of other recent topics (like literal convertibles or the extended existentials). There is no doubt that these questions must and will all be answered individually, however it is my HO that there is a small window of time to standardize the lower levels of the stdlib around a few simple patterns that can directly impact the design of all these solutions (some are already in place, and should likely influence the shape of the answer to this question, regardless of the selected name).

I am gathering a handfull of these really small proposals which I believe make more sense when looked at together.

Regards
(From mobile)

···

On Jun 6, 2016, at 5:26 PM, Tony Allevato via swift-evolution <swift-evolution@swift.org> wrote:

"Nothing" feels like it collides too much with the concept of a function that returns, but returns nothing (i.e., Void), however.

If I read a function declaration from left to right:

    func foo() -> Nothing

I read that as "a function foo that returns nothing". That sounds like a Void function to me. On the other hand:

    func foo() -> Never

I read that as "a function foo that returns never". That's perfectly clear to me.

When it comes to naming things like this, I don't think we should try to shoehorn in the arguably more "pure" names when it runs the risk of causing confusion with Swift's C-based ancestry. I'd argue that it's more important for the language to be clearly readable than to satisfy a notion of absolute adherence to pure formal semantics that only theorists would completely understand. The main audience here is still app developers and perhaps backend developers, not academics.

On Mon, Jun 6, 2016 at 8:16 AM Charlie Monroe via swift-evolution <swift-evolution@swift.org> wrote:
You are thinking of it as a return type, but that's not how you should think of it, really - that's an example of what it may be used for, but it should not be the only aspect.

It should be the opposite of Any, which (excluding None), seems to be Nothing. Or Singularity :)

6. 6. 2016 v 16:12, Vladimir.S via swift-evolution <swift-evolution@swift.org>:

> +1 for Never, as 'foo() -> Never' reads as 'foo returns never' i.e. close to 'never returns'. Or we just need NoReturn as replacement for @noreturn, and then think about true bottom type and its name separately.
>
>> On 06.06.2016 16:37, Thorsten Seitz via swift-evolution wrote:
>> My preference from the current suggestions would be Never.
>>
>> -Thorsten
>>
>>> Am 06.06.2016 um 15:24 schrieb Thorsten Seitz via swift-evolution <swift-evolution@swift.org>:
>>>
>>> Ceylon uses `Nothing` for the bottom type.
>>>
>>> -Thorsten
>>>
>>>> Am 05.06.2016 um 20:39 schrieb Charlie Monroe via swift-evolution <swift-evolution@swift.org>:
>>>>
>>>> While None is probably the best way to describe the opposite of Any, it would be often mistaken for .None (i.e. Optional) by newcomers to the language.
>>>>
>>>> I'd personally prefer calling it "Nil" (capital N), which really means "nonexistent". The same way ObjC had "nil" for "id" and "Nil" for Class. Possibly, to avoid confusion with nil, calling it Null? Though that might get confused with NSNull, once the NS prefix gets dropped.
>>>>
>>>> Or "Nothing" as in Scala.
>>>>
>>>>> On Jun 5, 2016, at 8:26 PM, Антон Жилин via swift-evolution <swift-evolution@swift.org> wrote:
>>>>>
>>>>> The following names were suggested: NoReturn, Bottom, None, Never.
>>>>> I would pick None, because it looks like opposite to Any and fits nicely in generic types.
>>>>>
>>>>> I would prefer the type to be simple, and be implemented as a case-less enum (not a bottom value, as in Haskell).
>>>>>
>>>>> None should be a usual enum, with no compiler magic except that functions returning None are equivalent to current @noreturn.
>>>>>
>>>>> Example 1.
>>>>> let x: None?
>>>>> // ...
>>>>> let y = x!
>>>>>
>>>>> It will trap in runtime not because we discover scary bottom thing, as in Haskell, but because x had value Optional.none at that moment and we asserted otherwise.
>>>>> We could prove that it is always true in this case, but compiler must be stupid about this.
>>>>>
>>>>> Example 2.
>>>>> Compiler should allow including None in structures. Error will show up in constructor, when we will not be able to initialize the field.
>>>>>
>>>>> Example 3.
>>>>> None in an enum case makes that case never appear in values of such a type. But compiler can not know about that.
>>>>>
>>>>> - Anton
>>>>> _______________________________________________
>>>>> swift-evolution mailing list
>>>>> swift-evolution@swift.org
>>>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>>>
>>>> _______________________________________________
>>>> swift-evolution mailing list
>>>> swift-evolution@swift.org
>>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution@swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

I'd argue that it's more important for the language to be clearly readable
than to satisfy a notion of absolute adherence to pure formal semantics
that only theorists would completely understand.

The semantics might help a person better understand the philosophy of the
language. The @noreturn methods are *not* being written very often, and
definitely not by newcomers, who are usually fine knowing there's
fatalError and that's it. For a person who has a deeper insight into the
language, semantic consistency may be good thing.

No, but it will be *read* by many, and those who are reading but not
writing these methods are particularly in need of clarity as to what it
does. A distinction between a method that returns None vs. a method that
returns Void is going to be ridiculously nonsensical for such a user.

In any case, if we need a 'consistent' word, `Never` can be paired with
`Every`.

···

On Mon, Jun 6, 2016 at 10:39 AM, Charlie Monroe via swift-evolution < swift-evolution@swift.org> wrote:

The main audience here is still app developers and perhaps backend
developers, not academics.

On Mon, Jun 6, 2016 at 8:16 AM Charlie Monroe via swift-evolution < > swift-evolution@swift.org> wrote:

You are thinking of it as a return type, but that's not how you should
think of it, really - that's an example of what it may be used for, but it
should not be the only aspect.

It should be the opposite of Any, which (excluding None), seems to be
Nothing. Or Singularity :)

6. 6. 2016 v 16:12, Vladimir.S via swift-evolution <
swift-evolution@swift.org>:

> +1 for Never, as 'foo() -> Never' reads as 'foo returns never' i.e.
close to 'never returns'. Or we just need NoReturn as replacement for
@noreturn, and then think about true bottom type and its name separately.
>
>> On 06.06.2016 16:37, Thorsten Seitz via swift-evolution wrote:
>> My preference from the current suggestions would be Never.
>>
>> -Thorsten
>>
>>> Am 06.06.2016 um 15:24 schrieb Thorsten Seitz via swift-evolution < >> swift-evolution@swift.org>:
>>>
>>> Ceylon uses `Nothing` for the bottom type.
>>>
>>> -Thorsten
>>>
>>>> Am 05.06.2016 um 20:39 schrieb Charlie Monroe via swift-evolution < >> swift-evolution@swift.org>:
>>>>
>>>> While None is probably the best way to describe the opposite of Any,
it would be often mistaken for .None (i.e. Optional) by newcomers to the
language.
>>>>
>>>> I'd personally prefer calling it "Nil" (capital N), which really
means "nonexistent". The same way ObjC had "nil" for "id" and "Nil" for
Class. Possibly, to avoid confusion with nil, calling it Null? Though that
might get confused with NSNull, once the NS prefix gets dropped.
>>>>
>>>> Or "Nothing" as in Scala.
>>>>
>>>>> On Jun 5, 2016, at 8:26 PM, Антон Жилин via swift-evolution < >> swift-evolution@swift.org> wrote:
>>>>>
>>>>> The following names were suggested: NoReturn, Bottom, None, Never.
>>>>> I would pick None, because it looks like opposite to Any and fits
nicely in generic types.
>>>>>
>>>>> I would prefer the type to be simple, and be implemented as a
case-less enum (not a bottom value, as in Haskell).
>>>>>
>>>>> None should be a usual enum, with no compiler magic except that
functions returning None are equivalent to current @noreturn.
>>>>>
>>>>> Example 1.
>>>>> let x: None?
>>>>> // ...
>>>>> let y = x!
>>>>>
>>>>> It will trap in runtime not because we discover scary bottom thing,
as in Haskell, but because x had value Optional.none at that moment and we
asserted otherwise.
>>>>> We could prove that it is always true in this case, but compiler
must be stupid about this.
>>>>>
>>>>> Example 2.
>>>>> Compiler should allow including None in structures. Error will show
up in constructor, when we will not be able to initialize the field.
>>>>>
>>>>> Example 3.
>>>>> None in an enum case makes that case never appear in values of such
a type. But compiler can not know about that.
>>>>>
>>>>> - Anton
>>>>> _______________________________________________
>>>>> swift-evolution mailing list
>>>>> swift-evolution@swift.org
>>>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>>>
>>>> _______________________________________________
>>>> swift-evolution mailing list
>>>> swift-evolution@swift.org
>>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution@swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

I disagree. We are discussing how to annotate a function in some way so that the compiler knows that the code following it will never be executed *and* so a human who reads the declaration knows that it does not return. “Never" is a poor choice for that. Never what? Never return? Never use this function? Never say never again?

Call it NoReturn as the comment you quoted suggests.

If you want bottom types for other uses, give them their own appropriate and self documenting names.

···

On 6 Jun 2016, at 16:37, Vladimir.S via swift-evolution <swift-evolution@swift.org> wrote:

My opinion is based on this message:

On 05.06.2016 23:16, L. Mihalkovic via swift-evolution wrote:
>
> FWIW, in the rejection of SE-0097
> <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160530/019879.html&gt;,
> this was what the core team had to say about it:
>
> /1) For noreturn, the core team prefers to explore a solution where a
> function can be declared as returning an non-constructable “bottom”
> type (e.g. an enum with zero cases). This would lead to something like:/
> /
> /
> /func abort() -> NoReturn { … }/

I.e. we need some type that will reflect "NoReturn" at first. Then, probably, it can be used as bottom type. IMO `Never` is the best candidate at this moment. For me it also can mean "never can have an instance of this type" or "never be created" or "never be user”