6.19.10.2.3. begin/end blocks

The @begin() command creates a new scope, by pushing a new input_frame onto the input stack. The @end() command is used to end a @begin() block. An unbalanced @end() command can be used to terminate input from a file before the physical end of file.

Use of begin/end blocks is important to limit the lifetime of various objects. In particular, if a tangler is writing code to a named_file_sink, then the file will not be closed properly until it is destroyed.

Start python section to interscript/frames/inputf.py[9 /42 ] Next Prev First Last
   349: #line 422 "input_frame.ipk"
   350:   def begin(self):
   351:     "Begin a block"
   352:     ho = self.head_offset
   353:     self.select(None)
   354:     inpt = input_frame(
   355:       self.pass_frame,
   356:       self.source,
   357:       [],
   358:       self.current_weaver,
   359:       self.userdict.copy(),
   360:       self.depth)
   361:     inpt.head_offset = ho
   362:     inpt.set_warning_character(python=self.python_warn)
   363:     inpt.file_pass()
   364: 
   365:   def end(self):
   366:     "end a block"
   367:     self.select(None)
   368:     raise eoi
   369: 
End python section to interscript/frames/inputf.py[9]


6.19.10.2.3.1. Begin/end test