[squeak-dev] How to tell if you have a boolean when you care to know

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] How to tell if you have a boolean when you care to know

Jerome Peace


In another tread Keith Hodges wrote:

2009/3/24 Keith Hodges <keith_hodges at yahoo.co.uk>

> true xor: [ true ]  => true
>
> discuss
>
> Keith

a simple guard for a boolean can be written simply.

true xor: bar aBoolean

will throw an error when bar is not a boolean

if
Boolean>>aBoolean
^self
and all other classes agree not to implement aBoolean,

This pattern can be extended to do all sorts of dynamic type checking.

Keith: Great bug find says Puck.

Elliot: +1 for your proposed fix for #xor:

Yours in curiosity and service, --Jerome Peace

and his imaginative friend Puck, fearless bug finder and Trouble Maker.




     

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] How to tell if you have a boolean when you care to know

Michael van der Gulik-2
On 3/25/09, Jerome Peace <[hidden email]> wrote:

>
>
> In another tread Keith Hodges wrote:
>
> 2009/3/24 Keith Hodges <keith_hodges at yahoo.co.uk>
>
>> true xor: [ true ]  => true
>>
>> discuss
>>
>> Keith
>
> a simple guard for a boolean can be written simply.
>
> true xor: bar aBoolean

Don't you mean >>asBoolean?

Gulik.

--
http://gulik.pbwiki.com/

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] How to tell if you have a boolean when you care to know

Jerome Peace
In reply to this post by Jerome Peace

Opps forgot to send to the list.


--- On Wed, 3/25/09, Jerome Peace <[hidden email]> wrote:

> From: Jerome Peace <[hidden email]>
> Subject: Re: [squeak-dev] How to tell if you have a boolean when you care to  know
> To: "Michael van der Gulik" <[hidden email]>
> Date: Wednesday, March 25, 2009, 5:42 PM
> --- On Wed, 3/25/09, Michael van der Gulik
> <[hidden email]> wrote:
>
> > From: Michael van der Gulik <[hidden email]>
> > Subject: Re: [squeak-dev] How to tell if you have a
> boolean when you care to  know
> > To: [hidden email], "The
> general-purpose Squeak developers list"
> <[hidden email]>
> > Date: Wednesday, March 25, 2009, 5:01 PM
> > On 3/25/09, Jerome Peace
> <[hidden email]>
> > wrote:
> > >
> > >
> > > In another tread Keith Hodges wrote:
> > >
> > > 2009/3/24 Keith Hodges <keith_hodges at
> > yahoo.co.uk>
> > >
> > >> true xor: [ true ]  => true
> > >>
> > >> discuss
> > >>
> > >> Keith
> > >
> > > a simple guard for a boolean can be written
> simply.
> > >
> > > true xor: bar aBoolean
> >
> > Don't you mean >>asBoolean?
>
> Absolutely NOT. Reread the original post.
>
> asBoolean returns true or false for all objects.
> The expectations is that objects other than Booleans will
> return true or false.
>
> The purpose of aBoolean is to throw an error when foo is
> not a boolean.
>
> The elaborate form of the message would be
>
> surelyYourABoolean
>
> "To which non Booleans would reply"
>
> ^self error: 'No I'm not a boolean and stop calling
> me Shirley.'
>
> Which I got from remembering Leslie Nielson in the movie
> Airplane. :)
>
> Thanks for giving me a chance to clear that up.
>
> Yours in curiosity and service, --Jerome Peace