. .

st4u

ST 4U 179: Read Streams in Smalltalk

January 9, 2012 8:33:59.246

Today's Smalltalk 4 You continues looking at the basic Smalltalk class libraries in VA Smalltalk - today it's the Stream libraries, focusing on reading. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Streams.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Today we'll look at the Stream class hierarchy, focusing on read streams. To get started, we want to browse the Stream hierarchy, in order to get a full picture of the local and inherited APIs:/p>

Streams

We are going to focus on the API methods (as per the ANSI specification, and experiment with a few simple examples in a workspace. The workspace code we'll use follows:


"read stream on a collection"
array := #(1 2 3 4 5 6 7 8 9 10).
stream := array readStream.

"get next item"
oneItem := stream next. 1

"get next 3"
nextThree := stream next: 3. (2 3 4)

"up to end"
rest := stream upToEnd. (5 6 7 8 9 10)

"set back to start"
stream reset.

"now peek - get next item, don't move position"
pos := stream position. 0
peeked := stream peek. 0
pos2 := stream position.  0

"skip first 3, get 4th"
stream skip: 3.
fourth := stream next. 4


You may be wondering about the text printed after each line; that's the result of doing a Display on each set of code. Try it yourself, and see if it all works the same way

Most of the examples work with streams that are positionable - i.e., there's a cursor into the stream, and we can freely move the cursor back and forth. That's true of internal streams and of file streams - but not of things like streams over a socket. Take a look at class PositionableStream and the APIs defined in it:

Positionable Streams

Here's a screen capture of the workspace after we've tried each line:

Experiment

The most important reading methods to understand are:

  • #next - get the next element from the stream
  • #next: - get the next N elements from the stream
  • #upToEnd - get the rest of the elements on the stream
  • #reset - reset the position back to the start
  • #peek - peek ahead one element without moving the cursor

It's worth trying a few experiments of your own - and notice that streams are not just about text. You can stream over any collection in Smalltalk, as our example above shows.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Technorati Tags: , ,

Enclosures:
[st4u179-iPhone.m4v ( Size: 7006057 )]

posted by James Robertson

 Share Tweet This

management

Customer Service, Anyone?

January 8, 2012 17:40:34.000

Best Buy is the latest entrant in the "when sales metrics run the show, everyone loses" sweepstakes:

As a sometime business school professor, I could just imagine the conversation with the TV department manager the day before. “Corporate says we have to work on what’s called up-selling and cross-selling,” the clerk was informed in lieu of actual training on either the products or effective sales. “Whenever you aren’t with a customer, you need to be roaming the floor pushing our deal with CinemaNow. At the end of the day, I want to know how many people you’ve approached.”

This is the sort of thing sales people think is effective. Why, I'm not sure, since nearly everyone I've ever met finds it irritating beyond belief. It sure is a widespread business meme though....

posted by James Robertson

 Share Tweet This

podcastAAC

IM 60: PHANtom for Pharo (AAC)

January 8, 2012 15:06:10.070

Welcome to episode 60 of Independent Misinterpretations - a Smalltalk and dynamic language oriented podcast with James Robertson and David Buck.

This week I have a recording from ESUG 2011 - Johan Fabry talking about PHANtom - an aspect language for Pharo.

You can subscribe to the podcast in iTunes (or any other podcatching software) using this feed directly or in iTunes with this one.

To listen now, you can either download the mp3 edition, or the AAC edition. The AAC edition comes with chapter markers. You can subscribe to either edition of the podcast directly in iTunes; just search for Smalltalk and look in the Podcast results. You can subscribe to the mp3 edition directly using this feed, or the AAC edition using this feed using any podcatching software. You can also download the podcast in ogg format.

If you like the music we use, please visit Josh Woodward's site. We use the song Troublemaker for our intro/outro music. I'm sure he'd appreciate your support!

If you have feedback, send it to jarober@gmail.com - or visit us on Facebook - you can subscribe in iTunes using this iTunes enabled feed.. If you enjoy the podcast, pass the word - we would love to have more people hear about Smalltalk!

Technorati Tags: , ,

Enclosures:
[im60.m4a ( Size: 15552871 )]

posted by James Robertson

 Share Tweet This

podcast

IM 60: PHANtom for Pharo

January 8, 2012 15:05:35.490

Welcome to episode 60 of Independent Misinterpretations - a Smalltalk and dynamic language oriented podcast with James Robertson and David Buck.

This week I have a recording from ESUG 2011 - Johan Fabry talking about PHANtom - an aspect language for Pharo.

You can subscribe to the podcast in iTunes (or any other podcatching software) using this feed directly or in iTunes with this one.

To listen now, you can either download the mp3 edition, or the AAC edition. The AAC edition comes with chapter markers. You can subscribe to either edition of the podcast directly in iTunes; just search for Smalltalk and look in the Podcast results. You can subscribe to the mp3 edition directly using this feed, or the AAC edition using this feed using any podcatching software. You can also download the podcast in ogg format.

If you like the music we use, please visit Josh Woodward's site. We use the song Troublemaker for our intro/outro music. I'm sure he'd appreciate your support!

If you have feedback, send it to jarober@gmail.com - or visit us on Facebook - you can subscribe in iTunes using this iTunes enabled feed.. If you enjoy the podcast, pass the word - we would love to have more people hear about Smalltalk!

Technorati Tags: , ,

Enclosures:
[im60.mp3 ( Size: 11196273 )]

posted by James Robertson

 Share Tweet This

podcasting

The Podcast Will Likely Be Late

January 8, 2012 10:22:35.541

I'm waiting on one bit of audio, and today is a travel day for me (back to Dallas for the new year). So - the podcast probably won't be posted until later this evening.

posted by James Robertson

 Share Tweet This

smalltalk

Returning to Smalltalk

January 7, 2012 0:35:20.133

Interesting commentary on how Smalltalk "feels" after a long absence, from Noel Rappin. It would be useful if the vendors (and OSS implementations) listened to some of the negatives and thought about them - these are exactly the kinds of roadblocks I recall bringing up more than once when I was at Cincom...

posted by James Robertson

 Share Tweet This

st4u

ST 4U 178: Working with Files in Pharo

January 6, 2012 13:54:41.506

Today's Smalltalk 4 You looks at basic file handling in Pharo - how to open files for reading and writing. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Files

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Technorati Tags: , ,

Enclosures:
[st4u178-iPhone.m4v ( Size: 4109228 )]

posted by James Robertson

 Share Tweet This

movies

Slamming the Barn Door

January 5, 2012 19:41:30.159

If the movie industry thinks that putting a bigger wait in front of Netflix and Redbox will bring back DVD sales, they are deeply, deeply confused:

A new deal between Time Warner’s movie studio and Netflix, Redbox and Blockbuster will double the “window” for new releases. That means the services will now have to wait 56 days after the discs first go on sale to offer them to their customers, instead of 28 days.

For the most part, movies aren't like music - most of us won't watch most movies more than once. Which means that Netflix or Redbox are the optimum choice. A bought DVD is expensive, takes up space, and is only watched once anyway.

The entire industry desperately needs a clue...

posted by James Robertson

 Share Tweet This

js4u

JS 4U 120: the Doublick Function in JQuery

January 5, 2012 9:36:56.559

Javascript 4 U

Today's Javascript 4 You looks at the dblClick() function in JQuery. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube.

Join the Facebook Group to discuss the tutorials. You can view the archives here.

To watch now, click on the image below:

dblClick()

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Technorati Tags: , ,

Enclosures:
[js4u120-iPhone.m4v ( Size: 1728654 )]

posted by James Robertson

 Share Tweet This

itNews

Dumb Headline of the Day

January 5, 2012 7:54:08.208

I think Baseline just started shouting "You Kids! Get Off My Lawn!"

Technorati Tags:

posted by James Robertson

 Share Tweet This

games

Thank You Thu'umcast Listeners!

January 4, 2012 23:55:33.820

This makes our day:

Technorati Tags: , ,

posted by James Robertson

 Share Tweet This

skyrimAAC

Thu'umcast 15: Is That a Skeleton Key in Your Pocket? (AAC)

January 4, 2012 23:40:32.190

Thu'umcast

Welcome to episode 15 of "Thu'umcast" - a podcast where Michael Lucas-Smith, Scott Dirk, Austin Haley, Makahlua and I document our trials and tribulations in Elder Scrolls V: Skyrim

Today we talk about the Thieves Guild Quest - top to bottom, with all the details you'll want to know to make your way through all of the nooks and crannies of the quest line. We also talk about what we liked, and what we didn't like about it.

If you liked our work on That Podcast, you'll probably like this. We intend to stay with the same idea - a gameplay podcast. If you don't want spoilers, don't listen - we are going to be talking about how we play the game, and what we ran across as we played.

You can subscribe in iTunes (or any podcatcher) using this feed, or this one for the AAC edition. We'll add the iTunes specific links as soon as they are available. In the meantime, join the Facebook Group and follow us on Twitter. If you play on Steam, join the Steam Group. Like the music? Pay Sbeast a visit, we thank him for letting us use it!

Links to all episodes and other information can be found on the Thu'umcast page.

If you want to download the podcast directly, we've provided it in three formats:

Got feedback? Tweet us!. Enjoy the podcast, and we'll see you in Skyrim!

Technorati Tags: , ,

Enclosures:
[thuum15.m4a ( Size: 26303961 )]

posted by James Robertson

 Share Tweet This

skyrim

Thu'umcast 15: Is That a Skeleton Key in Your Pocket?

January 4, 2012 23:39:48.030

Thu'umcast

Welcome to episode 15 of "Thu'umcast" - a podcast where Michael Lucas-Smith, Scott Dirk, Austin Haley, Makahlua and I document our trials and tribulations in Elder Scrolls V: Skyrim

Today we talk about the Thieves Guild Quest - top to bottom, with all the details you'll want to know to make your way through all of the nooks and crannies of the quest line. We also talk about what we liked, and what we didn't like about it.

If you liked our work on That Podcast, you'll probably like this. We intend to stay with the same idea - a gameplay podcast. If you don't want spoilers, don't listen - we are going to be talking about how we play the game, and what we ran across as we played.

You can subscribe in iTunes (or any podcatcher) using this feed, or this one for the AAC edition. We'll add the iTunes specific links as soon as they are available. In the meantime, join the Facebook Group and follow us on Twitter. If you play on Steam, join the Steam Group. Like the music? Pay Sbeast a visit, we thank him for letting us use it!

Links to all episodes and other information can be found on the Thu'umcast page.

If you want to download the podcast directly, we've provided it in three formats:

Got feedback? Tweet us!. Enjoy the podcast, and we'll see you in Skyrim!

Technorati Tags: , ,

Enclosures:
[thuum15.mp3 ( Size: 19231933 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 177: Opening Files in VA Smalltalk

January 4, 2012 11:30:05.552

Today's Smalltalk 4 You looks at opening and closing files in VA Smalltalk. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

Files.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Today we'll look at opening external files from VA Smalltalk, and how to read/write them once you've done that. To start with, have a look at the application CfsStreams:

CfsStreams

This is where the classes and APIS for reading/writing files are defined in VA Smalltalk. We'll start using CfsReadWriteFileStream to open and write a small file:


"open a file for read/write - if it does not exist, create it"
file := CfsReadWriteFileStream open: 'myNewFile.txt'.
file nextPutAll: 'This is my test text'.
file cr.
file close.

The first line opens the file - after which you can use standard stream methods to read and write text. Here we are simply writing some text, a CR, and then closing the file. The two methods of interest to us here are #open: and #close. The first you send to the class to open the file; the second you always send to close it. Once the file is out there, we can read it, and inspect the results to see what's there:

"open for reading" file := CfsReadFileStream open: 'myNewFile.txt'. data := file upToEnd. file close. ^data.

Read a File

Again, note the use of #open: and #close. Finally, what about error handling? Say a file you want to read doesn't exist? Here's the standard way to check for errors on file handling in VA:


"with error handling"
(file := CfsReadFileStream open: 'someFileNotThere.txt') isCfsError
		ifTrue: [^self error: file message].

All we're doing here is raising an exception on the error; you can, of course, do whatever handling makes sense in that block. Next time we'll get into the Stream APIs that were brushed over here.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Technorati Tags: , ,

Enclosures:
[st4u177-iPhone.m4v ( Size: 6705853 )]

posted by James Robertson

 Share Tweet This

smalltalk

ESUG 2012 to be in Ghent

January 4, 2012 8:19:12.445

ESUG has announced the timing and venue:

The ESUG board is glad to announce that the 2012 ESUG conference will be held at Gent in Belgium 27-31 August; Camp Smalltalk 25-26 August

Technorati Tags:

posted by James Robertson

 Share Tweet This

js4u

JS 4U 119: The closest() function in JQuery

January 3, 2012 11:40:04.708

Javascript 4 U

Today's Javascript 4 You looks at the closest() function in JQuery. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube.

Join the Facebook Group to discuss the tutorials. You can view the archives here.

To watch now, click on the image below:

closest()

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Technorati Tags: , ,

Enclosures:
[js4u119-iPhone.m4v ( Size: 1928140 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 176: Exploring Class String

January 2, 2012 12:39:42.341

Today's Smalltalk 4 You starts looking at the basic Smalltalk class libraries in VA Smalltalk, starting with String. If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:

String.

If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:


Today we'll start looking at some of the base Smalltalk class libraries in VA Smalltalk, starting with class String. To get started, we want to browse the String hierarchy, in order to get a full picture of the local and inherited APIs:/p>

Browse Hierarchy

Browse Hierarchy

After selecting the launcher pulldown and entering String in the dialog, you should see this:

String

The second pane from the left contains a list of all the applications that define or extend class String. If you look at the status line, you'll see the defining application; you can also find that by scrolling through the list and looking for the application notated with an asterisk. You can see the methods for one application, or select all applications and see the full (at least based on what you have loaded) definition:

Select all Applications

Notice the asterisk in application CLDT, which tells us where class String is defined:

CLDT

Looking at the method categories, you'll see the ANSI-API category, which contains the standard API for the class, as defined in the specification for Smalltalk. Open up a workspace, and you can try some of these messages out:


str := 'James Robertson'.
str asByteArray. 
str asSymbol. 
str at: 3. $m
str copy at: 3 put: $y.
str includes: $J. true
str replaceFrom: 1 to: 3 with: 'jam' startingAt: 1.

Try the second one; you should see this if you display the result:

Testing

Now try the #at:put: message:

Error

one of the changes made to Smalltalk by the ANSI spec was to make Strings read-only objects - that's the exception you are seeing. To do what is being tried here, you need to make a copy first. There's a lot more to explore in Class String - just try experimenting in a Workspace.

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Technorati Tags: , ,

Enclosures:
[st4u176-iPhone.m4v ( Size: 7993629 )]

posted by James Robertson

 Share Tweet This