Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!bionet!ames!sgi!shinobu!odin!delrey!shap From: shap@delrey.sgi.com (Jonathan Shapiro) Newsgroups: comp.lang.c++ Subject: Re: default argument discussion Message-ID: <5102@odin.SGI.COM> Date: 9 Mar 90 23:37:39 GMT References: <1006@xyzzy.UUCP> Sender: news@odin.SGI.COM Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 35 >langley@bigbird.rtp.dg.com (Mark L Langley) suggests that the following >should be legal: > > void bar(int x=i+j) { > printf("%d\n", x); > } > > main() { > int i=20, j=30; > bar(); > } > ...I intend to propose this as a change in ANSI C++, and have already > proposed it to AT&T in private correspondance... > >Mark Langley >langley@dg-rtp.dg.com This is a great example of why language design should be left to people who know what they're doing. C already has a facility for doing this. It is called a macro. The problem with what you suggest is that the function definition site needs to know lots and lots of things about ALL function use sites. It also would be altogether impossible to implement this across files today. Functions should be isolated - they should not care who calls them, except to the extent that they specify requirements in the form of arguments. The above proposal violates this any number of ways. Try proposing it to the BASIC committee. They love this sort of stuff. Jonathan Shapiro