Path: utzoo!attcan!uunet!ogicse!uwm.edu!cs.utexas.edu!rice!uw-beaver!Teknowledge.COM!unix!hplabs!hpl-opus!hpccc!hpcc01!hp-ses!hpcuhb!hpcllla!hpclisp!hpclscu!shankar From: shankar@hpclscu.HP.COM (Shankar Unni) Newsgroups: comp.lang.c++ Subject: Re: default arguments Message-ID: <58170008@hpclscu.HP.COM> Date: 9 Mar 90 20:33:53 GMT References: <820@xyzzy.UUCP> Organization: Hewlett-Packard Calif. Language Lab Lines: 38 > > 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. > Hello, "thunks"!! (Who called them that? Hoare?) > - 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. Does anyone remember the famous "call-by-name" in Algol 6*? Just as an example (at undergrad school), I tried calculating the Ackermann function (I tried "ackermann(3,4)" for a decent data point) using both call-by-name (the default!) and call-by-value, and got: Call by value : 6 seconds (OK, so it was a slow machine :-/) Call by name : >1200 seconds (The job was killed by the sysadmin) Mark, are you still serious about your proposal? I suggest a re-reading of some elementary (and preferably slightly old) principles-of-programming-languages text (Pratt, or the collection of papers by Dahl, Dijkstra, and Hoare) for a description of call-by-name, and what has to be done to implement it. ----- Shankar Unni E-Mail: shankar@hpda.hp.com Hewlett-Packard California Language Lab.