Path: news.daimi.aau.dk!not-for-mail From: Erik Ernst Newsgroups: comp.lang.beta Subject: Re: leaving a pattern? Date: 03 Sep 1997 19:04:02 +0200 Organization: DAIMI, Computer Science Dept. of Aarhus Univ. Lines: 74 Distribution: all Message-ID: References: <5tguc5$r4n$1@gjallar.daimi.aau.dk> <5tiboo$2h6$1@gjallar.daimi.aau.dk> NNTP-Posting-Host: fraxinus.daimi.aau.dk Mime-Version: 1.0 (generated by tm-edit 1.1.1.6.2.1) Content-Type: text/plain; charset=US-ASCII X-Newsreader: Gnus v5.3/Emacs 19.33 Xref: news.daimi.aau.dk comp.lang.beta:11251 jlk@daimi.aau.dk (Jorgen Lindskov Knudsen) writes: > > In <5tguc5$r4n$1@gjallar.daimi.aau.dk> jojo@daimi.aau.dk (Johanna Wiederhold) writes: > > >transaction: > > (# > > abort :(# do leave transaction #); > > ... > > do > > INNER > > #); > > >[causes an] error message: > > >leave transaction > >***** "leave P" or "restart P", where "P" is a pattern, > > is only legal in the do-part of "P" > > > >If you know a solution, let me know. > >[..] > > There is no real good solution to this. > > Why does this not work as one might expect (as you definitely thought). > Let us elaborate a little on your example: > > (# myTrans: @transaction; > ... > do ... > myTrans.abort; > ... > #) > > This shows why...when executing myTrans.about, myTrans is not on the > execution stack, leaving the semantics of 'leave transaction' > undefined (what should it 'leave'). > > This restriction in the compiler is inserted to avoid these (and > similar) problems. But since we could simply do (# pv: ##object do L: (# p: (# do leave L #) do p##->pv## #); pv (* 'leave L', but the inserted item is not on the stack now *) #) executing "homeless" leave/restart instructions is generally possible anyway. We don't have to use pattern variables, dynamic references would do, of course. It just causes an 'attempt to leave basic component' error message, because the stack unwinding machinery did not find an appropriate object on the stack to stop at. Not really worse than "divide by zero", and not better either.. Another thing is that it ought to stop the current thread, not the entire program, both when "divide by zero" and "leaving last component" happens. I believe this will happen as soon as somebody gets it implemented, though. So I think it should be allowed. Forbidding it is almost taking a safety-by-obscurity approach, which is usually not a clean solution to anything. And certain things _are_ easier to express with it, like your example. I have used a similar construct as my "L"/"p" example above several times, and it works nicely. It shouldn't be hard to implement either, at least it was no problem to support it in my interpreter ;-) -- Erik Ernst eernst@daimi.aau.dk Computer Science Department of Aarhus University, Denmark Check