Path: news.daimi.aau.dk!olevi From: olevi@daimi.aau.dk (Ole Villumsen) Newsgroups: comp.lang.beta Subject: Re: what is a pattern? Date: 12 Sep 1994 15:14:24 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 95 Message-ID: <351r8g$rkv@belfort.daimi.aau.dk> References: <34n5ad$36s@gort.oit.umass.edu> <34nbas$a8d@belfort.daimi.aau.dk> NNTP-Posting-Host: angers.daimi.aau.dk rodrigo vanegas writes: >In article <34nbas$a8d@belfort.daimi.aau.dk>, olevi@daimi.aau.dk (Ole Villumsen) writes: ... >Ok, if you explained something, i think i may have missed it. If >"pattern" is just a generic word for class, procedure, and function >and/or anything starting with "(#" and ending with "#)" then it would >seem that lisp has patterns too. After all, Lisp has classes, >procedures, and functions, and they all start with "(" and end with ")". >So what's the innovation here? How about a slightly more concrete >definition? I was hoping someone else would jump in here, but since noone did, I will try. I suspect the result will be less readable than my earlier posting; but I hope it will be good enough. Especially people who are a bit used to reading OO language specifications should profit from reading on. A pattern is used for instantiating objects (static objects, inserted objects, dynamic objects etc.). A pattern declaration in its basic form goes like this (other forms below): P: S (# decl1; decl2; ... decln; enter enterlist do imperatives exit exitlist #); This declares P a (direct) subpattern of S. (S thus is a (direct) superpattern of P.) "S" can be omitted, in which case "object" (the direct or indirect superpattern of all patterns) is assumed. Each part (declarations, enter part, do part and exit part) can also be omitted. (Thus P: (# #); is legal.) Each decli can be a declaration of a pattern, a virtual pattern, a further or final binding of a previously declared virtual pattern, a static item, a dynamic item, a static component, a dynamic component, a repetition (array) or a pattern variable (used for holding a pattern (popularly speaking)). Or a number of same. Thus the above declaration of P fits into an outer pattern. If both P and S have declared enter parts, the enter list of a P-object consists of the enter lists concatenated. The same goes for the exit list. Thus the subpattern declaration can only add to the enter and exit lists, not make other changes. A bit more complicated rules exist for do-parts, but the basic principle is the same: only additions are possible. A pattern can be virtual. There are 3 forms of a virtual pattern declaration: P: (# V:< Q; #); (* This is a comment telling you that V is virtual *) P: (# V:< R (# ... #); #); P: (# V:< (# ... #); #); - where Q and R are pattern names. As before, in the third case "object" is the implicit superpattern of V. (For the sake of completeness, I should write P: S (# ...; V:< Q; ...; enter ... do ... exit ... #); P: S (# ...; V:< R (# ...; enter ... do ... exit ... #); ...; enter ... do ... exit ... #); etc. - but I'll leave that out.) Virtual declarations can be extended, *further bound*, in subpatterns of the outer pattern (P): P1: P (# V::< Q1; #); P1: P (# V::< Q1 (# ... #); #); P1: P (# V::< (# ... #); #); In the first two forms, it is required that - either V was declared in P (or some superpattern of P) as V:< Q (first form above) and Q1 is a direct or indirect subpattern of Q. - or V was already further bound in P (or some superpattern of P) using the form V::< Q, and Q1 is a direct or indirect subpattern of Q. The further binding thus makes V a subpattern of what it was before. The third form V::< (# ... #) can be used no matter which of the forms was used for the previous declaration or further binding of V. The descriptor (# ... #) is used for forming a subpattern of the pattern that described V before (its *qualification*, to talk Beta). Finally, a virtual pattern can be *finally bound*. A final binding is a further binding, except (syntax) :: is used instead of ::< , and (semantics) after a final binding, V is no longer virtual, thus cannot be further bound. The example program posted by Joergen Lindskov Knudsen shows some nice uses of further bindings. Congratulations if you've read this far. Was it that bad? Ole Source: Ole Lehrmann Madsen et al.: Object-Oriented Programming in the BETA Programming Language. acm press and Addison-Wesley.