 Hi, so one thing that I want to emphasize that we talked about the previous slide was also regarding this variable argument list variable length argument list. So once you want to actually supply an argument list with a variable number of arguments then we can use this standard of args keyword this keyword actually describes this is already set in the in the language for a variable length of arguments, so it is read as a list essentially and then essentially now you can go through the list to understand of each of the arguments and then parse them separately, so here this is the example that we saw previously, so here the proc name is some which actually returns the sum of set of integers and then we do not specify like all the integers separately just specify args as the keyword, so inside this proc we said basically the s to 0 and then we can actually parse this args as a list, so for each I $ args we just increment s with whatever the value of $ I so and then we return that the sum basically yes, so here simple example some 1 2 3 4 5 the answer will be 15 because every time it is implemented by that much, so it is 1 plus 2 plus 3 plus 4 plus 5 if you say some 10 2015 then you the answer will be 45 and then if you just say some without any arguments then it returns the 0 itself and that is why 0 here, so this kind of using a variable length is a very useful because now we can extend this concept to many other things, so let us see one way to extend this concept, so oftentimes you see in procedures you do not want like positional arguments and you want non positional arguments what do I mean by that, so a positional argument for example for this proc, proc name foo we have an argument 1 argument 2 and it needs to be exactly specified when we call this procedure, if you miss it then it won't be proper for example in this one it is actually like I purposefully wrote this way, so I hope you remember this format actually when you specify a argument and another value inside the braces that is actually the default if you do not specify then that is what it takes the value of, so here say like I mean arg 1, arg 2 you need to specify exactly in this order otherwise the this function will fail, so now let us look at the non positional argument, non positional argument we can say like I mean the same thing like in any order only thing is we prepend with arg 1 dash arg 1 and then give the arg 1 and the share 2 give the arg 2 you can write like foo arg dash arg 2 and then something some value and dash arg 1 value 2 this is also possible because now it does not matter where you specify these values since you are prepending with the arg it knows like what exactly that to put in, so how do we write these kind of procedure this is one of the curious examples essentially like I mean what you will be seeing more and more in real world problems, so the way to do this this kind of procedure is as follows, so here a simple example the same procedures some in the keyword arguments now this is as you know it is a list and this list is essentially like now we should be like this basically like arg 1 or 2 all these things are there, so I am assuming that you will be specifying like dash 1 and the first number and then dash 2 second number things like that now you can actually inside the program you can look for those keywords and then you can mark those things exactly as here it is a simple increment of s with whatever the next value is but this could be a complex program right here and then once you write this program here and then same thing for each of these dollar values like if it is to then do something three then do something things like that once you have that and then return actually now you do not have to specify like I mean if we have three numbers you can specify in any order dash 1 and then first number dash 2 second number dash 3 third number this is one way to specify or you can just say like dash 3 the first number dash 2 second number and then dash 1 the third number so basically like in this kind of a method actually the procedure call itself or the way that you specify the arguments does not matter you can get actually the results with any kind of order that so that is mainly like I mean one of the things with this positional and non positional so you can use this array concept to convert the positional arguments into non positional arguments okay and one more thing is here instead of using if you can also use the switch command I hope you remember the switch command the switch command is essentially also like doing similar kind of thing where you can use like it is equivalent to multiple if command so another application for these kind of this arcs concept is you can use this to also extend the procedure to add documentation for example the help commands and also the manual pages you can easily extend and add those commands into the into your tickle procedures so again I think these are like very very very useful and the helpful way to do this basically some tickle environments provide like libraries that already contain these extensions to add the documentation the help commands for example in the synopsis tickle environment you get like a couple of things one is the parse proc arguments and also procedure or proc attributes so once you set that proc attributes that pretty much you can use it for describing your help commands and manual pages and then the proc that that one is also like fairly simple to use essentially the way to use will be just give like there are like few fields that you describe on the procedure attributes which can be considered as attributes and then that is what will be used to process or to define that attributes so mainly like I mean you can specify the procedure the it is the the command it is also called like define proc attributes and you can specify your procedure name followed by dash info and then that info will have so basically like the define procedure attributes and then it will specify you can specify the procedure name and then you can specify dash info and then you can specify a string with actually contains the information to display and then you can also like do some command groups and these command groups can be the arguments that you are defining and then here you can also define arguments and then this one will be like and what kind of arguments you have that is args and then basically like I mean what is the help command that will show and then what kind of type of argument it is and then this you can describe for all of them and then once you have this actually this is a group so once you define this whole thing this can be used as the documentation so once anyone like I mean wants to write the write and the help procedure or any type of arguments or any type of help procedure or the manner of pages they can use this command to describe them and then it will be it will be together with the procedure usually you have the procedure you write the procedure basically body and then at the end you will add the procedure attributes and then once you have the attributes then now the tickle interpreter can actually take the whole thing and then pass it and then if you are just calling the procedure that shall it will display the help information from the different walk attributes so I think this is this is another way like I mean another e learning thing so I want to also like give you the basic rules in tickle and then basically like I mean this will give you a good the framework when you start doing your typical program so rule number one this we saw earlier white space separates command name and each of the arguments so when we do the commands essentially like its command then followed by white space then R1 space R2 etc etc so this is one thing that I want you to understand and then the the other thing is also like I mean new lines and the semicolon separate the most so you have command one which is all of these arguments and then command two will be in the next line or you can say command one and then semicolon and then command two so now the question is if one of these arguments itself has a blank space then how do we or a new line how do we how do you write that so in that case essentially like I mean we need to use the grouping so the grouping is essentially through the quotes or through the braces so now let us see like I mean how back is done so that comes to the tickle rule number two the rule number two is on grouping so number one is this curly braces this prevents all substitutions by tickle interpreter so these two are very important prevents substitutions and tickle interpreter so as you recall the way that tickle is done is we have the tickle interpreter and then followed by parser so all the commands first go through the tickle interpreter it is interpreted into like multiple words and then that is sent to the parser and then the parser actually understands what the command is and then what is needed for that command so one thing to notice essentially like this once you start the group with the brace it groups all characters until a matching another brace is found and it also like prevents all the substitutions so like now let us look at this particular command while we started the brace as you know like the while has some two arguments this is argument one argument two the one is usually a condition and then argue two is the body so this condition we say basically expression $I plus $J less than 10 then do this while this is less than 10 is doing this body do you think this program will work a why or why not so here you look at this one basically there is a command substituting right here and since we are using the curly brace this prevents all the commands of situation so that means that once this is passed to the while while while is passed into the tickle interpreter it does not return anything it does return to both things so this will not work you need to actually like do this separately and then put it inside so that is one of the rules so now let us go to rule number three rule number three is essentially use the codes for weak grouping here substitutions are allowed by the tickle interpreter it groups all characters until a matching code is found one thing to note is there is no nesting of code so you cannot say like code and start something like I mean some $X plus then you can another start and then Y and then in this this does not work because up to here it is taken as one and then this code and code is taken and so your dollar Y is left with nothing so the nesting does not work in these kind of rules so this is another heating that I want you to keep in mind now let us look at the next rule the next rule is the backslash substitution this is used to code special characters essentially so here you can see one interesting program while foo you have a command or one or two return and here you see that basically like the new line is actually escaped with this this backslash so backslash and then the new line so what do you think this will happen so this when it executes this command this this backslash and the new line is replaced with the black space so this is as good as saying command or one or two so that is how this will work and then you can see that actually like for the when we start the curly braces we don't use escape new line essentially the reason for this is once you start the braces the command interpreter groups everything include inside that inside the two braces are basically like everything until the matching basis form so that means that basically these are automatically grouped into a single argument so we don't have to really do that and then here the tricky part is basically like the command interpreter me group everything and then sense it to the parser and then the parser first of all understands the command and basically like that it knows that it has two arguments complete that command and then it also sends this thing back to the interpreter which is basically a return to return the value so this is the the backslash substitution now the rule number 5 is the variable substitution we saw this also like I mean the first lecture of the second lecture actually the dollar causes the variable substitution and here the dollar and the variable name are replaced by the value of variable so whenever you say like dollar X and then it it finds what is the value of this X and then it replaces dollar X with the actual value and then finally the rule number 6 is the command substitution rule here essentially we use the square brackets to delimit the command one thing to note in command substitution is nesting of commands are okay and then everything including the square brackets is replaced by the command return value so this is another key thing key learning from this one so you can use this kind of method to actually do the command substitution and then the command replacement so in summary essentially like I mean you need to understand these six rules so in this module actually we went through quite a bit of tickling mainly we started describing the procedures I think you have the basic understanding of the procedure where we define the keyword proc and then we used the procedure name followed by the list of arguments and then then the procedure body so there are three params for the proc command itself and then once the procedure is defined then they just behave like built-in commands for example you can say like sub 1 3 will return value 2 and again or sub 1 of 35 this is the sub 1 is the procedure name and then the 3 is the argument here and then sub 1 of 3 returns to does it basically like subtract 3 from whatever I mean 1 from that argument value then the other thing that we also saw was the arguments can have the default values for example here decrement x and then y y is the another argument so usually like x-y but the default value of that y is 1 so if you don't specify only like decrement 5 then the answer will be 4 say decrement sorry DCR 5 4 then the answer is 1 so because like the default value for the second operator is one in this particular proc so this way like you can define multiple default conditions so this is the first thing that we saw here we saw like a quick example of the problem and how we can it will work or not work and then we started defining the scope because we need to set the scope and then if you use the variable inside a procedure you need to have explicitly the scope from outside so the way to give the scope to the variable is by using this keyword global and then the global needs to be specified inside the procedure in order to get the transfer from outside into into the procedure one thing to note is if you don't set this x and you are just using the global X it still does not work you need to the global itself does not set anything or X so that is another key thing so you need to have that variable set outside then you can use global to transfer that value into the procedure so then essentially so that that is what is shown here essentially so here the just by specifying like $1 does not mean that basically like it will get transferred you need to make sure that it is defined somewhere else and then you can use that inside this and then there are two other commands essentially like a poor and level they can they help you to pass some the bad the names by reference so here one quick example is implement one name up for one one name and this is war so what you can do is basically like now and then the and then we are actually like set the war to $ war plus one so now what happens is actually like and you can actually communicate this back to another place where this war is getting called and then this one here denotes the level basically up to there you can actually like send to send this variable so here war is only sent to the procedure that is outside of this and then if you want it to be even higher then you need to increment this one to two and things like that so that's the level naming essentially and then up level is similar kind of thing only for used for sending scripts from one level to the next level so and then we saw this variable length procedure and then we also noted like how we can use this for the both you know defining the positional arguments as well as non-positional arguments so how do we do this this is something that we saw and in this simple example actually go into more details so and then then we also like had some simple examples to remove those things and we saw like how we can document these procedures and then we also covered some little bit of error handling as to what kind of what is the error info and things like that essentially so we can use this error info to and then we can keep track of what is going on this again so with that I am also like I want to give you like some coding guidelines as to what you can do so here a couple of things that you want to make sure one is always use comments to match closing braces so because the braces are quite important so like when you close any brace make sure that you put that command out there so that whoever is reading they know that they have to close the comments the other one is need to add you can add the echo commands wherever possible so this also helps to provide some feedback and that by that people will understand what you are trying to do and what is actually printed out in those commands in the commands then make sure that you test your code in small chunks and then always use this error info that is what we saw in the debugging procedure and then finally we also saw like the six rules for effective tickle coding the rule number one is to understand the concept of white space which separate command name and all the arguments and then the new lines and the cosmic column separate commands so this is a very simple one just understand this one and then the rule number two is that grouping essentially the curly braces which prevents all the substitutions by tickle interpreter so here the keeping is also this tickle interpreter that I mentioned and then for the soft grouping essentially use the quotes or soft grouping this actually substitutes all the variables essentially and but there is no nesting of the quotes also the rule number five is to use the backslash substitution so how that works that's the keeping here you can review this one and then actually sorry this is the rule number four and then rule number five is the variable substitution which is by using the dollar here the variable is whenever we specify the variable name with the dollar that variable name is replaced by the value of the variable and then finally the last rule is the command substitution which is using the square brackets and the square brackets delimit the command here we can nest multiple commands essentially that we can start like this it's here and then blah blah blah and then start another one who and then who to and then close all of them so this is allowed so I think this basically as most of the basic tickle programming is all covered in these modules we will look at some of the advanced concepts from tickle in the next lecture and then after that we will start looking into tk as the next one okay thank you very much bye.