Session 6

Of the videos, this is the sixth session.

This will get replaced with the video (if the JavaScript runs properly).

The following is the comment I had left on YouTube, before comments were disabled:

Topic of this one: semantics. (The part of TeX that actually does things: the "stomach"?)

The image of the TeX program that this lecture starts with is also printed at the back of TeX: The Program, and was published in TUGboat https://tug.org/TUGboat/tb03-2/tb06software.pdf (a copy here https://i.imgur.com/6rVsaj6.png)

To follow along the module numbers (as the modern texdoc tex gives slightly different numbers), at the bottom of https://cs.stanford.edu/~knuth/programs.html there is a tex.web as of the version at the time this was posted. (But present-day cweave and present-day TeX don’t process it correctly.)

The transcript below is autogenerated from YouTube, and needs to be cleaned up.

oh ok so that was syntax and now kind of semantics this is lecture number six and semantics seriously is the big region in the middle that touches the local variables all is a equivalence table and and gets I next token here and there from syntax routines and then I divided part of it here into the part of tech 82 that’s doing math well this is all really semantics and the math was just one big chunk of it I’m not going to talk anymore about math and this hour except saying it’s more of the same as what we’re going to be doing so the things that we’re going to be talking about now is part of this is part of text Maddox and and with math it’s just similar and and there you can find it in the code where there’s special data structures for math so the in the dynamic memory we not only have h list node V list node so on but we have different kinds of things called no ads noad that are used for the things that can occur there like fractions and square roots over line binary relations and so on new data structures for math new and special part of the semantic routines that set up those data structures print them out and and change them into the kind of data structures that the rest of tech knows about the big big routine in math is called MLS to ageless this converts an M list math type list into an H list a horizontal type list and then the rest of tech knows what to do with H list so those are those are somehow sort of self-contained into a world and themselves so i called it math on here and it represents about forty percent of the code for semantics intact we’ll talk about the other sixty percent in this hour so that you get in then of those you want to look at the others be able to follow that in this in the same way to start out the semantics I suppose we ought to talk about the the big switch of tech this is the or the so-called chief executive the program that takes over when tech is is running mention that tech consists of lots of procedures and then there’s a little driver program at the end that starts the procedure is going well the thing that that it starts going is called main control and this is where where are we here chief executive sections 906 on page 318 the this is the hub of the web this is where everything comes together when I was writing main control I had to get a new desk to work on with the whole tech program spread out all over the desk because I had to be picking up you know remembering what all the subroutines do and all the naming conventions that I had used there but I and I had my finger in several places always at once because this is referring to the rest of the program and drive and picks up the other things starts them going at one this part of the program also has been made a little bit more complicated to read because its inner loop stuff when you when you’re going through a paragraph and trying to to set text this is the high priority for for the money of the thing so the main control procedure consists of has been tuned in order to to go fast on on the on the text so main control looks something like this big switch is says get MC token and then Reese which is another label where we could come back to in case we didn’t like the token we got and we want to try again without getting another one however we want to use it again in some other slight disguise and here there’s a bunch of little code for pause for interrupt you can interrupt at this point and you can also little tracing commands will print out the command that had got here so when we were running yesterday and it said here’s how I got a blank space here’s where the letter B came through that was at this point research but except for this diagnostic information then it’s a big case and its case amps of mode plus ker command of and then we have a bunch of things that will be like V mode + + skip and this would be 4 plus V skips a4a V skip that occurs in vertical mode and H mode plus h skip might be another another case so here’s a cake another type of right where I split into many many cases by adding together the current command to to something v mode has been set up an HMO they’ve been set up to be spaced apart so that these will these will all give us a unique unique division in two cases ok now that now I suppose there is also an M mode + H skip because a skip is allowed in that mode and then in most of these cases there will be a there will just be a procedure call here like I don’t know that you but do glue or something it won’t be called applets but it will be there will be a procedure call here and that’s called an action procedure then in your in your listing there will be another module say little therapy called declare action procedures needed in main module in in main control and and another one of the action procedures will be procedure do glue and then it’ll do it’ll actually do the it will actually do the the thing that that you wanted to do for these three cases now the reason I separate this out is because a lot of people have to use Pascal compilers that put restrictions on how big a procedure can be and and so main control procedure if I had all of these if I’ll have all these semantics inside the main control procedure it would weigh exceed these this limit especially on IBM machine which wants everything to fit into a small area that they can use only two base registers for so so the the so main control consists mostly of this case statement and calls on procedures the only exception is the cases that are really in the mainstream for the for the inner loop something like for example H mode plus letter H mode plus letter H mode plus other char this is what you find in the middle of in the middle of text and this is handled right in the main control procedure itself and the end with the things that will look for ligatures and do those things there are a few other things like spaces between words which were considered important enough to put most of the most of their code the the common code for space between words also in main control procedure now the the kirkham and is one of these command codes that section 201 lists always command code section 201 of the next ones and we take a look at those codes to read we looked yesterday at the first I paid shuttin 201 we looked at the first 16 cause but on page 202 it shows the Mexico’s and in this extends way also we got a code like char num that’s for the backslash ghar math char num mark input X ray is the internal code name for show instructions and make box H move all of these all of these are command codes for different things tech has to do all the way goes to the next page now the next page by the way can we have the house lights on a little more so that people can read people yeah that better okay can you see it enough in the first row because you get some of the light from this guy okay thanks so now the the codes above max non prefixed command which is a which changes from day to day as tech gets larger or smaller but it’s now equal to 69 these codes up 70 and hot and up to 91 here are all are all things that somebody might want to say is global or so on may be outer or deaf or something but you have these commands that there will take a prefix and they’re independent of the mode if you really had to cut down Main Control further and Andy and you had too many cases to handle you could rewrite it so that Reese which would check if Kirk command is bigger than max non prefix command then then do a prefixed command else do a case statement like this and you could wreak then you could cut down the definition of H mode H mode is now I think 91 you can cut it down to 70 so that you would know it’s so that these branches because because all the all these codes 70 up to 91 are really done this you do the same thing for them independent of the mode and all of them really just call the one procedure called prefix command so like I didn’t do that now because why should I add something to the inner loop if I some code to make a diff destiny in a loop if I it’s not necessary but you could cut down the size of main control x 3 x 20 cases in that case statement since they all go to the same place and they’re all consecutive or three consecutive regions of the of the cases do that now the codes above max command are the ones that get NC token will will wipe out you undefined control sequence will not get through I will marks top mark by marc all long-haul outer call long outer call these last won’t even occur through the scanner please appear in leaky cute up the EQ table but they’re only used to tell for purposes of when we are updating the data structure to tell whether we need to update reference counts or not so so these last things don’t have to do it’s with coming through get next at all but these six here are taken care of by get NC token so that’s what the kirkham and will be one of these codes now suppose you wanted to you wanted to figure out how tech does a certain a certain thing like let’s try to figure out suppose you didn’t happen to know that x-ray was the internal code of show box but you wanted to see well holic how the heck does tech to a show box okay well the answer is look in the index under showbox primitive and for every primitive of tech there are two hundred and forty two or three of these they’re listed in that same kind of a fashion like showbox primitive here is on page 4 30 and it’s alphabetized under SH not under backslash there are three or four primitives that are only one character long and those are indexed under single character primitives right here on the same page fortunately a show bak there four of them and but otherwise the primitives have are made out of letters in there and so some of that will refer you to wear where the primitive was actually loaded into the hashtable every primitive is put into text hash table by the any tech program and this’ll particular one was done in module 1159 so if we turn to 1159 we will see of course not word where we’re paging around in this code without looking at the environment too much but here we’ll see call on primitive procedure showbox now the this procedure primitive is what’s used to enter all the primitive so I call it 242 times and there’s a module 2 18 says put each of text primitives into the hash table and this is one of the one of the things that belongs with that module because of the plus here and so all these and that module 2 18 would refer you to all the calls on primitive if you really wanted a list of all the primitives now showbox then is put in with and then here’s the command and the chur the modifier to commence is a command code for show boxes x-ray and the character a modified is show box code so that if somebody writes showbox what comes through text scanner is Kirk command will be X ray and kercher will be show box code which we’ve defined here to be one right after putting something in primitive i also have a have a case of the print command and char procedure there’s a procedure that we have to use when we’re tracing commands that’s going to come that’s going to be used in reefs which here to print the thing out in symbolic form it’s not going to say you’re doing command number 12 / char is one it’s going to want to say show box and so in so x-ray inside of that procedure is going to just is going to look at the butcher code and it’s going and it’s going to find showbox cold air so it will print show box with an escape character in front of it and so then then you’ll see what what came through in this print command and procedure it’s supposed to be robust it’s supposed to be able to handle cases that can’t ever really be there there’s no way for a tech user to put two to get command x-ray associated with any code other than these here tech music can never enter of the something in the hash table whose command is x-ray only the primitive procedure is allowed to do this but for anything but but you guys could do this but by changing a web listing doing something you know you could you can get anything into into that eq TV especially if you make a mistake so so this print command and chair procedure has to never give an error message specifically but calling error it actually can be used inside of other routines which we wouldn’t want to to lead to an error message but there has to do something in all cases well it’s just going to say show in all those other cases sometimes if I think there’s really a chance that somebody would have would want to know that it was a bad one I I would have I would have rewritten this if I felt really needed and I would have show called printing show and the other cases would say unknown x-ray or something like that but I I want to make sure that that you know that the procedure it does always have a do something in every case that doesn’t let and abort your job so then showbox comes through as x-ray but what about now how does that I could get acted on well it’s we could now find that by looking in the index under x-ray to see whether we’re x-ray is used but that would refer to write back the previous page so save us to save time we look here and we say cases of main control that don’t depend on mode one of them is going to be any mode x-ray and it’s going to call a procedure called show whatever so sure whatever is one of these action procedures I’m talking about it and and most of the semantics are done by action procedures like that and here it is in the next page there on module 1 1161 the clear action procedures for useful main control one of the things is procedure show whatever and this is a it looks at the Kercher and if it’s show box code then it gets us to module 1164 show the current contents of a box okay well turn the page 7 64 show the current contents of a box can 8-bit integer that’s a special routine that calls scan integer and make and if it’s not between 0 and 255 it gives you an error message saying that it should have been between 0 and 255 and that is changing it 2-0 on you then we print a new line and this greater than sign in box and we print integer curv al scan AP dinger reduced puts its answer in curv al some of the reasons i wanted to use a global for this because almost because all the time i’m scanning something and I don’t want to have to have a new local every time for the dumb thing and actually specifically assign it but I got to be careful of course that I don’t it doesn’t get wiped out by something else in the meantime and that’s the danger the well-known dangers of global variables are that somebody else if everybody uses curv al like if print new line would use curv al I’d certainly be in trouble so you do this only one you know that your use of the thing is going to be near the near the time it was actually stored in global variable otherwise in trouble ins and also I couldn’t do this I well if I if I made main control recursive so that people would incorporate a whole tech job inside of another one then I would have to have curv al be local to main control all right now print char equal sign so box whatever is going to be equal to and then we have two cases but it’s just known as the refers to box of kerrville this is a macro that refers to a position in eq TB the current value of of that box and it’s the pointer to box it’s either an ageless Notre vives note if the box is there but if it’s null that means that the Box there’s no box there and take calls that absent otherwise we use the Showbox routine it displays all these boxes out in various lines using the the Showbox depth and showbox breadth parameters to call off and explain how much is actually being shown then we give an error then we give an error message okay that’s not really an error in the help message that goes with that was described in the previous page there it says we saw it yesterday this isn’t an error message i’m just showing something that’s the whole thing that’s a semantics for sure box and it’s typical of a simple case of semantics and there are 91 times three branches to this thing so about two hundred seventy three cases you switch into from this Reese which procedure and one by one you check those off and make sure that that tech is doing the right thing on okay now you want to add something to tech the extensions usually come through a single place let me see if I can find the or extensions detect we talked about that a second module 2 12 09 right near the end is where extensions are discussed and and it’s worth reading that just to get a feeling for what you have to do work I suppose you added a new feature detect how many different parts of tech would actually be changed to accommodate that feature well you’ve got to put a new primitive in the hash table you got to maybe put a new kind of what’s at node type into your data structure I see Lyle sitting here and near the front row he’s put in the feature at Xerox I prints in color so he knows I with me what goes on in these thing but there’s a various places where you have to wear where tech would actually get X ended and we and try to make most of those all be possible to put them into this one place extensions and provide hooks into the main program that are selected that you don’t have to affect the rest of it I got a beep from something warning five minutes to automatic log out and then you see okay yeah i don’t know if i’ll use the computer but i wanted to make be logged in just in case excuse me and so so these hooks are shown in the inner sections they are following 1209 and most of the case though we won’t have to we won’t have to add a new command code if we’re lucky we won’t have to add anything to main control because of what’s there because there’s one in the command code is called extension and it just has a chirp art that says what kind of extension you have so if possible when you make an extension to tech use extension as your command code and just give another turf field and then the action procedure that you get is let me see right there 1216 module 1216 is any mode extension do extension and cause the action procedure in 1217 do extension which disparate is a case statement that implements the different extensions and gives confusion if it’s an extension it doesn’t know about confusion is the is an interesting error message it’s a it this is where tech types out this can’t happen but actually it doesn’t type out this can’t happen all the time it’s remembered whether there’s been an error at least one error before if this is the first error that tech has seen then it says this can’t happen but if something but if the user has really screwed up before it says something else let’s take a look at confusion just to see what so you get the idea what that is because confusion is used to first internal consistency checks intact confusion is defined in you guys are fast what 90 okay module number 90 page 32 of confusion and so there’s a billion global boolean variable called spotless and that is set ordinarily to true until you’ve got your first air so if it’s spotless it says this can’t happen then it gives the indication of what can’t happen that would say x1 in that case and and then it gives a help message there then that help message by the way will show up on your on on on your file or let’s see wait a minute because this succumb procedure this the succumb procedure is is guaranteed to to cause a fatal error this is where it dies but on the other case it says I can’t go on meeting you like this and then it and then so you stop but whether they’re different health message okay so so that’s what confusion prints on now back to extensions I’m glad that some of you are chuckling you know I work on this a little bit now so that so the extensions occurring the the hooks are indicated let’s see in like I’m page module 12 25 page 400 you’ll see the that I’ve made a whatsit node have four subtypes for the four things that I’m treating as extensions in tech I’m considering Oh open send close and X sent as if they were extensions to provide example paradigms of what what you do for extensions and so 1225 says in the case subtype gives four cases otherwise it now this is for displaying or what’s it node so we all would only give an error message I’m sorry if we don’t know it what is we just print out what’s it man some say confusion in that case but if we’re copying a node for copying or what’s it notice one of the things we have to do so module 12 26 is a something that I used you know belongs in section 204 the rest of the program have been filled in here in the extension section and you could get you have you certainly have to provide confusion message there if you’re trying to copy or what’s it node you don’t know how many words to copy so you’re in trouble the whatsit nodes are not of a given our known size open note size is bigger than a send note size in this particular example and a close node sizes is two words which turns out to be equal to the send note size but it’s a coincidence there’s a place where you have to return recycling notes the data structure that’s used in section 1 96 the 12 27 is the code for wipeout or whatsit node and go to done and so that so you have to if you extend tech introducing new kind of what’s it then you must also be able to create print out and and free those nodes and that’s what these last three sections were about then there’s a bunch of simple things that didn’t affect take it off with in the case of send open and close but they might otherwise so we still have the hooks so 1228 1229 1230 1231 all of these let’s see I think it would be good for the videotape people to show this to show my finger pointing even though the people in the audience can’t see my finger tool so on the on these cases the modules are trivial like it says in corporate or what’s it note into an H box and the the code for that is do nothing do nothing if you that’s a macro in web that expands into nothing that’s an empty statement let D be the width of the what’s that node pee dee is set to zero that’s so all of these are trivial things but you have to if you add it what’s it where you want to do something then you’d have to check on the words that nodes type and see that you were doing the right thing okay so this gives an idea as to what parts of tech would be affected if you add something new to the language whenever you add something new to tech you realize that you’re making it impossible for your programs to run at somebody else’s installation and you have to you know I would strongly recommend that everybody keep a a vanilla version of tech around for those people who want to write programs for other users that does not let it growth to the point where where we can’t share where we can’t share anymore a lot of effort has been put into this program to make it possible to be used in in thousands of computer centers around the world and we can we can do that if we keep our our extensions in control so that we that you’ll also be able to have a change file it doesn’t include all of your extension of somebody says I want to write something and I know it’s going to work at somebody else’s machine then now you should you should have one there you have you should have a version of tech that that does that front okay now I’d like to follow one more thing through the semantics to finish our so that we can get an idea of the rest of the semantics and so let’s try unless anybody has a better system example I I thought I’d try falling through the H box to something and then just make the list rather trivial but let’s let’s let’s make a small H box and see what what it does so suppose I want to say H box 200 points of the letter A okay that shouldn’t be a hard thing but it’ll actually take us to the little adventure through a lot of different parts of tech okay now first place we have to we’ll just think about what what whether we imagined would be going on after you have the fu CH box tech has to look ahead and see if you specify something like 200 point or expand by a hundred points or just if it’s just H box with nothing after it there there are two cases of H box that you can see that one is where you give a particular size and then the glue will have to be set so that you reach that size somehow we don’t have any glue in here it’s too bad maybe I’ll put a space after that and allow and well if there was no glue we have we want we might as well see what happens if there is no glue in the box okay anyway one case is that we specify a final size are points exactly the other case is that we expand by a given amount where this could be expand 100 points and that would say take a natural size and make it 100 points for more the special time when you write just H box left phrase that’s expand by zero point so you have these kinds of things that can occur specifies the specification of what kind of H bucks we have there’s two cases the expanding and the exact and exactly then H box that can be used in different context that it can be preceded by a lot of different things for example it could have been preceded by lower lower two points and that means when you’ll move it down to if it’s in an H list I could have been preceded by ship out which says how to go we it could have been preceded by leaders which says this box is going to represent and the replicating part in leaders and going to be that’s going to be followed by glue so there’s various context by which this in which this H box could have appeared and we want to we have to somehow remember then as we as we’re building up the H box we’re gonna have to remember what we’re going to do with it after we’re finished with the box so where does take remember that well the answer is on the save stack we also remember stuff like that yesterday I told you that the save stack was used for saving and restoring equivalents and then it had this kind of we put fix up instructions on the save stack and we had boundary words on the save stack too well just just after those boundary words are before the boundary words whatever you want to call it there’s room it’s a nice place to put stuff before you get to the new to the fix-ups afterwards because if you’re going to come back to this boundary word it’s going to be at a time when you know what kind of a boundary word it was so in the boundary where it includes a code that tells you what kind of a group you’re in and in this case will be an H box group when we finish an H box group will be ready to read some stuff off at the top of this offer up of the same stack that will tell us that this H box was being lowered perhaps by something or maybe was being put into leaders maybe it was there was a set box 100 equals this in front of it all that information will be encoded on the save stack at the end at the end and so the safe stack contains below its boundary words contains mysterious other information of and then then fix-ups occurring now there’s a factoring problem involved here somehow I mentioned there are different things they can come in front of it like lower leaders I didn’t mention set box but that’s another one it’s called save in the present tech but set box in tech 82 and you might have said global set box which which is a different from just from a local set box and a few other things can proceed and proceed this and then all of these operations can take any box so these operations could also could have could apply to H parts to a Reeboks to a V top and a few other V split there are a few other cases that that make into a box and so also you have two things that are that multiplied together all the possibilities for how to use a box and all the possibilities for how to make a box and so we so tech wants to represent all these combinations so so first so these these uses of a box put something on the Save stack corresponding the use of the box and then and then they and then all the different ways to make a box put something on the safe spec seeing what kind of box they’re making and everything is finally gloriously put together at the end now let’s take a look at the that’s the general problem it had to be solved when we look at the specific case we want to keep a little aware of the environment of that case let’s see if I can find out where each box is done now let’s see building boxes in list is this part 46 that starts on page 3 26 and module 9 32 and but it starts getting into boxes let’s see on like module 939 tells how it’s going to represent the context of the box and the context of the box in the simple case that we just have an H box in the middle of some other list with not else in front of it the context is going to be like lower by zero because we’re just going to it’s going to be treated as a special case of lowering or raising or moving left to right where the amount of shifting is zero so the context code for that is going to turn out to be 0 but there will be a context code placed on on the save stack so when we when we scan H box it’s going to come through the command code for that is make box and all of these different contexts are going to insist that make box command is the next one otherwise there will be never message saying I expected a box specification here or something like that and the that the any mode make box comes through on module 9 51 and so so module 9 51 the last two lines of that any mode make box save 0 is set to 0 begin box now saved 0 is an abbreviation for save stack of 0 save pointer + 0 and saved 1 the same thing for sticking in a 1 here so this means it goes at the top of the saves deck save pointer minus 1 is where they the information that that’s really at the top of the stack goes and 0 this this is the the first place that’s available on that step if and if you looked at the code for saves deco it’s made sure that there’s always always five or six places available before it checks again to see whether it’s run out of saves tax base the test we don’t have to test here whether or not there’s room on the save stack that test has already been made that there’s always room for five or six things because whenever it does test it’s at a point that it’s guaranteed never to put five or six things on before the next test we’re going to be testing all over the place ok so now save zero in other words this position on save stack is set to zero indicating which is equivalent to a shift amount by zero because if I had okay so some of the other possibilities for getting the context code are described another mind I want to go into that oak so um so we got zero in that position and we call begin box the begin box subroutine and unfortunately I was not able to write the begin box subroutine next because it calls n box so a box end subroutine and I had a declare box ends first I had the reason is that when I begin a box I don’t know I all I’ve seen so far as a make box i don’t know that I’m making an H box this might be some simple thing like instead of H box am I just said box 20 in which case I would I would be able to finish the box right away something like H box I’m gonna have to wait and scan this whole thing in which might be arbitrarily long before I finish the box but i might finish it very simply so I call begin box now begin boxes module 9 58 and that’s what then is going to look and see what kind of make box were supposed to make and in this case we have other cases initiate the construction on H box of e box because let me see where did I where’s my call on primitive 4-h Box it must be around here somewhere the H box primitive is yeah bottom of page 3 30 H box primitive 4-h boxes right here and it and it was it’s a command quarters mate box its Charcot is V top code plus h moaned so so that’s where we are here H box get savvy top code plus h mode and that’s so that H mode is going to tell us what mode to go in when when we are when we reach this point vbox would look very similar but it would have V mode in there instead so so as far as tech knows it so it’s it’s got the command code of make box and then it’s Chirk ode is going to be V top code plus either V mode or H motor or zero in these are the three cases that were coming into in module now this is uh 962 so module 962 here is where we hopes on 962 is where we make a enter restricted horizontal motor internal vertical mode in order to make a box and so the first thing is we stuff away kirche r minus v top code into a local variable k the the value of k will be 0 for v top otherwise it will be V mode for V box or H mode for H box we increase the save pointer that means then that we have now officially put this guy on the save stack the it’s in order to make room for the next thing we call scan spec subroutine the scan spec subroutine is what scans this part of the input expand or two followed by a hundred points and it puts two things on the Save stack one of them is either 0 or 1 telling whether it’s to our expand and the other one is the dimension 100 point I guess there’s no point in going to look at the scan spec subroutine but it just calls scan keyword and then it puts those two things on the stack and I believe it also increases the safe pointer by 2 so that we now have put three things under the stack telling us the context of this box as well as the final dimensions of the box now now we still have K which tells us what was going on although kercher has changed many times because the scanning spec procedure is called get next of course k equals H mode then we call new save level h box group so the safe pointer not the save stack is now going to get a boundary word for an H box group and then we’re ready to know when the right race comes along that we’re in an age box group and so the thing to do is to some tips to package up rh box that’s we will see that in a minute but we put on the safe stack in a boundary word that that refers us to an h box group in our current group the current type of thing we’re in is going to be h box otherwise for v box and V top is similar things go then we say push nest and here’s something I shouldn’t want to know about in tech gob it has it has a stack for all the somatic activities for various kinds of lists and the and this has state information analogous to the input stage remember when we were talking about syntax last hour the syntax would have a state and local limit and there were a few other things we didn’t we didn’t get into but like the name of the file you’re reading is part of your state the semantics also have these habits that have a stack of these things and one of the things is the mode that you’re in that’s that’s a current part of your semantics state and then you have the head the head and tail of the list that you’re building so if you’re in horizontal mode for example you’re building a horizontal list head points to the beginning of that horizontal list tail points to the end of that horizontally there’s a space fact there is another part of the of your mode of your of your state int as far as semantics is concerned for building horizontal lists so we would so when we say push nest this says all the state variables that go into semantics save them away in your nest stack for semantics and so that they’ll pop up again later when we’re done with this but but they all get saved and so we’re pushing some things on the save stack and some things in the nest well turn out to be need to do that then we set mode to minus k k is either H motor vemos so it’s in and the mode the value of your current mode is six possibilities there’s vertical mode and the V mode and minus V mode minus V mode is internal vertical mode and plus V mode is what you have went off on the outermost level of tech building pages and there’s H mode in minus H mode minus H mode is restricted horizontal mode that’s what you have in the middle of an H box plus h mode is the ordinary horizontal mode which you have for building a paragraph then there’s M mode and minus M mode plus M mode is in a displayed mass formula minus M mode is in a text math poornima so those are the six modes and that’s part of you and so when you say push nest that saves away your mode and your head and tail of your current list your space factor or pre depth or whatever was was a part of the mode there and also a presents you with a fresh new mode a brand new mode your new you now got an empty list at your building so your head is now pointing to a special location in memory that’s just going to be the head of this list it’s not really an element of a list but it’s a it’s a base of other thing in the tail is pointing to the same place so that is representing an empty list and the mode that when I say push nest I stay in the same mode I was in but now I change it to minus K which is minus H motor- vemos so now i’m going to make either vbox on each box and i have to initialize the space factor in the case of horizontal mode so I I said space factor to a thousand thousand is the normal space factor meaning don’t don’t make any correction to spacing if space factor was 2000 it was say double your your stretch stretch ability and neyo spacing and half years shrink ability and that return that and then return which which means go to exit get out of the procedure or begin a box so now this is a simple case of posthypnotic suggestion here’s where we we now return to main control and we go back into tech and and we have our fingers crossed that someday somewhere a right brace is going to come along and we’re going to be able to finish this h box but we fearlessly let tech run with its head do whatever it wants to this h box and all kinds of things can happen before we ever get back control again those things will presumably we our state will presumably push down on either the save stack or the nesting stack or both whenever something even more complicated comes along but someday we’re going to get back and a right brace is going to come along and take us out well what does come along in this case wait a minute where did I say scan left brace oh the scan spec subroutine actually scanned away the left brace to why not because one of the things that could have been was H box left brace and why should we have to back up so it takes away the left race to scan specs subroutine is only used in two places here and after H a line yeah vcenter I guess another case okay now now so so we put we’ve pushed our previous mode into the nest and we’re in a fresh mode with an empty list next thing comes through the scanner is H mode plus a letter letter a okay do we see do we have time I guess we can we have time to do a little bit of this well I won’t go through all the details we certainly will have to check now for the character following a to see if it’s part of a ligature and whether kerning is needed and things like that well I’m not going to go through that code but H mod + letter is the case recognized in module 907 and it tells us to go to main loop and main loop is in where main loop is in that same module 907 and it says append okay here we go main loop is append character kercher and the following characters if any to the current H list in the current font go to Reese which when a non character has been fetched 9 10 4 9 10 is all that action and this is this is inner loop so we’re trying to be fast here f is set to curve on this is the internal code of the current font if it’s undefined font then we then were not inner loop anymore and we given about we call a procedure for missing font and go back to big switch do nothing but let’s suppose F is not a nun not not undefined font then we set C to the current character which is asked the internal code for lower case a 97 and we got main loop 1 which is a label that’s been explained on the previous page said main loop one is like I is like named Luke but F and C are the current fountain character so that’s I guess a correct description of what main loop 1 is now here we have to check to see whether this is a valid character in the font or not so he says is it less than font beginning character or greater than the font ending character because see because this font might you might be valid okay but it might not have this character in it and if so then we have to then we have a char warning procedure which which gets called and we ignore the character tech will never put in its data structure a character that doesn’t exist in the font the Opera routine never has to check whether a character is there or not that’s already been done before we ever put it in the data structure but so we get through this test and mainly to if I bet you if I turn back the page and and and gave the camera operator more fits it would just say that it was like main loop one except that the character also is in the right range for the font so then we said a couple other variables that are going to help us on our ligature space loop and but the gist of it all is that we’re going to finally get to main loop 3 which is going to finally put in put put a character into the current list in font f what that means is the following I’ve got now when I when I said push nest a minute ago that meant that I that I had a pointer variable called head which gets pushed down at each level pointing to some new word of memory which is no has a null pointer in it and nothing nothing there this represents an empty list and tail is also pointing to this same place in memory to represent the empty list now when I get a new character a what I’m going to do is make up a char node which is which is one of these nodes that goes in the one word memory and tail is going to point to it so I’ll say get a veil and in fact i’ll i’ll use a special case of get a veil that’s that doesn’t call a subroutine unless unless it’s a hard situation is one of the hard cases in order to because I mean the inner loop and I get an available one word node and and I’ll have a null pointer in here but I’ll make this one point to this one the tail will point to this one and it’ll say f here and see here the font and the character will be stored in that note F is already known to be in the correct range for a quarter word but this 97 code for a ski I’m going to have to admin quarter word to it in order to get it in there anyway I’m going to have a font in a character and then a null pointer at the end of that if this list got any longer let’s suppose I had a space they’re just too I won’t go through exactly I won’t go through the Cobell tell you what happened if I put a space here what would happen we look at font at the current front F and say what’s the glue for that current front and in most cases there will be a pointer to a glue specification for that font if not we’ll make up such a pointer for so that later on we can we can do it in one step there will be a pointer to a glue specification so then this will point to until you move to a new word which is glue and this is and this would be glue which refers to the to the glue for the current font there’s a little packet that says how much to stretch how much to shrink how much to space four spaces in each font and even the undefined font has one of these which is the Charles zero but there this glue will point to this word of glue specification and there’s a reference count in this word saying how many people are pointing to it so that this will disappear when there’s no there’s no more uses of it but this is a this glue is a very compact thing this one has to specify three 32-bit numbers so we don’t want to we don’t want to waste that much space in tech we do it we get by with that with just a point just pointing to it and have a reference count in here to show that this will go away when we don’t need it so this is a one word node for the character a two-word node for the glue and and we’ve built an H list that contained two items in it when we when we when we made this space we check the space factor that the space back there was a hundred a thousand therefore we could use the standard glue for the front otherwise we would have diddled with it a little bit ok that’s what we did then a in a space then our right brace comes through and is where some this is a another big thing when tech sees the right brace almost anything can happen depending on what that right brace means and see where does the right brace come through I think it’s um I’m going to get some help on this right brace anyway the exact there’s if I can if I went you know in handle right brace is the procedure so so when the right price comes through then we call handle right brace and 964 is the module number no 99 64 is the one that’s used in 947 young okay all right 947 is the procedure handle right brace here we are and it does it has to deal with all of all the things that can occur when a right brace occurs now there’s a lot of error situations that that we want to detect here like an X suppose somebody said dollar sign and then he had a right brace before he finished his formula well dollar sign is also considered to go on the save stack with a boundary word and so did left and right and there’s also now something called group begin which which will give you local local variables just like left braces too so there are things that so the right grace might match something that isn’t that isn’t a left brace we have to check for that decide what to do we have to decide for example in this case whether or not the guy forgot a dollar sign or whether he put it in a right bracelet he didn’t want to and so those cases have to be have to be handled but in this case we’re lucky we got a right brace and what happens it it calls case kerr group of korea group for us is an h box group so it must be in cases of handle right brace we’re right based triggers a delayed-action 90 64 and then going to finally take us to ma module 979 no let’s see 964 if I looked in the index under H box group I would find it yeah well here it is 964 okay so H box group says call package of 0 and V box group says in the paragraph in package of 0 so package of 0 must be the thing that is going to wrap this thing up into a little neat little package and that’s on the next page 965 and package of the parameter is going to tell whether it’s a read top or not I it’s all is the only other case unsaved this is what goes through all all the fix-ups on the on the Save stack so it goes back to the previous boundary word anything that’s been declared nearby only deaths in here font changes in here they all get undone by by the unsafe procedure well then I’ve got back to the point where there’s three words on the Save stack that are telling me what kind of box I was supposed to make and what the end what the use of that box was going to be so I decrease safe hunter by three more and all those three things are saved zero saved one and save to hear I check to see what kind of mode i’m in if negative H mode means I just finished a restricted you know NH box and restricted horizontal mode so that’s what that’s what applies so I set per box to H pack of link of head save to save one okay now H pack is my packaging subroutine talk about thats in the SEC link of head well here’s head the top of the list link of Ed is the beginning of the list so when I call h pack I want to know where the list starts and i also have these two things on the Save stack that said it was 200 says it’s 200 points so I want to make it 800 points exactly and H pack is the subroutine that’s called the packager and the ends the main way to take a list and make it into a box it’s sort of leeway H pack and repack are the two things in there the packaging subroutines which come right after me right here packaging page 196 554 packaging and that section is isn’t devoted to creating a to the H pack subroutine h-back subroutine essentially runs through this list figures out how big it is so it’ll finds character you know found F character c and from that it knows it looks up into find information and sees how wide the character is how high it is how deep it is so we can compute the depths of this H box it looks at the next thing it’s glue and it records how much stretch ability there is whether or not it’s infinite and whatever and gets to the end of the list say see that I’m supposed to make it up to 100 points makes up a makes up a new box node that says the glue is stretching by a certain factor this is the height of the boxes the depth of the box h Peck does all those nice things and returns a pointer to the box it made the Box note it made and as we saw its that corner gets stuffed into cur box okay that’s we’re in handle right brace somewhere there well I got lost and we’re getting short of time but that’s the one so the right brace has taken us through that much and if I go if I could find my coat back again here on boxes building boxes i bet you what would happen next is that i would pop the nest and go back to my environment but wherever that is page 3 35 ok here we go yeah Soaker box was set to H pack and and then we pop the nest which means that we get by this time we’ve got another pointer to this to this list already this list is now pointed to by by some box note or other and head is still pointing to it but i but i wipe this note i recycle it could put it back into into free memory and then I call a box end procedure the box then procedure is going to take ker box and add it to the current list in the in the auto mode and we’ll leave it will either lower it or raise it or put it in leaders or whatever the context on save save zero tells it to do oh there we are we finished an H box now that’s taken us through a lot of the of the ideas of Technic bye-bye that example you’ll get a feeling for ya you know what other things are going to are going to happen anything could have happened inside this H box of course it could have called a V box that could have had a displayed for them inside of the V box and all and other stuff going on but it’s all done with the the same same basic idea that we save some things on us on the nesting stack some things on a safe stack and we have a few vital procedures like the H pack procedure that make transformations on the data structure finally everything gets into the data structure and we’re ready to do things like break it in two lines four paragraphs and that’s that that’s the subject of the lecture at two o’clock breaking paragraphs in two lines the most interesting one that I want to especially recommend is the one at three-thirty on hyphenation we should have some fun with that a computer is still up because the brand-new hyphenation algorithm in tech and i want to show you how it works and do some experiments with it so this afternoon well both pretty good with the hyphenation want to be the most fun for me

That's the end of this page. If you have any feedback about anything on this site, you can contact me here. To go back to the top-level page (if you are not on it already), click here.