Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Sunday September 26, 2004
01:43 PM

Running Squeak

[ #21058 ]

It's been a frustrating day trying to get Squeak up and running. One site had archives that I couldn't unpack. Another one had an "all in one" bundle that was a piece of cake to install. Unfortunately, I have to run inisqueak to create my image and it didn't seem to include that. After a bit of playing around, I created a $HOME/.squeak directory, copied Squeak3.7-5989-full.changes, Squeak3.7-5989-full.image and SqueakV3.sources over there, set my SQUEAK_IMAGE environment variable to point to an image file there and successfully ran Squeak. The main window has a variety of different screenshots(?) that I can zoom into and play with and some information that will probably prove useful, though it's a bit of a strange world for me.

It appears that to actually get to write code, I need to expand the System Browser window but Squeak is not automatically opening to that right away. I think that's right, but I'm not sure. I don't know if the image file I copied to the .squeak directory is not the one I wanted. I hover the mouse over various "things" and not all of them have tools tips.

After a bit of playing around and reading through a Squeak tutorial, I created various tiny methods and one of them looked like this:

hello: times say: text
    (times > 100)
        ifTrue: [ Transcript show: 'You will get bored!']
        ifFalse: [1 to: times do: [:i | (Transcript show: text) cr]]

Which can be invoked as:

Object new hello: 5 say: 'This is cool'

I now think I understand the lack of if statements (I'm sure my terminology is off.) The (times > 100) expression constructs a boolean objects which understands the message ifTrue:ifFalse:. Since everything is an object and you send messages to them, a bare if hanging out there would not fit the language design.

So how does the loop work? The number 1 (one) creates an integer object which understands the to:do: message. This is very cool, but I'll admit that it's a bit strange to me. I look forward to more play, but tuit reclamation is proceeding, as always, slowly.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Sometimes during a Perl class, I like to jerk the chains of the Java people who like to play OO-purist.

    I ask them "What methods can you call on 1?". They look at me dumbly for a bit. Sometimes they say something about creating a new object, and I have to reinforce the statement: "No, all you get is 1. What methods can you call on it?"

    It ends up the same: "I guess Java isn't an object oriented language then."
    • That's a classic example of people misunderstanding the terminology. Even my brief exposure to Squeak is showing me more. While I'm unsure of the process by which (foo > 5) creates a Boolean object in Squeak, it's now clear how the ifTrue:ifFalse messages work and why the traditional if/else statements are procedural in nature. It's not clear to me if mixing a bit of procedural code with OO code is bad, but then, I'm still exploring this. I suspect that the pure OO approach has benefits that get arou

      • The object to which methods are sent is always the left one. There are no prefix operators. Everything is left to right. So, in

        foo > 5

        you'd look for a greather-than binary message in the class (and superclasses) of value currently held in the foo variable. If it was:

        5 < foo

        you'd look for a less-than binary message in the class of 5 and its superclasses. Yes, a wacked-out system could make those do different things, but "with great power comes great responsibility".

        • Randal L. Schwartz
        • Stonehenge
  • Now I am wanting to test the Smalltalk waters! Thanks guys. :-)
  • gets the method calling syntax! It took me a while to wrap my head around it, but it's kind of useful because it helps from having a long, incongruous list of positional parameters.
    "Perl users are the Greatful Dead fans of computer science." --slashdot comment