# Candid explainer: First post published

**URL:** <https://forum.dfinity.org/t/candid-explainer-first-post-published/6787>\
**Category:** Language Support\
**Created:** [August 29, 2021, 3:59pm UTC](https://forum.dfinity.org/t/candid-explainer-first-post-published/6787 "2021-08-29T15:59:12Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![levi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/levi/32/22608_2.png) [@levi](https://forum.dfinity.org/u/levi)\
**Post date:** [September 15, 2021, 5:44pm UTC](https://forum.dfinity.org/t/candid-explainer-first-post-published/6787/21 "2021-09-15T17:44:01Z")

</div>

> [@rossberg](#):
>
> First of all, the technical definition of value is not dependent on usefulness of values, that would be absurd.

HA!

> [@rossberg](#):
>
> Now, the `null` variant is a subtype of the `opt` variant.

If you want to make null a variant that is fine with me and even a shortcut Null candid keyword as long as over the wire it is a variant. The Option-type can as well be a variant over the wire I think that is better

> [@rossberg](#):
>
> Having said all that, the type `null` also is in fact useful. For example, it allows the use of variants as enums in the first place: in Candid, the type `variant {a; b}` is in fact just a shorthand for `variant {a : null; b : null}` .

We already went over this, reserved can be used here (or empty).

> [@rossberg](#):
>
> Now, assume you just need a set. Then you can use this canister with type `V = null`

You can use reserved here as well. (And side point why on earth would anyone want to use a canister that is made specific for a map key,value store as a set? What an example.)

> [@rossberg](#):
>
> ```auto
> foo : (bar : func (nat, null) -> (nat)) -> (nat)
> 
> ```
> 
> This documents the intent while being backwards compatible with callers passing a callback that still allows an option.

- This can only be backwards compatible if the canister checks for people sending options and skips them.
- a canister which makes new clients send it a null value is just a waste.
- if this was a legitimate case, the canister can use the type: Reserved .

---

<div class="post-metadata">

**Author:** ![rossberg](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/rossberg/32/795_2.png) [@rossberg](https://forum.dfinity.org/u/rossberg)\
**Post date:** [September 16, 2021, 6:48am UTC](https://forum.dfinity.org/t/candid-explainer-first-post-published/6787/22 "2021-09-16T06:48:24Z")

</div>

> [@levi](#):
>
> > [@rossberg](#):
> >
> > Having said all that, the type `null` also is in fact useful. For example, it allows the use of variants as enums in the first place: in Candid, the type `variant {a; b}` is in fact just a shorthand for `variant {a : null; b : null}` .
> 
> We already went over this, reserved can be used here (or empty).

Indeed, we already went over this, and I already explained earlier that `empty` can _not_ be used, since you would not be able to construct any values of the variant then.

Technically, `reserved` could be used, but would not convey the same information, namely that the argument is unused and doesn’t need to be stored. Reserved rather means that the argument can be anything but you don’t care (yet) what it is.

> [@levi](#):
>
> (And side point why on earth would anyone want to use a canister that is made specific for a map key,value store as a set? What an example.)

Quite a practical example, in fact. When you only have a map at your disposal but need a set, that’s what you do. Been there done that.

> [@levi](#):
>
> - This can only be backwards compatible if the canister checks for people sending options and skips them.

I think you missed out on the higher-order nature of this example: it’s the canister itself who sends these values.

> [@levi](#):
>
> - a canister which makes new clients send it a null value is just a waste.

It has no choice if it wants to avoid breaking existing clients. And FWIW, sending values of type `null` takes up zero space in the wire format.

> [@levi](#):
>
> - if this was a legitimate case, the canister can use the type: Reserved .

Again, that would not be a backwards-compatible choice.

---

<div class="post-metadata">

**Author:** ![levi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/levi/32/22608_2.png) [@levi](https://forum.dfinity.org/u/levi)\
**Post date:** [September 17, 2021, 5:54pm UTC](https://forum.dfinity.org/t/candid-explainer-first-post-published/6787/23 "2021-09-17T17:54:14Z")

</div>

> [@rossberg](#):
>
> > [@levi](#):
> >
> > > [@rossberg](#):
> > >
> > > Having said all that, the type `null` also is in fact useful. For example, it allows the use of variants as enums in the first place: in Candid, the type `variant {a; b}` is in fact just a shorthand for `variant {a : null; b : null}` .
> > 
> > We already went over this, reserved can be used here (or empty).
> 
> Indeed, we already went over this, and I already explained earlier that `empty` can _not_ be used, since you would not be able to construct any values of the variant then.

@rossberg I see, you put this line in the spec:  
`// NB: M(_ : empty) will never be called`  
This line is a waste. Only there to make the null value try to make sense. If this line (the M-function of the Empty type) is: `M(_ : empty) = .` this is correct because it is, in the most literal and logical sense, an empty data-sequence (as it says in the spec: “The following notation is used: ‘.’ is the empty byte sequence.” the spec uses the word empty here because the ‘.’ is an empty byte-sequence which fits with the word empty. ). The Empty-type has a type-code in the current-spec: 0x6f, the only reason you are saying it can’t be used as the value of a variant is because of this line: `// NB: M(_ : empty) will never be called` , which can change for the line: `M(_ : empty) = .` which will make the Empty-type good for the use as a value in the variants (it already has a type-code). Then we can get rid of that null type.

---

<div class="post-metadata">

**Author:** ![nomeata](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nomeata/32/733_2.png) [@nomeata](https://forum.dfinity.org/u/nomeata)\
**Post date:** [September 18, 2021, 6:42am UTC](https://forum.dfinity.org/t/candid-explainer-first-post-published/6787/24 "2021-09-18T06:42:17Z")

</div>

Now you are confusing `null` and `empty`, which are very different beasts.

---

<div class="post-metadata">

**Author:** ![rossberg](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/rossberg/32/795_2.png) [@rossberg](https://forum.dfinity.org/u/rossberg)\
**Post date:** [September 20, 2021, 6:49am UTC](https://forum.dfinity.org/t/candid-explainer-first-post-published/6787/25 "2021-09-20T06:49:22Z")

</div>

One take-away from this thread perhaps is that the name `empty` is confusing – apparently, some read that as “type with an empty value”, not “empty type”, and even explaining it several times doesn’t make up for the initial misunderstanding.

I wonder if we should rename it to `impossible`?

---

<div class="post-metadata">

**Author:** ![nomeata](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nomeata/32/733_2.png) [@nomeata](https://forum.dfinity.org/u/nomeata)\
**Post date:** [September 20, 2021, 7:39am UTC](https://forum.dfinity.org/t/candid-explainer-first-post-published/6787/26 "2021-09-20T07:39:52Z")

</div>

Maybe. How about `none`?

---

<div class="post-metadata">

**Author:** ![nomeata](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nomeata/32/733_2.png) [@nomeata](https://forum.dfinity.org/u/nomeata)\
**Post date:** [September 20, 2021, 7:53am UTC](https://forum.dfinity.org/t/candid-explainer-first-post-published/6787/27 "2021-09-20T07:53:16Z")

</div>

But TBH I think `empty` is a fine name, and I am pessimistic that there exists a name that will significantly reduce confusion. Some things just need to be explained, no matter what the name, and the concept of a type without any values is certainly not intuitive.

---

<div class="post-metadata">

**Author:** ![Sherlocked](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/sherlocked/32/3256_2.png) [@Sherlocked](https://forum.dfinity.org/u/Sherlocked)\
**Post date:** [September 24, 2021, 8:49pm UTC](https://forum.dfinity.org/t/candid-explainer-first-post-published/6787/28 "2021-09-24T20:49:22Z")

</div>

the explainer was useful, thank you!

[Previous page](https://forum.dfinity.org/t/candid-explainer-first-post-published/6787.md?page=1)
