Path: utzoo!mnetor!uunet!husc6!hao!noao!arizona!naucse!rrr From: rrr@naucse.UUCP (Bob Rose ) Newsgroups: comp.lang.c Subject: Re: The D Programming Language Message-ID: <602@naucse.UUCP> Date: 8 Mar 88 20:51:31 GMT References: <25284@cca.CCA.COM> <1354@laidbak.UUCP> Organization: Northern Arizona University, Flagstaff, AZ Lines: 45 In article <1354@laidbak.UUCP>, daveb@laidbak.UUCP (Dave Burton) writes: > In article <25284@cca.CCA.COM> g-rh@CCA.CCA.COM.UUCP (Richard Harter) writes: > >I would like to be able to return several items from a function. > Please don't design D until you understand C. > C has had pass by reference for a very long time (since its inception?). > The following useless code illustrates: > > int flag, foobar(); > x = foobar(&flag); > ... > int foobar(arg) int *arg; > {*arg = 1;return 0;} > > Now, what could be simpler? Easy [int, int] foobar() /* prototype */ .... [x, flag] = foobar(); .... [int, int] foobar() { return [0, 1]; } Yes I admit this looks a bit strange but look at some of the things we can do with multi assignments [x, y] = [y, x] /* swap */ The only question is should we be allowed to index this stuff so if (([x, flag] = foobar())[1]) { /* the flag was true */ .... } Anyone for comp.lang.d Robert R. Rose Northern Arizona University, Box 15600 Flagstaff, AZ 86011 .....!ihnp4!arizona!naucse!rrr