You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by "Peter B. West" <li...@pbw.id.au> on 2008/06/01 03:40:21 UTC

Re: try without catch in BlockStackingLM.getNextKnuthElements

Andreas Delmelle wrote:
> On May 29, 2008, at 18:23, Vincent Hennebert wrote:
> 
>> Could anybody explain me what is the purpose of the following piece of
>> code:
>>     if (!breakBeforeServed) {
>>         try {
>>             if (addKnuthElementsForBreakBefore(returnList, context)) {
>>                 return returnList;
>>             }
>>         } finally {
>>             breakBeforeServed = true;
>>         }
>>     }
>> that we can find, for instance, in BlockStackingLM.getNextKnuthElements?
> 
> Can't explain, other than that it seems to be a remnant of some 
> refactoring cycle without subsequential cleanup...
> 
>>
>> Isn’t it equivalent to the following:
>>     if (!breakBeforeServed) {
>>         breakBeforeServed = true;
>>         if (addKnuthElementsForBreakBefore(returnList, context)) {
>>             return returnList;
>>         }
>>     }
> 
> Indeed, this has the exact same outcome AFAICT.
> 
> 
> Cheers
> 
> Andreas
> 
> 
What's the scope of breakBeforeServed?

-- 
Peter B. West <http://cv.pbw.id.au/>
Folio <http://defoe.sourceforge.net/folio/>

Re: try without catch in BlockStackingLM.getNextKnuthElements

Posted by Andreas Delmelle <an...@telenet.be>.
On Jun 1, 2008, at 03:40, Peter B. West wrote:

> Andreas Delmelle wrote:
>> On May 29, 2008, at 18:23, Vincent Hennebert wrote:
>>> Could anybody explain me what is the purpose of the following  
>>> piece of
>>> code:
>>>     if (!breakBeforeServed) {
>>>         try {
>>>             if (addKnuthElementsForBreakBefore(returnList,  
>>> context)) {
>>>                 return returnList;
>>>             }
>>>         } finally {
>>>             breakBeforeServed = true;
>>>         }
>>>     }
>>> that we can find, for instance, in  
>>> BlockStackingLM.getNextKnuthElements?
>> Can't explain, other than that it seems to be a remnant of some  
>> refactoring cycle without subsequential cleanup...
>>>
>>> Isn’t it equivalent to the following:
>>>     if (!breakBeforeServed) {
>>>         breakBeforeServed = true;
>>>         if (addKnuthElementsForBreakBefore(returnList, context)) {
>>>             return returnList;
>>>         }
>>>     }
>> Indeed, this has the exact same outcome AFAICT.
>>
> What's the scope of breakBeforeServed?

Protected instance member. On top of that, the method call  
addKnuthElementsForBreakBefore() can only throw an Exception in case  
adding elements to the passed List would fail for some reason, and  
the value for breakBeforeServed is definitely not used in that method  
(otherwise there would be a good reason why it's set only after the  
call).


Cheers

Andreas