Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84; site opus.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!hao!cires!nbires!opus!rcd From: rcd@opus.UUCP (Dick Dunn) Newsgroups: net.lang.c Subject: Re: YAAO and `with' Message-ID: <985@opus.UUCP> Date: Wed, 19-Dec-84 01:01:13 EST Article-I.D.: opus.985 Posted: Wed Dec 19 01:01:13 1984 Date-Received: Thu, 20-Dec-84 05:22:01 EST References: <209@cmu-cs-k.ARPA> <529@vu44.UUCP> <6616@brl-tgr.ARPA> Organization: NBI,Inc, Boulder CO Lines: 31 > > Dean Rubine asked for a ->= operator,... (Sorry about the grandparental nature of the reference for the followup.) The desire for ->= (assign from subfield) comes from one case of a more general desire--working on a referenced object in some convenient way. Consider as an alternative something like the Pascal `with' clause. (No, put down the torch, I don't mean to consider adding it to C! Just consider it for a hypothetical language.) The semantics of `with', somewhat simplified, is that in the form with do must be a reference to a structure, and within the fields of that structure are accessible without prefixing them with the structure reference. For example (here, "^" is Pascal's pointer-de- reference), one Pascal idiom is" while p<>nil do with p^ do begin . . . p := next; end where "next" is a field of the record referenced by p; without the `with' the statement would have been written p := p^.next The `with' is useful in a lot of other situations, such as filling in several fields of the same record. The usual implementation is to grab a pointer to the base of the structure, taking care of any address calculations in the , and try to keep the pointer in a register. -- Dick Dunn {hao,ucbvax,allegra}!nbires!rcd (303)444-5710 x3086 ...Nothing left to do but smile, smile, smile.