Simple scripts without "Smalltalk at: #b put: ..."

Going back and thinking about "what I've learned so far" in the few days I've been typing around on GNU Smalltalk, I noticed that I put something in my previous "example snippets" which wasn't immediately intuitive when I got started.

Motivation: when writing a simple script, or playing around with `gst`, you want to execute some block of code that requires various intermediate results, and get a final result you can inspect, without the pinkie-mangling jibber-jabber that is:

Smalltalk at: #z put: 'some value'!
Smalltalk at: #y put: 'another value'!

'instance creation' method inheritance

Tagged:  •  

help-smalltalk gets a question fairly frequently from users who don't know how to create Directory instances. (Incidentally, the answer is that you should use the instance creation methods inherited from File class.)

Some (very) simple networking examples

Tagged:  •  

While I'm still quite the Smalltalk beginner, in trying to learn how a few things are done in GNU Smalltalk I have tried to jot a few things down.

First I wrote a small and very simple (1 file listing) echo server using the TCP package directly:

Second I wrote a small and very simple chat server, which adds to the above by using a few classes, a few different file listings, and (of course) a bit of "state" on the server side to allow named connections and multi-person chat:

Fun with MD5 and Random

Tagged:  •  

GNU Smalltalk comes with a few fairly nice libraries if you want to generate alphanumeric passwords or salts, and compute MD5 digests, both fairly standard things you might want to do when dealing with storing sensitive data such as passwords.

You can generate some random strings fairly easily using built-in libraries without requiring any packages:

| d i l s |
  i := 20.
  d := '0123456789abcdefghijklmnopqrstuvwxyz'.
  l := d size.
  s := String new: i.
  1 to: i do: [ :x |
    s at: x put: (d at: (Random between: 1 and: l))
  s printNl!

Syndicate content

User login