[PHP-DEV] [CONCEPT][DISCUSSION] Instance as boolean

2020-07-08 Thread Josh Bruce
Link to working draft: https://bit.ly/php-0001 Discussion on implementing a means by which a class instance can interacted with syntactically as a boolean. At this point in the discuss the only means discussed is creation of a method (magic or via an interface). Abili

Re: [PHP-DEV] [CONCEPT][DISCUSSION] Instance as boolean

2020-07-08 Thread Marcio Almada
Hello Josh, > Link to working draft: https://bit.ly/php-0001 >From a type safety POV I'd prefer to have an interface available, the same way we did to the Stringable interface RFC. But I'd rather keep these engine affecting behaviors with the same magic method naming con

Re: [PHP-DEV] [CONCEPT][DISCUSSION] Instance as boolean

2020-07-09 Thread Josh Bruce
> On Jul 8, 2020, at 12:54 PM, Marcio Almada wrote: > > Hello Josh, > >> Link to working draft: https://bit.ly/php-0001 > > From a type safety POV I'd prefer to have an interface available, the > same way we did > to the Stringable interface RFC. But I'd rather keep t

Re: [PHP-DEV] [CONCEPT][DISCUSSION] Instance as boolean

2020-07-09 Thread Marcio Almada
Hi > > Re casting - In the previous thread the following concern was presented and I > don’t know enough about that area to respond effectively: "I'd endorse > avoiding object-to- casts via cast operations: they are a good source > of bugs. My rationale for the discouragement of magic cast meth

Re: [PHP-DEV] [CONCEPT][DISCUSSION] Instance as boolean

2020-07-09 Thread Marco Pivetta
Hey Marcio, On Thu, Jul 9, 2020 at 7:49 PM Marcio Almada wrote: > Hi > > > > > Re casting - In the previous thread the following concern was presented > and I don’t know enough about that area to respond effectively: "I'd > endorse avoiding object-to- casts via cast operations: they are a > good

Re: [PHP-DEV] [CONCEPT][DISCUSSION] Instance as boolean

2020-07-09 Thread Marcio Almada
Hi, > > Hey Marcio, > >> >> Hi >> >> > >> > Re casting - In the previous thread the following concern was presented >> > and I don’t know enough about that area to respond effectively: "I'd >> > endorse avoiding object-to- casts via cast operations: they are a >> > good source of bugs. My ratio

Re: [PHP-DEV] [CONCEPT][DISCUSSION] Instance as boolean

2020-07-10 Thread Josh Bruce
>>> >>> Frankly this is something subject to personal opinions and will change >>> over time according to community shifts. >>> >> >> Not sure what's "subject to personal opinions" in the objective bug exposed >> in the snippet above? >> > > So there is a bug in a contrived code snippet ther

Re: [PHP-DEV] [CONCEPT][DISCUSSION] Instance as boolean

2020-07-11 Thread Larry Garfield
On Wed, Jul 8, 2020, at 11:39 AM, Josh Bruce wrote: > Link to working draft: https://bit.ly/php-0001 > > Discussion on implementing a means by which a class instance can > interacted with syntactically as a boolean. > > At this point in the discuss the only means discus

Re: [PHP-DEV] [CONCEPT][DISCUSSION] Instance as boolean

2020-07-12 Thread Josh Bruce
> > Focusing on Bool is, I think, a good choice because it has an argument for it > other than "well it works for strings." You hint at it in the writeup but > really bury the lead: Null objects. > > Being able to not use null or false as a "not found" case and instead return > an "empty" val