[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] [APPROVE] asBoolean



the only thing really Cish in here is Number returning false if it is zero, which is also the thing i am most ambivalent about and which i'd be glad to drop. i don't really see how the rest is Cish in that you have to explicitly ask for the behaviour. the main point of the idea is precisely to have object return true. you use it in circumstances when you don't want to have to write a whole lot of support code to test whether something is false or nil or an object and you want to write a simple if statement to check it. in javascript which is actually a pretty neat little language imho you can just go "if( someVariable )" and nil is treated like false and objects like true.

// test.html
<script>

var x = 4;
var y = false;
var z;

if( x ) window.document.write("x\n");

if( y ) window.document.write("y\n");

if( z ) window.document.write("z\n");

</script>

here only "x" will be printed in your browser window. this *is* Cish and in scripting like language like js it also happens to be a big coding convenience. i don't think an explicit version of this would hurt anything in sc. i can just add it to my own library, but i do think it is more generally useful.

_c

On 29/10/2004, at 5:53 AM, James McCartney wrote:

C boolean semantics. why?


On Oct 27, 2004, at 8:08 PM, ccos wrote:

<x-tad-smaller>+ </x-tad-smaller><x-tad-smaller>Object</x-tad-smaller><x-tad-smaller> {
asBoolean { ^</x-tad-smaller><x-tad-smaller>true</x-tad-smaller><x-tad-smaller> }
}
+ </x-tad-smaller><x-tad-smaller>Nil</x-tad-smaller><x-tad-smaller> {
asBoolean { ^</x-tad-smaller><x-tad-smaller>false</x-tad-smaller><x-tad-smaller> }
}
</x-tad-smaller><x-tad-smaller>// True inherits from object</x-tad-smaller><x-tad-smaller>
+ </x-tad-smaller><x-tad-smaller>False</x-tad-smaller><x-tad-smaller> {
asBoolean { ^</x-tad-smaller><x-tad-smaller>this</x-tad-smaller><x-tad-smaller> }
}
+ </x-tad-smaller><x-tad-smaller>Number</x-tad-smaller><x-tad-smaller> {
asBoolean { ^</x-tad-smaller><x-tad-smaller>this</x-tad-smaller><x-tad-smaller> != 0 }
}

</x-tad-smaller>
_______________________________________________
sc-dev mailing list
sc-dev@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-dev
_______________________________________________
sc-dev mailing list
sc-dev@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-dev