Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!zephyr.ens.tek.com!uw-beaver!Teknowledge.COM!unix!hplabs!hpfcso!hpldola!patch From: patch@hpldola.HP.COM (Pat Chkoreff) Newsgroups: comp.lang.c++ Subject: Re: default arg handling Message-ID: <11430021@hpldola.HP.COM> Date: 16 Mar 90 19:39:01 GMT References: <1116@xyzzy.UUCP> Organization: HP Elec. Design Div. -ColoSpgs Lines: 50 / hpldola:comp.lang.c++ / shap@delrey.sgi.com (Jonathan Shapiro) / 12:52 pm Mar 14, 1990 / >>In article <11430020@hpldola.HP.COM> patch@hpldola.HP.COM (Pat Chkoreff) writes: >/ hpldola:comp.lang.c++ / shap@delrey.sgi.com (Jonathan Shapiro) / 4:13 pm Mar 10, 1990 / > >> As Mark Langley has pointed out, the supplying of default arguments should >> be thought of as the responsibility of the caller, not part of the function >> definition. > > De facto, C++ says otherwise. If what you say were true, the > following would be legal: > > extern foo(int = 5); > > ... > > extern foo(int = 10); > > in the same file. Note that C++ disallows this. > > Jon According to Mark Langley's policy, the example above should NOT be legal, because the caller's responsibility is ambiguous. The implementation of his policy which I proposed would in fact correctly reject the example. Here's why. The compiler would generate the following: extern int foo(int); // extern foo(int = 5); static int foo() { return foo(5); } // ... extern int foo(int); // extern foo(int = 10); static int foo() // This is line "10". { return foo(10); } This itself is not legal, because foo() is declared twice: CC: "t.c", line 10: error 1034: two definitions of foo() I still do not see a problem with either Mark Langley's policy or my implementation of it. Patrick Chkoreff 719-590-5983 {hpfcla,hplabs}!hpldola!patch