On Sat, 2 Oct 2021 at 00:54, Andreas Hennings <andr...@dqxtech.net> wrote:

> Hello list,
> I would like to propose new methods for ReflectionType, that would
> allow treating ReflectionNamedType and ReflectionUnionType in a
> unified way.
> This would eliminate the need for if (.. instanceof) in many use cases.
>
> Some details can still be discussed, e.g. whether 'null' should be
> included in builtin type names, whether there should be a canonical
> ordering of type names, whether we should use class names as array
> keys, etc.
>
> [...]
>
> What do you think?
>
> -- Andreas


I don't think this is a good idea, at least in a form like this.
I understand that the ReflectionType API is cumbersome but I don't think
merging everything together makes a lot of sense.
Want does need to know if one is dealing with a Union, Intersection, or
single type and conflating the APIs is IMHO a bad idea as it doesn't
consider future extensions.
And I am not talking about more complex composite types such as
(A&B)|C|(X&Y), as those will be handled within the existing design, but
potential additions to the type system like function types, literal types,
generics, etc.

I also don't really understand what the argument for removing instanceof
checks is other than more generic code which works, but if this breaks at
the next type system addition, this seems rather pointless.

Best regards,

George P. Banyard

Reply via email to