Path: news.cs.au.dk!not-for-mail From: nospam2159@cs.au.dk (Peter von der Ahé) Newsgroups: comp.lang.beta Subject: Re: Virtual attribute gives Seg Fault when accessed from pattern ref Date: 03 May 1999 17:25:15 +0200 Organization: University of Aarhus, Department of Computer Science (DAIMI) Lines: 74 Message-ID: References: <7gi6gi$99i$1@nnrp1.dejanews.com> <372D57DD.41C6@cs.au.dk> <7gkb3t$vho$1@nnrp1.dejanews.com> NNTP-Posting-Host: ufleku.cs.au.dk Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: xinwen.cs.au.dk 925744932 2124270 255.255.255.255 (3 May 1999 15:22:12 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 3 May 1999 15:22:12 GMT X-Attribution: Ahe User-Agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.3 Xref: news.cs.au.dk comp.lang.beta:11913 >>>>> "AK" == Andrew Klaassen writes: AK> ... Function: (# ... Printname: (#...#); do ... #); ... do AK> Function.Printname; (* doesn't compile *) ... AK> which doesn't compile at all. Nor does AK> &Function.Printname; AK> Why not? This will create a new instance of the Pattern "Function.Printname". Do to that the Function needs to be an object, otherwise Printname has no origin or surrounding environment. "(&Function).Printname" should work. This uses a computed reference. A computed reference has the form: (EXPRESSION).ATTRIBUTE where EXPRESSION must return a reference qualified by something which has an attribute ATTRIBUTE. But this is probably not what you want to do, PrintName might depend on some other attributes in Function, consider: Function: (# name: @text; printName: (# do name[] -> putLine #); do ... #); In this case (&Function).printName will do nothing interesting, whereas: myFunction: @Function; do 'Hello, World!' -> myFunction.printName will print something interesting. Another thing to consider is efficiency, if you intend that Function should be a collection of some methods used for similar things, it will be more efficent to say: Function: @(# printName: (# ... #); someOtherMethod: (# ... #) #); do (for i: 10 repeat Function.printName for) than Function: (# printName: (# ... #); someOtherMethod: (# ... #) #); do (for i: 10 repeat (&Function).printName for) Where the latter will have to allocate a new instance of the pattern Function at each iteration. Cheers, Peter -- · Peter von der Ahé · Systems programmer · · Office phone: +45 89 42 31 41 · Office: 540.030 · · ·