Path: news.daimi.aau.dk!jco From: jco@daimi.aau.dk (Jens Cornelius Olsen) Newsgroups: comp.lang.beta Subject: Re: Recursive, double INNER Date: 9 Feb 1995 17:56:29 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 80 Message-ID: <3hdl0d$c2l@belfort.daimi.aau.dk> References: NNTP-Posting-Host: rennes.daimi.aau.dk Thus spake alfh@byleist.ifi.uio.no (Alf-Ivar Holm): > ... >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; > #); Nice try ! > ... >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 My solution would be to use THIS() and pattern variables. In a *true* recursive version this amounts to something like this forAllThings: (# before:< object; after:< object; callMe: ##forAllThings; do before; this(forAllThings)##-> callMe##; &callMe; after; #); Where the pattern variable is used to duplicate the subpattern of forAllThings in question. From previous email correspondance with Ole Lehrmann Madsen, one of the designers of BETA, I know that it was (or is) considered to include a shorter version of the two statements involving callMe in the syntax: &(this(forAllThings)##) but for now we are forced to use the callMe variable. \Jens ______________________________________________________________________________ Jens Cornelius Olsen, Email: jco@daimi.aau.dk Student at Aarhus University, Office: B18/B1.13, phone: +45 89 42 33 48 Home: Skelagervej 181, phone: +45 86 10 91 65 8200 Aarhus N, Denmark, Europe. ______________________________________________________________________________