DIP19: Remove comma operator from D and provision better syntactic support for tuples
ponce
spam at spam.org
Mon Sep 24 12:53:11 PDT 2012
On Sunday, 23 September 2012 at 21:51:35 UTC, Nick Sabalausky
wrote:
>
> *Logically* speaking, is there really any difference between a
> one-element tuple and an ordinary single value? I don't think
> so, and
> here's why: What is a tuple, logically speaking? Multiple
> values being
> handled as if they were a single value. So what's a one-element
> tuple?
> *One* value being handled as if it were one value - which is
> *is*.
>
> Similarly, a zero-element tuple is logically equivalent to void
> (or the
> one value a void can have: the value void, a concept which has
> been
> argued in the past that might be useful for D, particularly in
> metaprogramming). (I admit this is a little weaker than my
> argument
> for one-element tuples.)
>
> So perhaps zero- and one-element tuples should be implicitly
> convertible back and forth with void and ordinary non-tuple
> values,
> respectively (polysemous values?), because that's what they
> essentially
> are.
It's informative to look a bit at the Ocaml language:
- no distinction between 1-tuple and single value:
# 1;;
- : int = 1
# (1);;
- : int = 1
- "void" type is called unit and its notation is the empty
tuple:
# ();;
- : unit = ()
- for some reason tuples can't be indexed in Ocaml
More information about the Digitalmars-d
mailing list