Re: switch with case 0 [message #182609 is a reply to message #182607] |
Sat, 17 August 2013 18:39 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 17/08/13 18:58, Tim Streater wrote:
> In article <kuo9bl$4h9$1(at)news(dot)albasani(dot)net>,
> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>
>> On 17/08/13 16:56, Peter H. Coffin wrote:
>>> Strong-typing introduces its own complications: Are we going to cast
>>> implicitly between numeric types?
>>
>> No.
>>> it makes me 100% behind "We're a loosely-typed language and it works
>>> how it works. If you want to know HOW it's going to work in a
>>> particular case, don't guess, test or look at the source. Which we
>>> make available." That is the problem in a nutshell. With a strongly
>> typed language I
>> don't HAVE to look at the source code. Ther are no implicit rules.There
>> are only explicit rules and if I say:
>>
>> float c;
>>
>> I don't mean char c, char * c; cha** c, char c[]. int c, double c or int
>> *float(c) ; or anything else.
>> and I HOPE the compiler will tell me I am being sloppy when I return
>> a zero from a function that should return a pointer.
>>
>> and furthermore if I say case 0: , it doesn't mean case '0' or case "0"
>> or case 0.0 but it can surely mean (because its defined that way) case
>> FALSE, and may mean case NULL. but with a few errors thrown up abut
>> implicit casts.
>
> I'd rather not have to bother. And I like to be able to do:
>
>
> $num = (some calculation here);
>
> if ($num==0) $num = "no";
> echo "There were " . $num . " widgets\n";
well all you have to do is
char temp[256]; int num;
num = (some calculation here);
printf("There were %s widgets! " num? itoa(num, temp,10): "no");
Shorter than your example.
--
Ineptocracy
(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
|
|
|