Path: utzoo!attcan!uunet!brunix!doorknob!jak From: jak@cs.brown.edu (Jak Kirman) Newsgroups: comp.lang.c++ Subject: Re: default arguments Message-ID: Date: 7 Mar 90 15:12:38 GMT References: <820@xyzzy.UUCP> Sender: news@brunix.UUCP Reply-To: jak@cs.brown.edu Organization: Brown University Department of Computer Science Lines: 39 In-reply-to: langley@bigbird.rtp.dg.com's message of 5 Mar 90 14:23:17 GMT 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... Surely you can't be serious about this? You are proposing dynamic scoping for C++. C and C++ have always been lexically scoped, and the problems with dynamic scoping are so great that languages like Lisp, which used to be dynamically scoped, are moving away from it. Consider: - How can you guarantee that any i and j will be in scope when bar is called? You would have to look at the context of every call to bar to decide this. - How do you decide which i and j should be used? You have to scan up the stack at run-time -- a very expensive proposition. - How can you do any reasoning on your program when you have no idea which i and j are going to be used? Jak ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ARPA/BITNET : jak@cs.brown.edu Tel : (401) 863 7664 Snail : 86 Benevolent St, Providence, 02906 RI. Tel : (401) 272 6149 "You'll have to forgive me. I have a memory like a... like a... what are those things you drain rice in?" -- Douglas Adams, "Dirk Gently's..."