DMD 0.148 release

Derek Parnell derek at psych.ward
Sun Feb 26 00:59:01 PST 2006


On Sun, 26 Feb 2006 19:39:48 +1100, bobef <bobef at lessequal.com> wrote:

> Derek Parnell wrote:
>>  Zero is frequently used to implement the concept of falsehood and  
>> likewise non-zero for truth, however the semantics of integers is not  
>> the same as the semantics of booleans. But because many C programers  
>> are just *so* used to thinking this way they have become to believe  
>> that zero *is* falsehood rather than just a number chosen to implement  
>> the concept.
>>
>
> Just thoughts...
>
> Well back in school we were learning boolean algebra. (for some  
> electrical crap... I don't remember... I don't care...). Even if we take  
> just the name 'boolean algebra' it means it used for calculations, which  
> means it is number not falsehood...

Not so. It is possible to create 'calculations' using purely logic  
expressions. The result is not a number but one of 'false' or 'true' (or  
unknown). Fuzzy logic calulations are more of a numerical field  
(probablilty theory).

> After all it used for all these logical operators which operate with  
> numbers not falsehood...

Well I'm sure it operates on relationships between numbers and not the  
numbers themselves.

> If we say it is not calculations and it is logical operations, well it  
> is not, else it would be only true, false, if a to b is false and c to b  
> is true then a to c is ... this kind of stuff. But it is actually used  
> for numbers and calculations, because 01101010<<0202 is not logic  
> anymore it is mathematics which is also logic but other kind than  
> true/false, logic for the quantity of things not their rightness...

Ok whatever ... but I was talking about what one gets when one compares  
things with other things in relative terms or similar...

e.g.   a < b  ==> true or false


> And one more thing. If it is falsehood indeed, then it is something  
> abstract. Technically speaking True and False have any meaning only in  
> the context of each other, i.e. in the context of some logic, system or  
> whatever, not in the context of numbers. So how are you going to convert  
> from number to falsehood?

By agreeing on a convention that is convenient.

> This would limit us to writing only bool a=true || bool a=false, which  
> seems annoying to me. bool a=1 is shorter ;].

Yes it is shorter, but it is not descriptive of your intention. Did you  
want 'a' to be set to 1 or to true? In other words, is the 'bool' a  
mistake and really meant 'int'? Because the use of 1 in this way is  
ambiguous it ought to be made cleaner / clearer to future maintainers.

> Plus there will be no if(a), if(b), because a is always true or always  
> false by itself, it should relate to something else to be right or  
> wrong, so we will always have to write if(a==1), if(b==null) instead, so  
> I like it this way ;]

I take the syntax form  'if (<numeric-expression>)' to just be shorthand  
for 'if (<numeric-expression> != 0)' and thus it would still be valid  
syntax and get you the result you were expecting. No relaxation of boolean  
sematrics is required.

> Am I talking nonsese? :)

No.

-- 
Derek Parnell
Melbourne, Australia



More information about the Digitalmars-d-announce mailing list