Path: utzoo!attcan!uunet!hsi!stpstn!cox From: cox@stpstn.UUCP (Brad Cox) Newsgroups: comp.object Subject: Re: code blocks (Was: Re: Objective-C review) Message-ID: <5305@stpstn.UUCP> Date: 30 Jun 90 19:22:23 GMT References: <12396@june.cs.washington.edu> <1112@carol.fwi.uva.nl> Reply-To: cox@stpstn.UUCP (Brad Cox) Organization: Stepstone Lines: 32 In article <1112@carol.fwi.uva.nl> delft@fwi.uva.nl (Andre van Delft) writes: :John Maloney writes: :How would code blocks in C look like? No, a block (I prefer the word 'action') should be an *expression*, not a *statement*. The following syntax might suffice (assuming that C compound statement syntax can be parsed specially to denote block instantion when used as an expression). id aLocalVariable; aBlock = { action for subsequent invocation, which might and often will reference variables like aLocalVariable, formal arguments, etc. }; [aMenu selectAction:aBlock]; or [aCollection do:{ id blockFormalArgument; | [blockFormalArgument someOperation]; }]; or [ { action to run concurrently} fork]; or [ { action that might fail } with:{ action for handling exceptions}]; The main thing that makes blocks nontrivial is references from the block into the instantation-site's local variables. -- Brad Cox; cox@stepstone.com; CI$ 71230,647; 203 426 1875 The Stepstone Corporation; 75 Glen Road; Sandy Hook CT 06482