Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!cs.utexas.edu!utnut!nott!cunews!omega.scs.carleton.ca!ug940002
From: ug940002@omega.scs.carleton.ca (Alex Fitzpatrick)
Subject: Re: whileTrue:
Message-ID: <Cyp5Lq.Ksu@cunews.carleton.ca>
Sender: news@cunews.carleton.ca (News Administrator)
Organization: School of Computer Science, Carleton U., Ottawa, Canada
X-Newsreader: TIN [version 1.2 PL2]
References: <9411022316.AA04248@sci.brooklyn.cuny.edu>
Date: Thu, 3 Nov 1994 14:58:38 GMT
Lines: 30

Gerald Weiss 718-951-5945 (weiss@SCI.BROOKLYN.CUNY.EDU) wrote:
: I'm sure I'm being dense, but could someone explain the following
: implementation of whileTrue: from GNU Smalltalk? Isn't the embedded
: whileTrue: message simply a recursive one, and if so, where is the
: escape clause?

: The way I read it, the second function (using the unary selector whileTrue)
: is a syntactic convenience, not an escape clause for the whileTrue:



: !BlockContext methodsFor: 'basic'!

: whileTrue: aBlock
:     [ self value ] whileTrue: [ aBlock value ].
:     ^nil
: !

: whileTrue
:     ^[ self value ] whileTrue: []
: ! !!

I tried it and it works, don't ask me how or why but it works!

Maybe I'll show it to Lalonde and ask him...


--


