Session 2

Of the videos, this is the second session, on the representation of strings in the program.

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:

First 12 minutes: an outline of the TeX program, i.e. what its major parts are. The image that Knuth drew is available here: http://imgur.com/a/KBwue (via https://tug.org/TUGboat/tb03-2/tb06software.pdf -- but note that the middle section is scaled by amount of code, and not memory structure as the caption in TUGboat says).

Rest of the hour (video ends at 58:30) is about strings (what tangle does with double-quoted strings, the pool file, etc). Pascal had weak support for strings, so they came up with their own homegrown solution, which they grew to like.

In the last 10 (or more?) minutes, there is also a bit about printing, how TeX prints to various streams, including the “pseudoprint” trick for printing just the last part of a large string (by using a circular buffer).

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

Wow okay welcome to session number two we’re going to start looking now into some of the fundamental data structures that are used by the program and to start out I’d like to to just give some idea as to how these 1200 modules of tick can be written me broken down so let’s see we could this is a little diagram that I tried to to estimate the relative sizes if you had if you look inside a memory and took out all the system routines that were needed for running Pascal programs and so and so on but what tech would put involved now the parts here between okay these lines here this is code and then these on the outside our tables of large tables of data and the so the program itself has 1200 miles above is roughly 1200 modules and I just counted modules and i’m assuming about a hundred bytes per module on advice of code for every module in the web thing that’s the estimate that I made so 10 modules would be 1k bites and that’s one square on here and so if it’s so if I’d say that like looked like about 14 140 of those modules we’re concerned with syntax and that would at the counts for this charge I also tried in this chart to indicate something about how the the parts of the program talk to each other although it could reflect all the all the constraints you get some creeks I’m feeling for the for the organization of the program by this diagram so I’ll go through a little bit there’s three kinds of input files get read there’s the text the user source file on the text text input then there’s the font information which comes in which is here and then there’s the initialization which is your format file comes in with the very beginning when when tech is loaded these are three different kinds of files this one would be a Pascal text file just characters this one is a TFM file this one is an FMT file format from the TFM file is in 8-bit bites the fmt file is in memory words which is a tech take internal data structure we would never expect to to send FMT files from one computer to another these are these are local things that we’d keep only in the in someone’s own local library and in any tech writes these files other versions of tech read these files now the the the the part of tech type that we call its eyes and mouth is consider is the part that reads in of the users text file and it also has the macros that it that it looks at when for things that have already been defined the fmt file of course feeds into macros and the syntax part is supposed to make some sense out of these and keep track of what levels of input that we’re in so that we might be reading one file and then that file said column at grow and that macro said had some parameter and we’re actually looking at that parameter of the macro and in that parameter it said input another file and various levels can be going on on at once so let’s so remember these boxes of tech I’m indicating just here not the size of the of the data but the size of the program so this is the amount of program i have here to deal with macros reading and ND click defining macros this is how much program i have four inputting text from files roughly speaking and this includes from the terminal so this includes things like responding to error messages but it doesn’t indicate the size of the buffers the size of buffer is only about a half a cake for four input it could make it larger if you wanted to but it’s trivial with respect to the side of the program in that case how the alignment is sitting in here too there’s some program for alignment I said this was the hypnotic suggestion type of thing in this it sits in the background and contributes to the syntax now again then locals program to deal with local variables this is the grouping aspect of tech that’s thing they’re supposed to go away when right braces are hit and and we have to save and restore think the equivalence the table of local things is called the equivalence table and this is it this is data here this is area where we actually are storing all the counts of dimension skips values of baseline skip all the parameters the codes and all envy I also offer every control sequence of a pointer to where it’s defined now after we’ve read in things then there’s also text out this can be either at a terminal for for Erica for rum for error messages it could be to the tour to the transcript file or to ascend file and these and so some program has to be there for dealing with text output and it’s about 40 modules worth so that’s four of these squares now semantics is generally what we’re doing to digest this information after we’ve eaten it and and the big part of the semantics is concerned with matters of formatting this is everything else and besides math and this is matt so this reap arts for things that that do we when you say H box or something like that dealing with constructing of boxes of doing proper things glue some of the parsing though will be in the syntax for example you can say H skip five points in the syntax we consider the thing that that recognizes 5pt and converts that to a number that the semantics will deal with then in the math mode routines these are the things that that will build em lists instead of semantics or other smacks bill h listen v list endless are the math this H and V are horizontal and vertical list now the programs that deal with the dynamic memory are this is where most of tech is is stored and and so we have to allocate things in this dynamic memory and that in the first lecture in the afternoon we’ll be talking about the dynamic memory to fermanagh kotas is to vote to that including the one I mentioned the last lecture where it’s a display box be because one of the things you do with the dynamic memory is show what’s in it then sort of separate from all that is the is are the optimization routines that that come into action after you’ve gathered together a list and then then we try to break the list in the best way and took in two lines of pages so there’s a paragraph there there’s a lot of code devoted to finding the best way to break paragraphs and that code or occasionally talks to the hyphenation part of the tech but the hyphenation doesn’t really talk directly to any other module just the paragraph or if Perry opera gets stuck it calls hyphenated and the paragraph who puts things back in the memory and and asynchronously whenever there’s enough gathered to do something to for output then the page builder comes along and and send something else then the the program that actually does the output to the DVI file is a little it’s not very long in fact most of these modules are comments about what DVI files to what deviant sounds are and there’s program that reads in font information so now the hyphenation tables take up certain amount of space and the equivalence table takes up about the same amount of space for all the registers we have more space indicated here for fun information and a little bit less for all the strings in and we’re going to talk mostly this hour about strings the help you add all this up and see how many kbytes is it gets very encouraging because it comes out to be from like 260 k or something like that however I left out one one small detail and that is there’s another table which is the whole dynamic memory which I haven’t shown on here because everybody talks to that practically and you can think of that as an overlay about equal in size or let or maybe half the size so to get the dynamic memory I would put it I would give I would say you need 100k of dynamic memory to do about to do a fair amount of typesetting and the and with the 300 cake it’ll be it would be now 256k is as much as as you’ll be able to get on some machines with 16-bit addresses because we we address them four bytes at a time so somewhere in between there you’ll get the total size of tech I’ve made these other tables of reasonable for for a fairly large scale production so I would say that oh you’re your tech would then add up to something between 350 and six hundred thousand bikes flood plus the amount for a Pascal runtime system depending on how so so half a megabyte it looks like you should you have a chance of doing a good type thing but you’d be comfortable with this little more than that any questions on this I hope this picture helps to give a little bit more perspective as to what we’re going to be dealing with inside so you’re you’re this is a ten by twelve area from in here which covers the 1200 modules in the tech unitech writing and the number of those modules devoted to different parts of tech is sort of indicated by the sizes of those rectangles oh by the way I forgot to mention there’s little microphones in front of your eyes and you pick that up and push the red button and everyone can hear on the tape how does that memory requirement compared with tech 80 can do you know I know in Yaqui can you how can you say you will about the dynamic memory the sizes of all to say birthday I think the program has gotten a little small or by bought the same so what the spring memory is new well I don’t know no it isn’t really knew that things are packed reasonably efficiently you you can also use trickery to to decrease the memory requirements of course but not just plug in this this program you have to you have to do some major changes to some of the macros there’s a wasted bite here and there I tried to emphasize readability over efficiency without sacrificing efficiency to mine so yeah but it’s roughly the same I would say now the let’s see the next thing I want to do is is the next thing I want to do is turn off the projector so we can see the computer again I wanted to show you the pool file that tangle typed out protect we’re going to be talking about strings and and one of the things that Pascal is weak on is strings they provide certain certain kind of support for strings but not very much and and so in order to use paschalis a language we had to develop a mechanism now this was originally the idea of I think Lewis caparo Annunaki in the other version of tech after they fought with the problem of strings for one I think they came up with a solution that’s not only good but has turned out to have many other big payoffs that we didn’t expect so that now I’m very happy that Pascal didn’t have strings if I’d used pastel strings there have been a lot of other things that wouldn’t have worked as well as things are working now so we have a string method in tech that also turned out to solve a lot of other problems in a better way than then we had than otherwise would have occurred nice and as we get more into it I think you’ll understand what I mean but first of all let’s see what tangled us to two strings so if the machine is still up we can take a look at tech dot poo can you see this on that screen there is it coming up awesome ok now the pool file that’s written out by tango is it consists of lines again our maximum length of a 72 characters because the the restriction on the length of strings that you can use in weave and each line comes out at each string comes out on a line by itself so that means carriage return line feed or if somebody has a IBM machine that means that that there’s a lot of blanks or nulls at the end now the the first two characters our line is the length of the string itself so the first string that people currently appears in this program is buffer size and it’s 11 characters long and and so on you get to see all of the all of the strings if you if you push through this file and it’s eight hundred and eighty ninety eight lines long actually the last line is not a string the last fine is special it’s a it’s called the string pool some check now tango has this extra the special number with an asterisk in front of it at the end of the file with a following idea that if you have changed any one of the strings in the in the program then chances are very good at this number will be different and you can also refer to this number in your web program and say what is my string pool number therefore you can find out if you’ve read in the string pool that’s neat that’s yours because you can look and see if your string pool number equals this one at the end of the file now if I edit this if I edit this tech profile it without changing a number at the bottom the program won’t complain you’re not supposed to touch this this file yourself this file is supposed to be made by tango but you see it this is important because if you were started to load a file that was that was generated without the right you know somebody suddenly put another string in his change file or something like that and and these things get out of sync then you get very interesting printouts from tech where we have some permutation of all the strings coming out one point it says prints doing 100 it actually brings something quite different and it might be amusing to some people but frustrating to other okay so that last thing in the file is your is the string pool checksum now this file isn’t that them isn’t that mnemonic to read because it doesn’t tell you what string number in is and and so there’s a trivial program at the beginning of the tech where report that handout that you got called pool type and the pool type program does something is to to swing fools and so will demonstrate that now I think I’ve got it already compiled it’s such a trivial hey wait my son has a message for me here now okay so let’s run full time poor fire will be checked at school or poo an output will be Ohio not cool okay so now it’s reading in that file and presumably making the output file for it and we can look at pooled up type to see we could print this out of course to see what what the strings are inside now the the first honor 28 strings I mentioned are special and that’s right I can this is these are not however the pool type I’ve done was done with with sale versions fool type so this has our local character set i’ll be talking with blood characters that also in this hour but let me make another let me do another pool type without the sale dependent changes so let’s see i’ll run tango on pool type without any change file and it doesn’t have a pool of its own so whenever you you run a web with a boat’s Donnie see it isn’t that great when you have a short program it was 11 second instead of two minutes now the Patna we’re going to compile an and go the and I’m making a version without the change file my change file refers to my local character set and the sale character set has a keyboard that has some symbols on it which I I like very much especially the unequal sign and the and less than or equal sign Greek on the left arrow I would find it very difficult to have to write less than greater than every time instead of unequal that would be quite painful for me so I’m glad I can do that here and I imagine there are a few other people that feel the same way so we try to make tech that it will be able to be to allow that for people at Stanford however we want to also so that it’s not going to be confusing that we can also send our files to places elsewhere and not lose the machine dependent so we have I think a pretty good solution to that and I’ll explain in a minute versus look at prove that Tim cool that temp shows the strings that we would get without sale characteristic okay now the first hundred and twenty eight strings so number 0 327 our our our what gets printed out for asking for tech internal our codes and so starting in 32 we have ascii code 32 is a space 33 ! 34 is is a double quote can you see that ok on there I can’t see it on my mouth yeah okay so and then we get up to 126 which is a tilde and then then the other codes aren’t visible in ascii and so for interchange purposes we are representing them with two up arrows and another symbol and for example 1 27 which would be ascii code octal 177 would it comes out it up arrow up arrow ? and at the beginning of the thing if you remember we have the at sign and a through capital A through a capital C and then the next asking codes that that go in there so so this is a a form that tech 82 will accept if you put it in your input if you say I’ll pero pero s capital S a parallel bear capital s it will treat it as the ascii code that is 19 decimal if i compare this to I’m so it was cool but type we compare that same thing to the sale character set and see that as sale some of these we I assume that someone can type so a down arrow will assume they can type a yeah that’s rather handy for subscripts and alpha beta and sign not epsilon pi lambda and then when we get to a symbol 9 there which is at which is an octal 11 essa but it’s that tab I think isn’t it and yeah eight is backspace sometimes but minus tab and so there if somebody wants to so if we’re printing out this is these strings are using printing and so for printing out a tab mark that somebody that we might have read in at sale then it would print out as up there up arrow I if somebody inputs uh pair up or I even at sailor anywhere it will go in as internal code number nine okay and these tab mark line feed vertical tab carriage return and page mark form feed our are not visible symbols so so we would print them in that way and if someone wants to define a control sequence backslash of barrow uh pero el that’ll work and it’ll it’ll be a beckman or if he wants to do a check code on that symbol you can do it this way you can check old your carriage return to mean something it’s on well these internal codes on the other one would would all be with all the UH pearls and so if I’m sending a file to some other place I would use a version of tech that would print it would print in the standard form and by making system dependent changes you say what there’s a module called character k can be printed and that that code is duplicated in the pool type program and in the tech listing module kick I forgot to tell you an important thing about how to read web program that is that there’s an index to all the modules all the module names after the other index and that’s very helpful if you are looking at something in the web file I want to find out where it is in the thing and I and as I remember it was called character k can be printed is the module that I’m looking for here so on page 4 38 I found character k cannot be printed is module number 49 and so now I can look at module number 49 and and there’s a comment there it’s called true in the in most versions of tech character k cannot be printed is true in most versions of tech namely this is for characters k that are non ASCII codes non-visible ascii code there’s only supposed to work for the for those values of K lesson then octo octa for t less than 32 decimal so I saying that this this is true here now on the other hand at MIT I suggest that it can’t be printed be V 0 10 to 12 14 15 and 33 because the 33 is an escape code and 14 is your carrot busier line form feed and so on now so then only a few characters cannot be printed in that place now this is assistant depend of change and in foreign countries there will be different ideas on what to do with these codes less than 40 so question vector is what does it mean so what so well what’s the giving it to these internal codes have well in a way if you changed your codes to us up to anything else it wouldn’t matter that much to tech we it was still compile still compile programs except that these numbers are used in the language in in several ways first of all the internal numbers the tech has go out into your DVI file in the font like if you happen to say letter A in in a certain font then that then the internal code that Tech has for a is what gets used as the character number in in your DVI file so it’ll say Italy DVI file say you your maybe in front number 63 and you’re setting character number 65 that’s a capital A or at least that’s intex internal code for capital a so so if the manufacturer has that capital a in another position in iskcon file it your output driver makes the conversion at that point so we have we have to have some kind of standard internal code that everybody uses and if you use an episodic or something on your external files the first thing tech does reading in a program out of the outside world is going to convert that to its internal code so that also that the rest of tech knows exactly what’s what’s going on and guarantee that 0 through 9 are consecutive numbers and things like that now if you do something you know you can convert any of your outside codes to any internal cause you want and and then then on the output we will go back and and do the inverse operation the the idea is that if you if you never print out these codes that are not standard in ascii then you can still do it with the up there when i said uh pair off error s is equivalent to one of these asking control codes i should have been a little more exact that it’s not just an up arrow any character whose check code is a superscript mark is is is the real thing that instead of what i said up arrow so if up arrow hasn’t been checotah to superscript mark it doesn’t work and if but if any character who has been chacorta 22 superscript mark the two should be I should be identical and both superscript marks but they could be any but but otherwise I tech will allow this on input in the middle of a control sequence name if that thing is to colon as a letter for example it’s possible to do that now that the the other place where where internal code is used in checotah statements for example in text so you’ll say what’s the check code of of something and we have this this back this reverse ’ operator that converts a character into tech and internal code number so to code 65 sets the code for uppercase a the reverse ’ upper case a is equal to 65 so this is a definite part of a language of text language as to what it does for the for its internal code number I think some of you know that sale the computer that we are that we’ve got here has a strange code that nobody else does in the world because that they started at Stanford with SD code earlier than before ascii code was even in its first form and one guy one night figured he could save five resistors or something in the in our machine by switching around the co2 right brace to one to the other you did it overnight without telling anybody in mex and ever since we’ve had right brace in the position different from the rest of the world now we have a few other characters that are that are unusual to and certainly the burden should not be on the rest of the world but should be on us to to have to make our change file a little harder than yours you cannot do that so text internal character code is based on a code that i that i think is the best proposal for for representing these extra characters as invisible way it’s the one that’s used on several MIT machines and so at MIT nope no conversions are needed if you wanted to use a recommended conventions for codes less than octal 40 the strange ask codes now most of you just won’t want to do anything with those characters and you won’t see them on your input files you want to write a money output files but you could do you can imagine people in in foreign countries that want that have more than 26 letters in their alphabet and they also want to have backslash in a lot of and other control characters to use I believe it would be good idea to map those letters for text purposes for tech purposes in two codes less than 40 and and then they can send their source files and everything else to America and we’ll still be able to do to work with them as if they were as if they were generated here so the internal character set represents the first these first cause and then pool type just types out the other ones with us with numbers associated with them so that you can see exactly if you’re if you had a debug and you wanted to really look at the Pascal program and the Pascal program refers to string number 432 then you could look at the thing and say well for and 32 is this is such and such a message so you probably be able to i dint from what that string was maybe a help message is something be able to recognize what what part of the / pascal program you’re looking at that pool type is simply a help in that way to shoot so that you can figure out what’s in a what’s in one of these pool files that tangle generates any questions on that now what actually happens then when a when text starts it has to read in the pool file so it reads in this pool but only in e-tech does this and you take reason in the pool file and checks to see that we’ve got the right of some check and stores that all into the format file with the rest of the macros and find information that is going to preload on the other hand it also stores the front some check so that the other versions of tech they won’t check anything except with but except they will check to see that they have the right the format file was generated from the right some check okay so so other production versions of tech will also know that their format file is compatible with them they’ll try to load a format file that was generated with a different version of tech and then the strings won’t be compatible and so it’ll it’ll say right away or that this format file is wrong how the the way strings are represented inside of tech have a big array called the string pool and let’s see where I can string handling is starts in module 36 page 18 okay the big there’s a big array declared in module 39 and and in this array you see string pool packed array of ascii code ascii code is a sub range of the integer 0 2 127 and only things that are going to go in this string pool array are visible character or characters that we can print also so the the input routine is set up so that I’m not going to put in into that into that string pool buffer any of the codes that would come out with up arrow up there or something in the printing out only only the ones that I could print are going in there and they’re all seven bit some characters nothing over 127 Wow if you look just above that it says types in the outer block 18 plus equivalent and it mentions pool pointers I guess I should have mentioned that the types when you have the plus equivalent there and it refers to module 18 but here we are in module 38 what we’re saying here is that these are more types in the outer block 18 was the first module where we had types in the outer block and if he turned the pit to modulate een it tells you all the other ones where they are so module 18 says see also sections 2538 that’s only at 96 and so on up to 812 and besides thing where the code is used it says see also this means that many modules with the same name all get butted together in the order in which they appear in the program so this is one of the places where we want a new type so when we refer to something as a pool pointer this will mean an index into the string to luray and whenever we’re talking about the swing pool array then something that’s going to go into stir pool it’ll have an index call if the type will be pool pointer and similarly a string number is something that that’s a string start array well the string start array is a directory to the pool to the pool and the strings that tech get submit once it reads one in it never removes it unless it’s the very last one ready sometimes the last one ready and you don’t want to see anymore and you delete that but we but it’s just operates in a very simple fashion because that the rules of tech it or not that’s what you want so it starts out with all the strings that these 800 and some strings that tangle if we read that into the string pool array and that then after that we’re going to have strings for various other purposes and take as tickets going and they’ll be continually added at the end like file names of your fonts and so on now the string start is a pointer into into the array and so that it tells you where that string begins so stringing number 100 for example will start at some place in the unit pool array and at the very beginning we’re going to put in we’re going to put in those first hundred twenty eight strings also even if they’re one character long we’re going to put them there now there’s no string end or a reason is that if you want to know where string 100 ends you just look at where spring 101 starts and it’s one because it you know and that’s that’s where it is so uh so we don’t need so we only need the one array string start and then we have to keep if we have n strings in the spring pool we have n plus 1 starting positions so the starting the start alpha of the of the string we’re going to do next is also recorded there so that we could find the end of of the last spring we had in so that’s all that’s to it as far as representing Springs is concerned and so there’s a macro defined therein module for tea length of a string so if we want to know how long string number K is we just ask for its length which is the difference between the two string start positions for modules 38 so on I just build up very simple routines for for dealing with strings that other parts of tech are going to use as subroutines there’s a simple one that flushes a string the destroys the rose most recently maintenance module 44 there’s there’s one that’s called the string room that’s at the bottom of page 18 a string room you call string room of 5 for example to see if there’s room for a string of length 5 and so it’s as if pool pointer plus 5 grade and pool size then overflow pool size pool size the first parameter to overflow is a string saying is you’re going to get in here message saying sorry text memory sticks capacity is exceeded in the pool size equals and then it will give the numerical size that it’s been compiled with and pool size is a compile-time parameter and all the compile time parameters I believe are in module 11 notoya module 11 and crew can delete that we that you can decide on at VP how much space you want and here I declared it to be 30,000 remember this gets this is a packed array of seven bits on our 36-bit computers that means we get five to a word and 30,000 takes six thousand words on a on a better car by oriented machine this would mean 35 30 k bytes in a row and 32-bit word machine this would of course before to a word and so on and this number it says it must be at least 22,000 more than string vacancies and string vacancies is another compile time parameter and I set that to 8,000 now why I put this 22,000 that’s because we’re using almost 22,000 for the strings in in tech already the error messages and health messages and everything I think at the end of the pool type I might even have that I don’t don’t worry about oh yeah you’ve got it okay wait am I kind of all the way to the end here last extension yeah twenty 1175 characters in all and so I’m just rounded that up to 22,000 because people will be adding extensions and things like that to probably earn up a little bigger so this is a now what happens is that when when it reads in the pool file it makes sure that there’s also room for spring vacancies more more otherwise in any tech will complain saying that the string that you got to increase pool size so that’s a compile-time parameter depending how many things that you’re going to do and it says it tells you here in module of evidence is it’s the maximum number of characters and strings including all error messages and health texts also the names of all fonts names of all control sequences these are the kinds of things that go into the pool you see it’s names of names of control sequences when you declare a control sequence and it’s not a one letter one character control sequence avista stated some multi letter K control sequence the name goes right into the string pool here’s one of the things I mentioned before where I saying that this was this method of dealing with strings was was giving us advantages over what we had in the sale version of tech because sale version of tech we couldn’t the implementation of strings was quite inefficient we didn’t want to use sale strings for control sequences or instead though we had to go into our dynamic memory and take away valuable space therefore the names of control sequences my first original design of tech if anybody remembers way back in 1977 I had real strange restrictions that control sequence had to consist of at most five letters and an upper and lower case were not distinguished after the first one and things like this was all so that I could keep a separate table of my control sequences and I had the idea at first it hardly anybody would be defining new control sequences I didn’t realize that macros were going to be very powerful at first and so then gradually we found that people actually want control sequences so we’ve made groupon well now but treating on my strings solve lots of problems with the data structure because then I can not confess I don’t need a special program for example to print out the name of the control of a control sequence because I’ve already got a program that prints out a string and so that was one of the one of those simple advantages that we were able to combine two client two kinds of data structures into one here now you see there are subroutines there on module 45 to compare a string to the buffer this is what we would be doing when we’re looking up but to see if our control sequences in a table or not another one that compares two strings to see if they’re if they’re equal to each other that went that’s what we want to do when we’re loading fonts to see if a fund has already been loaded and then the next few sections are just the things that Trump that are used to to initialize the strings one point I could point to show you at the page 21 my see page 21 module 51 says I can’t read tech pull you notice that that’s not that’s a Pascal string it has single quotes around it not double quotes you can see why because we couldn’t read the string pool so we have to use Pascal strings there so now in Pascal you can’t call a you can’t use strings as an argument to a function unless they’re all there a certain length that so you might wonder how I could do this both that’s because bad pool of course is a macro it’s defined up up above there and it writes this string and so again having macros we’re able to get around one of the deficiencies of Pascal and it it writes that error message saying can’t read text and dies it returns false to the to the procedure itself so that the environment will give you another error message there it is so these messages you have to increase pool size depending on string vacancies and so an hour all done in this case it also syntax checks the pool file to see if it if it’s been collaborate or not okay any questions on that I don’t see ya please use the mic kind of what string a string begin with a constant a string begins with a double quote and ends with a double quote and anything goes in between yeah it’s okay anything goes in between tonight so so any any text whatsoever if you have double quotes inside you you have to have have quadruple quotes you have to double them again so that a double quote inside of a string gets its a double din question there you said that the shrink was used for member name therefore there is no garbage collection you can reapply macro name there’s no if it turns out an intact that you really find a if you define my control sequence undefined control sequences happens only at the end of the group then it’s it’s very difficult to tell whether that control sequence is really not going to be used again because another control sequence might have used it and been declared global and so in order to so there is no garbage collection the the number of times that that would actually have saved memory was much was actually less than the amount of memory we would have saved by not having the code for garbage collection so so this is why there’s no garbage collection okay so the next section talks about online and offline printing and here’s where we get to use the string pool to just print messages and so the I’ll talk a little bit about printing routines these again are very basic to the whole process I think these are the ones that actually get declared first there’s a procedure called initializing and as a procedure cook them in basic printing procedures and they start in module 56 the first one is a print print line procedure now the interesting thing here is that the printing procedure there’s a destination for printing so that when my program says print it might write on a terminal it might write on the on the errors transcript file that you get after you run tech you might do both it might be writing on in one of the send files it might be writing into the string pool itself and so you can change the destination so that also that all you need is a few print procedures and whenever you say print integer that will send an integer to the proper destination with that destination might be a variety of different things you still don’t need a different sub routine for each one okay so by switching the destination we’re able to get by with just a few you know all our procedures are called print but what actually happens to it one of the destinations is no print which means it just disappears okay there’s one called pseudo which is number 20 these are all defined on page 22 module 54 this one called pseudo which is used in an interesting way for showing that the context of your error lines you know when you can error message from tech it tries to show you where it was and it gives a two-line indication of this the first line shows the characters Tech has read so far second line shows the things that hasn’t even seen yet and this might be in the middle of a huge macro definition for example and so the macro might be a hundred thousand bytes long when it expands or very long anyway now because when we’re expanding it we’re expanding all the control sequence names out to their full length and so on now we don’t want to have a special buffer that expands out 100,000 vice and then and then shows the 60 that were actually interested in so instead we keep a buffer of size 60 and we go circularly round and round in this buffer that’s what soooo printing is and then when it stops it has enough information when to just print out the characters you need it in the environment the buffers a little more than 60 but it’s just a not small amount so this is a method so soooo printing is turned on when you’re just when you have a little bit of when you’re using this trick of what were you going to run you’re going to print a whole bunch of stuff and then you’re only going to select a little bit out of it and and what you do is you turn off storing into the buffer after you’ve gotten past your your key point so so let’s say the buffers of length 60 and is the transition between line 1 and line to occurs at a certain point at this time you’re going to you’re going to write at most 30 or 40 more characters before you quit and then you’re going to shut off printing so that’s the pseudo thing which is explained elsewhere now no that’s so so by having these print procedures we can change that but they’re all called print and many maintenance one of the most frequently used things in tech will say print an integer and this is automatically does binary decimal conversion and because you can send the integer anywhere you want like to a string so if somebody wants to see a string but stored as a string you can do that by setting the selector to new a string and then you get a new spring into the string for so this is a another turn out to be another advantage of having the data structures organized this way instead of have instead of making use of a particular string feature that might have been in in in pasco so i like what i guess i’m saying is that that by programming my strings homemade i have much more I had more flexibility and what i could do with them in an efficient way I didn’t have to worry I didn’t have to consider a very inefficient but highly general method status some system programmer would put in for a string package that would have a lot of overhead take a lot more memory space besides making the program a lot more portable and and not really longer so so this home-baked approach the strings has not been a it turned out this week one of the first things I struggled with using Pascal turned out afterwards or the blessing in the sky the print procedure on not page 24 module 58 is the thing that we use to print out a screen so just to reinforce what I’ve said this hour i’m getting near the end of the hour let’s just look at that print procedure and see well it’s this is so simple it doesn’t even call anything else but just it should reinforce what we’re talking about so procedure print s is integer prince spring s now this is something i changed last week as i was debugging s used to be called the type stir number like print new line s is a stir number and this is Prince stirring at the beginning of a line it’s the same as print except for the making sure that it goes at the beginning of a line but but here I said s could be any integer anybody have an idea why that why I had to make that change well I decided to make that change the reason is a while I’m debugging I have made my bugging routines extremely robust so that if memory has gotten completely clobbered is still allowed to look at any location in memory and say if this is a pointer to a string printed and so it should be it shouldn’t give and and if memory did get clobbered then at least I would have some mike symbolic indication would part of it would make sense in the cloud word part would would would would be there but it wouldn’t the program wouldn’t die on me well if I didn’t say this was an integer Pascal would stop me saying that parameter to print is not in there in the range of a string number so I change us to an integer and then we have a test inside the program that says if s is less than 0 or greater or equal string pointer then set s 20 this can’t happen well it can’t happen in lists of buggies is a present of course nothing everything can happen in a computer if you see if there’s a bug and I don’t call an error message if s is less than 0 is greater than 0 remember i said before print programs aren’t supposed to I’m supposed to call error messages otherwise there would call print and print me call error and you can you go on and on forever so it just fits it s 20 which is going to print out a very unusual string one that got you string number 0 is this up arrow up arrow at sign when you see that that’s a good error message enough ok so then J is set to stir start of s that’s where it that’s jay is now of type bool pointer that means it’s an index into the buffer and I’m assuming that stir start is not clobbered but but the s itself might have been clever now while j is less than the string start of the next string s plus one that’s always defined when string s is less than string pointer and greater than zero then the skirt start s plus 1 is defined that’s where the next one starts so while at j is less than that i print char string cool j print char is the lower level procedure that just takes the character right out of the buffer and sends it out to paske increase j and continue that that prints the sink so that’s why I that’s what the print jar procedure doesn’t look for string number you know print charge 65 doesn’t look for spring number 65 print char Prince char see text internal character code 65 at the end so that the stir pool entries must all be printable characters let’s look at print char all of the print procedure I said you could change the destination every print procedure works through print print line and print char these are in and they all reduced to these so these are the only two that look at the selector that look that look at the Connecticut has the Prince elector and do n so you could if you want to deflect it you just deflected in these two places and print char takes an ascii code as a parameter and and so for example it’s both were writing on the terminal only that would be term only case and it would say right term out extra of C now exter is the array that is set up to convert from tex internal code to episodic or whatever and that’s where you want to make system dependent changes so let’s look at where exter is set up that song starts on page 10 and a section called the character set and the things i mentioned about characters that are discussed there on page 10 on page 11 you see where extra is set up a whole bunch of assignment statements these are supposedly not system dependent if we assume that your pascal can read any of the visible ASCII codes then it you don’t need any changes here otherwise you do but this these assignment statements will set extra of octal 42 of the the character blank and so on and many many implementations of pascal will then set extra properly by this but by the statements it and it then on the other on the other codes less than r / 40 that’s explained on the next page on page 12 and there’s a and the standard version of tech that hasn’t been modified in module 23 the standard version of down here is says just blank it out said said all these other characters that you don’t expect to find on the input to blank and then you know if you are able to output them all out for this blanks also but at MIT I suggested that you could just set them all to the character itself because text internal code agrees with this MIT code so that that’s a system dependent change that of course would have to be made if you want to do something special with the codes under 40 however most installations won’t have to do anything with those I guess all right that’s all except if there are questions any more question i can offer you attempting lunch if you don’t ask me any questions okay good that I work so we’ll meet again here at two what is it two o’clock sharp thanks you

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.