Re: No call for Ada (was Re: Announcing new scripting/prototyping language)

From: Rob Thorpe (robert.thorpe_at_antenova.com)
Date: 02/11/04


Date: 11 Feb 2004 11:31:30 -0800

Ludovic Brenta <ludovic.brenta@insalien.org> wrote in message news:<m3fzdlyrh1.fsf@insalien.org>...
...
> which is not possible in C:
>
> typedef enum { YES, NO, MAYBE, MAYBE_NOT } assessment_t;
>
> void P (assessment_t A) { }
>
> int main () {
> P (42); // no compiler check!
> return 0;
> }

In C enums are interchangable with ints so there is no error, though
there maybe the compiler should give a warning.

A C++ compiler should check
I got:

bash-2.05b$ g++ -Wall fiddle.cpp
fiddle.cpp: In function `int main()':
fiddle.cpp:6: error: invalid conversion from `int' to `assessment_t'



Relevant Pages

  • Re: It Pays to Enrich Your C Skills
    ... Check if you can score a perfect 10 (without using a compiler). ... int main{ ... struct bitfield { ... out if it is a negative integer constant or a constant expression ...
    (comp.lang.c.moderated)
  • Re: cpu type idea
    ... compiler related recently. ... int main ... float a; ... just to parallelize the vectror and tensor operations. ...
    (alt.lang.asm)
  • Re: [CodeGallery] MFC MD5 Calculator
    ... Then when they added types, internally, the compiler still thought they were int values, ... ANSI standard began to emerge that the language design ...
    (microsoft.public.vc.mfc)
  • Re: extended operators
    ... uint32_t u32rotl{ ... my compiler currently doesn't handle constants this large... ... together a "cleaner" way of dealing with temporary text buffers, ... different sets of tokens. ...
    (comp.std.c)
  • Re: problem with output of the program on different OS
    ... for those few remaining millions that don't have a C99 compiler. ... assert that it's not -1... ... int index, i; ... for N, you want *numpoints, right? ...
    (comp.lang.c)