Path: news.daimi.aau.dk!news.uni-c.dk!sunic!trane.uninett.no!nntp.uio.no!ifi.uio.no!nntp!alfh From: alfh@byleist.ifi.uio.no (Alf-Ivar Holm) Newsgroups: comp.lang.beta Subject: Recursive, double INNER Followup-To: comp.lang.beta Date: 06 Feb 1995 19:42:01 GMT Organization: Dept. of Informatics, University of Oslo, Norway Lines: 73 Message-ID: NNTP-Posting-Host: byleist.ifi.uio.no CC: This is a recursive function with two INNER clauses: forAllThings: (# do INNER; ... &forAllThings ... INNER; #); The main problem here is that the user of the function has to know about the double INNER and make some code to identify which INNER is being processed. I thought that I could overcome this by changing the two INNER parts to two virtual functions, 'before' and 'after': forAllThings: (# before:< object; after:< object; do before; ... &forAllThings ... after; #); It works, but there are one more problem, if you make a sub pattern, e.g. forAllDingbats, the forAllThings super pattern is still called. Next thought: Make a virtual function, 'callMe', which is bound to the current (sub)pattern: forAllThings: (# before:< object; after:< object; callMe:< forAllThings; do before; ... &callMe ... after; #); Now, I can make forAllDingbats and bind callMe to that sub pattern: forAllDingbats: forAllThings (# before::< (# ... #); after::< (# ... #); callMe::< forAllDingbats; #); Finally, I would usually use forAllThings directly, not making a specific sub pattern: do ... &forAllThings (# before::< (# ... #); after::< (# ... #); callMe::< (* What am I supposed to put here? *) ; #); My problem is that I don't manage to bind callMe to that specific instance. What am I missing? Some minor syntactic detail? Some major fundamental issues about programming or BETA? A course about rewriting recursive algorithms to non-recursive? Affi