Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-04-19 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found