Smalltalk is an interpreted language!

Well started my assignments for the OOP class. It’s a simple introductory to smalltalk programming. I have to create a derived class from another provided by the professor. When I “compiled” the file, and passed it to the smalltalk interpreter, I encountered a problem! Smalltalk did not like me using my instantiated object:

” My Main! “
| sa |

sa := SavingsAccount new initialize: 50.
sa postInterest: 0.05 .
sa inspect
!

>./gst ~/Documents/grad_school/ooProgramming722/dev/savingsAccount.st
“Scavenging… 15% reclaimed, done”
“Scavenging… 0% reclaimed, done”
“Scavenging… 0% reclaimed, done”
“Scavenging… 0% reclaimed, done”
“Scavenging… 0% reclaimed, done”
“Scavenging… 0% reclaimed, done”
“Scavenging… 0% reclaimed, done”

Not so good, hunh? I am sure you smalltalk gurus already see my problem. Besides running smalltalk as a program and not installing it wherever make install puts it. Hint for all you non-programmers: interpreted languages are read from start to finish at the time the program is run.

See it yet? My SavingsAccount is derived from another class Account. (Am I using the correct smalltalk terminology?) I am passing only the savingsAccount file to the interpreter, and I am missing it’s parent. How will smalltalk know what the parent class looks like? Smalltalk was able to interpret the object in this file by just creating instances of a generic object to take place of the SavingsAccount’s super class. I guess it doesn’t like garbage collecting in this scenario. I must read the oop.h file to understand why but for now passing the parent class on the CLI does the trick.

Posted by broderic

Yo! I'm the writer here. Super sauce.