Archive for the ‘Pharo’ Category

Metacello: Conditional Loading

February 1st, 2013 No comments


The most frequent use case I have is for pending bug fixes. Imagine this… you find a bug in Pharo that you need fixed to progress on your project, so you fix it. Now, you’ll need the fix to be present anywhere your project is loaded, so what do you do while waiting for the fix to be integrated? You’re obviously not about to manually file in changesets when you have a powerful tool like Metacello! And anyway, you don’t want to have to edit the scripts for your continuous integration server.


I’ve found two ways I like to handle this scenario. I’ll show the (slightly) easier one first.

Method #1 – #customProjectAttributes

This is the method to use for Monticello packages

1. Make sure your configuration has #customProjectAttributes

Depending on the version of Metacello that was used to create your ConfigurationOfMyProject, you may have to add this method (which is easy enough).

In ConfigurationOfMyProject>>project, if you see the following two statements:

	"Construct Metacello project"
	constructor := (Smalltalk at: #MetacelloVersionConstructor) on: self.
	project := constructor project.

Change them to the following:

	project := MetacelloMCProject new projectAttributes: self customProjectAttributes. 
	constructor := (Smalltalk at: #MetacelloVersionConstructor) on: self project: project.
2. Define your custom attributes

#customProjectAttributes will return a collection of symbols that will be added to the Metacello platform symbols e.g. #’squeak4.4′ or #’pharo2.0.x’. The following is for the bug fix example we discussed earlier. The general process is a) declare a condition that let’s you know the fix hasn’t been applied in this image (e.g. a class is not present or DNU a message), and if true, add an attribute declaring that (e.g. #’PharoIssue6300′, as below).

	| requiresPharoFix6300 requiresPharoFix6382 attributes |
	attributes := OrderedCollection new.
	requiresPharoFix6300 := (Morph canUnderstand: #hasKeymapCategoryNamed:) not.
	requiresPharoFix6300 ifTrue: [ attributes add: #'PharoIssue6300' ].
	^ attributes.
3. Finally, add fixes to your baseline

With this method, they must be packaged with Monticello. See method #2 below if you have to use changesets or .st files

	spec for: #'PharoIssue6300' do: [
	spec package: 'SLICE-Issue-6300-Detach-keymaping-shortcuts' with: [
		spec repository: '' ].
	spec package: 'VimPharo' with: [ spec requires: #'SLICE-Issue-6300-Detach-keymaping-shortcuts' ] ].


Method #2 – #preLoadDoIt:

This is the method to use for changesets or .st files

1. Add a #preLoadDoIt: to your baseline

For example:

	spec for: #'common' do: [
		spec blessing: #'baseline'.
		spec preLoadDoIt: #preLoad.
2. Define your callback

This method is going to look much like #customProjectAttributes in method #1. The main difference is, since Metacello can not handle file-ins, you will load the code right in this method instead of delegating, as in the following example:

	| shouldFixIssue7294 |
	shouldFixIssue7294 := (EventHandler canUnderstand: #keyStrokeRecipient) not.
	shouldFixIssue7294 ifTrue: [ '/path/to/issue7294.cs' asFileReference fileIn. ].


So when would you want to use method #2? For one, you may already have a changeset handy. But the other reason is time decay. In Pharo, for example, because of the rapid pace of development, the package you fixed may have another fix applied first. Now, loading your version may silently replace those changes (this is what happens in the MC browser, I assume Metcello works the same way). I’m actually still figuring out the tradeoffs here for myself. For now, I default to method #1 unless I have a specific reason for #2.


So there you have a simple pattern to conditionally load packages or code files in a Metacello configuration

Hope it helps!

Categories: Pharo, Squeak Tags: , , ,

Pharo Smalltalk: An Acknowledgement

July 7th, 2012 1 comment

Mark Watson wrote a nice blog post about his appreciation for Pharo and its progress.

I was inspired to comment on my own experience of Pharo as we move toward 2.0:

Thanks for the shout, Mark! Given how much you’ve enjoyed Pharo so far, I think you’ll be really impressed after the 2.0 release – I’m sure it will be a game-changer.

Much of the work the past few years has been in improving Pharo under the hood, like the new compiler, class builder, vector graphics, keyboard shortcut framework, and countless cleanups. This has been coupled with great leaps in infrastructure, like the CI server testing many variants of Pharo and its VM on Mac, Window, and Linux with every commit.

Now, all these investments are starting to payoff for Pharo users:

  • Continuous integration has given us the confidence to replace the uggggly File library with FileSystem, a beautiful object-oriented library which is a joy to work with.
  • Nautilus, the new browser, has long-awaited features like a history and custom groups.
  • I’ve been playing around today with Vim bindings for Pharo tools, made easy by Keymapping.
  • Fuel is a new fast object serializer
  • Fuel might soon allow near-instantaneous bootstrap times for Metacello, the new package-mananagement system, which is getting closer to RubyGems (plus tools) every day
  • The Pharo Kernel is driving the system to become more modular

I feel that we are close to a tipping point where the system becomes so easy and fun for developers that we will see a self-perpetuating revolution in the IDE. For me, Vim bindings are something I’ve sorely missed since finding Smalltalk two years ago. It’s only now that I’ve seen in Pharo an opening to make that dream a reality…

Now, if we can just clean Morphic… ;-)

Categories: Pharo Tags:

Cocoa Smalltalk App

December 20th, 2011 No comments

For a while, I’ve been thinking about using MacRuby for native UIs and multiple windows in Pharo on the Mac. I uploaded a proof of concept to . It has a simple Cocoa UI that uses http to get a value (the current time) from a running Pharo image and displays it in a text field. See the discussion on the Pharo mailing list.

Categories: Mac, Pharo, Programming, Ruby, Smalltalk, Xcode Tags:

Metacello Toolbox

December 6th, 2011 2 comments

Metacello Is Cool

Metacello is a great project that manages your Smalltalk project’s dependencies on:

  1. other projects
  2. Smalltalk platforms (e.g. Squeak 4.2 vs. Pharo 1.2)

Overcoming the mess that package loading has historically been (imagine trying to guess which version to use of each package of multiple interoperating projects while the platform evolves beneath you!), it lets you say the programmatic equivalent of:

Before loading my project, you must load the current stable version of the OSProcess project. Then, for my first package: if this is Pharo1.2, load version X; if Squeak 4.2, load version Y…

But We Need Tools!

Writing configurations by hand can be a drag. But fear not! Dale and Co. have created an API to facilitate your workflow. It is described in detail in the draft chapter of Pharo By Example 2. Here’s a walkthrough of my first experience using it…

Describing Project Structure

    createBaseline: '1.0-baseline'
    for: 'SimpleApplescript' "Project name"
    repository: ''
    requiredProjects: #('OSProcess')
    packages: #('CommandShell-Piping' 'SimpleApplescript')
    repositories: #()
    dependencies: {
        ('SimpleApplescript' -> #('CommandShell-Piping')).
        ('CommandShell-Piping' -> #('OSProcess')) }
    groups: { ('default' -> #('SimpleApplescript')) }.

As good Smalltalk code, it does just what it says – describes the project and its dependencies – namely, that the SimpleApplescript package depends on CommandShell-Piping, which in turn depends on OSProcess. Usually, it would not be our responsibility to describe dependencies of an external package like CommandShell-Piping, but CommandShell currently has no Metacello configuration of its own, so we step in (although creating one would be cleaner :)). Here’s the method it generated:

baseline10: spec
    <version: '1.0-baseline'>
    spec for: #'common' do: [
        spec blessing: #'baseline'.
        spec repository: ''.
        spec project: 'OSProcess' with: [
                className: 'ConfigurationOfOSProcess';
                versionString: #'stable';
                repository: '' ].
            package: 'CommandShell-Piping' with: [
                spec requires: #('OSProcess' ). ];
            package: 'SimpleApplescript' with: [
                spec requires: #('CommandShell-Piping' ). ];
            package: 'SimpleApplescript-Specifications' with: [
                spec requires: #('SimpleApplescript' ). ].
        spec group: 'default' with: #('SimpleApplescript' 'SimpleApplescript-Specifications' ). ].

Now there was one thing I was unable to specify above. Because CommandShell-Piping is an external package, we need to tell Metacello where to find it (see how quickly things get complicated without Metacello). So I added a line to the generated baseline above:

package: 'CommandShell-Piping' with: [
        repository: ''; "added manually"
        requires: #('OSProcess' ). ];

Version Snapshot

    createDevelopment: '1.0'
    for: 'SimpleApplescript'
    importFromBaseline: '1.0-baseline'
    description: 'initial development version'.

Here, we just did something amazingly cool. Metacello walked through our project’s packages and dependencies and created a version with:

  • the current versions of each package
  • the appropriate version of each external project (e.g. stable, bleedingEdge)

Here’s the method it generated:

version10: spec
    <version: '1.0' imports: #('1.0-baseline' )>
    spec for: #'common' do: [
        spec blessing: #'release'.
        spec description: 'initial development version'.
        spec author: 'SeanDeNigris'.
        spec timestamp: '12/6/2011 10:38'.
        spec project: 'OSProcess' with: #'stable'.
            package: 'CommandShell-Piping' with: 'CommandShell-Piping-dtl.10';
            package: 'SimpleApplescript' with: 'SimpleApplescript-SeanDeNigris.1'. ].


PBE2 advises us to validate our configurations after editing. It’s easy to do, just printIt the following, which will return a collection of problems, if any:

MetacelloToolBox validateConfiguration: ConfigurationOfSimpleApplescript.

A configuration is Born

Now we have a functioning configuration. We will commit it so we can start testing it on the different platforms we support:

Gofer new
    url: '';
    package: 'ConfigurationOfSimpleApplescript';
    commit: 'Initial version of configuration'.

Release into the Wild

Once we are satisfied that our configuration is correct for all supported platforms (beyond the scope of this post, see the PBE2 draft chapter), we promote our current development version (the one we created a few steps ago) to released status:

    releaseDevelopmentVersionIn: ConfigurationOfSimpleApplescript
    description: '- release version 1.0'. "this will be the commit comment"


So the community can easily find our configuration, we copy it to (note that this location may change in the future as the community is rapidly evolving best practices for Metacello):

    copyConfiguration: ConfigurationOfSimpleApplescript
    to: ''.


Metacello solved a great need in the Squeak/Pharo ecosystem, and its tool support is making it easy and fun to use.

Here’s a github gist of the code above that you can customize to create your own configuration. Have fun!

Categories: Pharo, Smalltalk, Squeak Tags:

Objective-C in Smalltalk

May 2nd, 2011 6 comments

I’ve been playing with an Objective-C Bridge in Squeak and Pharo. Now I can do cool Cocoa things in-image! For example, sometimes I need a Mac app’s bundle identifier. I previously used a Ruby script. There are a few options, but the easiest is MacRuby:

p NSBundle.bundleWithPath('/Applications/').bundleIdentifier

Now, I can do it in Smalltalk, although it’s a little wordy:

bundle := ObjectiveCObject findClassName: 'NSBundle'.
aBundle := bundle bundleWithPath: '/Applications/' asNSStringUTF8.

There were two things annoying me about the above code:

  1. Object create – wow, a lot more complicated than MacRuby!
  2. #asNSStringUTF8 – I was certain that this could be done automatically by the bridge, and in fact, the above code has a memory leak, because the NSString must be released.

The first one, I did something about. I wrote a simple little class called ObjC to use like a namespace for ObjC classes. The above Smalltalk code becomes:

ObjC NSBundle bundleWithPath: '/Applications/' asNSStringUTF8.

Okay, we’re getting better… Currently not a part of the bridge, the changeset for the class is available here. I’m still working on the NSString issue, so standby…

Categories: Mac, Pharo, Smalltalk, Squeak Tags:

Pharo: (Multi) Select in World by dragging

January 19th, 2011 2 comments

Did you ever end up with a world overcrowded with Morphs that you no longer need?  Frequently, especially when I’m prototyping, I end up with something like this:

And I wish I could delete them all at once, so I went to implement “drag to select”, just like the standard behavior in a Mac or Windows desktop.  I was finished in under a minute because I’m an amazing programmer it already exists!  To turn it on, evaluate:

WorldState easySelectingWorld: true.

To make things easier and more obvious, I’ve added a setting for this and submitted it to the Pharo inbox.

Here’s a short screencast that shows how to start digging into Pharo, and the Settings Browser:

Categories: Pharo Tags:

Multiple Worlds for Pharo

January 18th, 2011 No comments

Do you ever feel restricted by just one world?  Would you rather have an entire universe of them, with a new blank canvas whenever you want one?

There is code in the inbox that allows you to do just that.  Visually, it’s like Squeak projects.  Although, there is no UI for this initial iteration, so you create and switch worlds via a simple API:

wm := WorldManager instance.
"Add a world"
wm createOrSwitchToWorldNamed: 'AnotherWorld'. 
"Return to the default world"
wm createOrSwitchToWorldNamed: 'Pharo'.

Try it out:

Categories: Pharo Tags:

Digging Cool Code out of Sophie

December 13th, 2010 2 comments

OpenSophie (“software for writing and reading rich media documents in a networked environment”) did a lot of great stuff that never made it back to Squeak Smalltalk (on which it was built). I just ported mp3 playing to current Squeak/Pharo, and there are many more treasures to be unearthed.

Here’s how to get started:

  1. Download the last Squeak-based version here
  2. Start the image either:
    1. With a current Squeak VM passing it this changeset, which unlocks it for development (select to file in entire file from the menu that pops up).  On the mac, you can do it like this from Terminal (n.b. Squeak VM Opt is inside the VM bundle):
      "path/to/Squeak VM Opt" /path/to/ /path/to/
    2. By launching the Sophie one-click app
      1. Bring up a user interrupt (Cmd-. on the Mac)
      2. Click the “Debug” button
      3. In the debugger, DoIt the following:
        1. (World findA: SophieRootMorph) delete.
        2. Transcript open.
        3. SophieApplication open.

You will find yourself in a Squeak image with an OpenSophie application running in a SystemWindow.

If you rescue any code, share it with the community! And if you make sure to cut and paste the OpenSophie license into it (e.g. in a class comment), it seems you’re in the clear*.

* not legal advice. I’m not a lawyer.

UPDATE: To start exploring a book programmatically, evaluate:

SophieApplication singleton activeBook
Categories: Pharo, Smalltalk, Squeak Tags:

Playing mp3s in Squeak Smalltalk

December 13th, 2010 No comments

Squeak’s VM has an mp3 plugin, but there doesn’t seem to be any access from the image. So I dug into OpenSophie (version 1 of which was based on Squeak) and yanked out some code.

You can now play mp3 files in Squeak and Pharo!


  1. Just load the SophiePort package from
  2. Then try:
    song := StreamingMP3Sound onFileNamed: '/path/to/yourFavorite.mp3'.
    song play.
    "song pause."


  • It works in Squeak 4.1 and Pharo 1.1.1 on Mac OS 10.6.5
  • I am unclear about the license – Sophie has one license, the code itself seems to be SqueakL. Do your own investigation.
  • There were checks like the following that had to be removed for Pharo 1.1.1: “WeakArray isFinalizationSupported ifFalse:[^anObject]“. I’m not sure of the implications of removing them
Categories: Pharo, Smalltalk, Squeak Tags:

Squeak/Pharo Presentation in NYC

September 20th, 2010 No comments

I’ll be giving a talk about Squeak and Pharo for the NYC Smalltalk group.  Details are at

Here is the abstract…

If you enjoy frequent (and long) personal breaks while waiting for your code to compile, stop reading now.  If tears of pride well up every time you behold the library of books you steamed through to learn C++, don’t come to this presentation.  We’ll be talking about Squeak & Pharo – active, open source, production-quality Smalltalk, and what makes it the baddest language on the block… 30 years later!  You may never have the heart to open your Java IDE again – here’s why:
* Productivity – 2.5 times more productive than Java or C++, with less errors
* Easy to learn – sending messages to objects is theonly concept
* Fun – write only code that matters, just the way you want; make any part of the system work how you say it should

UPDATE: Most of the magic happened in the group conversation itself, but here is the slideshow that nudged us along

Categories: Pharo, Smalltalk, Squeak Tags:

windows 7 product key

windows 7 product key

windows 7 key generator

windows 7 key generator

free winrar download

free winrar download

winzip activation code

winzip activation code

free winrar

free winrar

winzip free download

winzip free download

winrar free download

winrar free download

winrar download free

winrar download free

winzip free download full version

winzip free download full version

windows 7 activation crack

windows7 activation crack

windows 7 crack

windows 7 crack

free winzip

free winzip