2018-12-22 - In IL: Print the Alphabet (break, continue)
One final aspect of looping that we haven't looked at yet are the use of break and continue statements. These statements allow you more control over how loops progress. break statements stop the loop and move to the next statement after the loop while continue statements stop the current loop and moves execution onto the next iteration. We are going to start by looking at the same for loop we had before but with some break and continue statements added.
This loop skips over all "even" letters and stops the loop when we hit the letter k. Now let's look at the compiled code.
This looks very close to our previous for loop but with extra code to check for even letters and the letter k. In the first case we branch to the incrementing part of the loop and continue on from there. In the second case we branch to the first statement after the loop. Now we are going to make those same modifications to the while loop we had before.
Now if we compile this we expect to see the same code as our for loop since the original fore loop and while loop compile to the same code.
Now you might say the compiled code is identical to the compiled code for the for loop and you would almost be right except for one important distinction. The continue part branches to the loop conditional check and not the increment part like the for loop does. This causes the program to go into an infinite loop and never exit.
As I mentioned when we looked at for loops the main difference between for loops and while loops is what is and isn't a part of the loop from the compiler's perspective. In the for loop case the incrementing is part of the loop so the compiler makes sure that's ran even if we use a continue. In the while case we are responsible for the incrementing so the compiler ignored it and goes straight to the conditional check. This is something to keep in mind when you are using break or continue.
Next time we're going to look at some array instructions.
2018-12-04 - Parts of Speech: Determiner
Determiners are a type of adjective used to help identify which instance of a noun is being referred to. They are similar to articles and depending on who you talk to articles may be considered a type of Determiner. One important distinction between determiners and normal descriptive adjectives is that the rules for combining determiners are usually stricter. There are several types of determiners.
Demonstrative determiners continue on from where articles left off and not only indicate that a specific noun is being talked about but attempt to indicate if the instance of the noun is close by (this, these) or far (that, those). Interrogative determiners are used to make questions. Which cat is that? What cat is that? Whose cat is that? Possessive determiners are used to indicate the owner of the noun. His cat. My cat. Your cat. Joe's cat. Numerical determiners are used to indicate how many instances of a noun there are. Some cats. Several cats. Thirty cats.
Determiners can often also be used as pronouns if the noun is omitted. This cat is mine versus This is my cat.
Next time we will look at adverbs.
2018-11-12 - Bookstore Adventure
I'm a fan of books, in particular old computer books. I'm fascinated by the evolution of computers and the different ways people have found to solve the same problem. Now it's easy enough to find old computer books online, and I've bought quite a few that way, but I would like it if I could buy some in person. It's easier to tell the condition of a book in person, you can read parts of it to find out if it's a book you would enjoy and you don't have to pay for or wait for shipping. So to that end I set out on an adventure to try and find a bookstore that would sell me old computer books.
The week previous I had gone to a second hand bookstore which said that their other location had computer books so that was my first stop. It turned out that they had new second hand computer books which aren't that interesting to me. I'm sure they are useful for some people but they weren't what I was looking for. I remembered there being a bookstore on 17th ave so I looked it up on my phone. I couldn't find another mention of the one I remembered but I did find two others around that area so I walked over there to check them out.
As I was walking I was starting to feel a bit thirsty but luckily there was a gas station around the next corner so I bought some water. I managed to find one of the bookstores my phone mentioned but it turned out to be a small retail bookstore that didn't have any computer books. I found a sign for the other store my phone mentioned but I couldn't find the actual store. I found out afterwards that the store my phone mentioned had closed down 5 years ago and that the bookstore that I remembered had closed down about a year ago. My guess is that because store which had closed more recently was part of a chain there were being around to remove it from maps and things while there was no one to bother about the other store so the information on it stayed around.
After wandering around there looking for stores I gave up and decided to take the train down south to a big retail bookstore. On my walk to the train I found a paper taped to a lamp post but didn't have a chance to read it because the light changed. While waiting for the train I saw a bus stop on top of the train tracks which I found a bit worrying. I did buy some fiction books at the retail bookstore but sadly they didn't have any old computer books either.
On my way home I decided that I wanted to take another look at the paper. So I went got off at the same train station I had gotten on at and walked back towards the paper. It turns out they were annoyed because sometimes they'd miss the walk light and have to wait for it to come around again and they wanted it to work without having to press the walk button. I can kind of understand that but I don't think it would ever annoy me enough to write out a letter and paste it around town.
While walking around that area looking for bookstores I remembered seeing a large convince store. I had gotten lunch on my way to the retail bookstore but I was feeling thirsty again so I walked over there to get another drink. After that I checked on buses and luckily there was a stop just a few blocks west of there for a route that would take me home. I walked over there and managed to get there just a minute before the bus came. I always find it interesting when things just seem to work out. You make a decision which just happens to setup other things. You don't plan it, it just works out that way.
Overall the adventure was more or less a bust. I did manage to buy some books but not the books that I had set out to get. That being said the walk was excellent, I saw some interesting things and isn't that what life's all about?
2018-09-01 - In IL: Print the Alphabet (Do Until)
In the last few parts we've been looking at C# loops, today we're going to look at a couple Visual Basic .NET loops. VB has a lot of the same loops as C#, with some syntax differences, but the Do Until and the Do ... Until loops are VB only. The Do Until loop is similar to the while loop except that instead of looping while the condition is true it loops until the condition is true, hence the Until keyword.
One thing you might notice about this code is the strange way the character is incremented. This is because Visual Basic .NET has different rules about implicitly converting characters to integers which requires us to explicitly convert the value to an integer, increment it, and then convert it back to being a character. Now let's compile it and see how that looks.
Except for the different instructions to increment the character this looks almost identical to the while loop version we saw previously.
Now let's look at the other version of the Do Until loop which puts the Until after the loop similar to the do ... while loop.
and if we compile that we get.
Again that looks very much like the do ... while loop we saw last time. The language gives you two ways of doing something but the compiler converts them into a single way by reversing your logic. The Until syntax is simply a tool for you to better describe your program's intentions using words.
Next time we will look at continue and break statements.