> On Dec 9, 2020, at 3:29 PM, Benjamin Morel <[email protected]> wrote:
> 
> On Wed, 9 Dec 2020 at 19:48, Mike Schinkel <[email protected] 
> <mailto:[email protected]>> wrote:
> 
> 5. Someone else mentioned shortcut syntax, which I would like to mention 
> again, although I realize implement details might make this a non-starter.  
> 
> So if I have a function that accepts a Size from above, e.g.:
> 
> function show(Size $size) {}
> 
> Then it would be great if we could call the function like this since its 
> parameter was type-hinted:
> 
> show(::Medium) 
> 
> Rather than always having to write:
> 
> show(Size::Medium) 
> 
> So can we consider a shortcut syntax?
> 
> I'm not sure what value a shortcut syntax would bring, but it would surely 
> break, or at least make ambiguous, union types:
> 
>     function show(Enum1|Enum2 $value)  {}
>     show(::Medium)
> 
> Which enum would Medium resolve to?

Good question.  

What *could* happen is:

1. It could resolve to the Enum that has a ::Medium, 

2. Or it could be disallowed for union type hints (probably the better option 
as adding a "Medium" to the other enum could inadvertently break code that 
calls it.)

3. This suggestion could just be tabled.


Again, I am just asking if this is something we could consider because it would 
be nice to shorten line length in cases where expressions get really long.


Maybe a different question could be if a "use" statement could empower making 
explicit shorthands/aliases?


-Mike

P.S. I completely understand if either of these things are out of scope for 
this RFC.

Reply via email to