On Friday, December 29, 2017 8:20:14 AM CST Stephen Reay wrote:
> > On 29 Dec 2017, at 19:56, Fleshgrinder <p...@fleshgrinder.com> wrote:
> >> On 12/29/2017 1:26 PM, Rowan Collins wrote:
> >> On 29 December 2017 12:08:16 GMT+00:00, Fleshgrinder
> >> 
> >> <p...@fleshgrinder.com> wrote:
> >>> What is the use case for `int|float`? I mean, if f is able to
> >>> process a `float` than f is able to process an `int` and since
> >>> `int` is already automatically changed to a `float`, well, you're
> >>> done.
> >> 
> >> I think it is somewhat tedious if we discuss every possible pair of
> >> types, just as it would be somewhat messy if we added a new keyword
> >> for every combination we found a use case for. The beauty of a
> >> general-purpose syntax is precisely that a user can use whatever
> >> combination they need, and not use combinations they don't need. I'm
> >> sure there are plenty of nonsensical or redundant checks that can be
> >> expressed in other parts of the language, but that doesn't mean those
> >> language constructs are useless or damaging.
> >> 
> >> Regards,
> > 
> > I agree and I do not intend to do so, I actually am not even questioning
> > the usefulness of union and intersection types. I am more curious in
> > regards to providing a `number` type. Seems useless to me.
> 
> I'm not sure "number" as a predefined type union is necessary but int|float
> would allow a method to accept either in strict mode, and as you said it
> would also be useful for eg a formatting function.

I think he's referring more to the fact that int -> float is the only auto-cast 
allowed in strict mode, so it's not a great example of where a scalar union 
type would be useful.  Which is a fair point.

Nonetheless, it sounds like we're all saying the same thing: 

The fact that there are cases where a union or intersection declaration would 
be nonsensical or arguably poor design doesn't change the fact that there are 
plenty of cases where they would be entirely sensible and very good design, 
and building a bunch of one-off custom unions (scalar, number, mixed, 
iterable, etc.) is a poor substitute.

So to those who voted against allowing Foo && Bar as a declaration, why?  More 
specifically, what would get you to change your vote to allow general union/
intersection types, so we don't need all of these one-offs?

--Larry Garfield

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to