<br><br><div class="gmail_quote">On Sat, Dec 5, 2009 at 11:18 AM, David T. Lewis <span dir="ltr"><<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Sat, Dec 05, 2009 at 02:48:21PM +0100, Bert Freudenberg wrote:<br>
> On 05.12.2009, at 14:29, Randal L. Schwartz wrote:<br>
> ><br>
> >>>>>> "Bert" == Bert Freudenberg <<a href="mailto:bert@freudenbergs.de">bert@freudenbergs.de</a>> writes:<br>
> ><br>
> > Bert> I don't think it would break any sane application. #asInteger is<br>
> > Bert> descriptive, and "feels right" to me. Reading "asBit" I'd expect it to<br>
> > Bert> return an instance of Bit.<br>
> ><br>
> > Bert> I have not really felt the need for such a method, but I can see how<br>
> > Bert> it's tempting to have, in particular when porting code.<br>
> ><br>
> > It's also "according to who". 0 as false, 1 as true is only one encoding,<br>
> > and clearly not universal. I've worked with systems where 0 is false,<br>
> > and -1 is true.<br>
><br>
> I knew someone would bring this up ;) I also like to KISS.<br>
><br>
> This is not about internal representation, but about doing arithmetic with<br>
> booleans. I don't think any other mapping than "true asInteger = 1" and<br>
> "false asInteger = 0" makes sense in that context.<br>
<br>
</div>I don't think that arithmetic with booleans makes sense in any context.<br>
<br>
Is this convenience method really worth muddying up the distinction between<br>
numbers and booleans? Think of all the C programmers with bad habits<br>
(like me for example) who have had to stop and think twice about assuming<br>
that a number means the same thing as true or false.<br>
<br>
It seems to me that maintaining a clear distinction between numbers and<br>
booleans is a Good Idea even if it does require some extra typing.<br></blockquote><div><br></div><div>yes, yes. But real Smalltalk programs have to interface with external programming languages, typically through a C-inlfuenced ABI. In that context it makes sense. I second Bert's proposal, true asInteger == 1 and: [false asInteger == 0].</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
$0.02<br>
<br>
Dave<br>
<br>
<br>
</blockquote></div><br>