Name another language that's completely and 100% backwards compatible after a major version upgrade.

Look. C++ is quite compatible with C89 in the sense that most C89 programs you could think of would compile in C++ and produce identical behaiviour. It's not "completely and 100% backwards compatible", but I think it's at least as compatible as perl6 would be with perl5 (I'd bet this even on this stage of p6).

It's a bit OT, but for those of you who know C++ well, it's worth to think of a way to write a program that does something different in C89 and C++, work reliably and portably in both, but not in some obvious way like checking for a macro that only one of them defines.

I know of four ways but all of them use sizeof. The first uses the fact that apostrophe char-literals are of a different type in C and C++. The second uses that the visibility of a type declared inside a structure is different. The third uses the fact that struct labels are optional in C++ but not in C. The fourth is the only one that's my own invention:

typedef double number; struct hypergeom { number a, b, c; }; struct { struct hypergeom operator, (number); } function; int main(void) { if(sizeof(number) == sizeof(function = function, (number)4)) printf("C89\n"); else printf("C++\n"); return 0; }

I'd like to see a way to do this without sizeof. I couldn't figure out any even with the help of this list: http://david.tribble.com/text/cdiffs.htm. If you know any, please tell me.

Also C99 is quite compatible with C89. (On the other hand, C89 is not that compatible with original K&R C, nor is C++ compatible with C99.)


In reply to Re: Why Perl 6 is taking so !@#$ long by ambrus
in thread Why Perl 6 is taking so !@#$ long by dragonchild

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.