help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Writing to a File


From: Stewart Stremler
Subject: Re: [Help-smalltalk] Writing to a File
Date: Sat, 22 Jan 2005 18:28:46 -0800
User-agent: Mutt/1.3.28i

begin  quoting Isaac Gouy as of Sat, Jan 22, 2005 at 05:07:00PM -0800:
> I have only a few moments, so go look at the examples at 
> 
> http://shootout.alioth.debian.org/benchmark.php?test=all&lang=gst&sort=cpu

Noted. I will do that.
 
> and try and get it to work with stdout rather than a file.
> Then get it to work with a file.
> 
> Use variables 
>    | foo bar | 
> instead of Smalltalk at:

The 

| variable | 

notation doesn't persist beyond !, it seems.

And writing to stdout was what I first did, with 

foo do: [:item| item displayNl] ! instead of [:item| bar << item...],
and just now:

% gst
GNU Smalltalk ready

st> | foo bar |
st> foo := SortedCollection new.
st> foo add: 'one' ; add: 'two' ; add: 'three'.
st> bar := FileStream stdout.
st> foo do: [:item|bar << item ; cr ; nl ]!
one
three
two
O
st>

But it's not the | variable | notation that's the problem:


% gst
GNU Smalltalk ready

st> Smalltalk at: #foo put: (SortedCollection new)!
O
st> foo add: 'one' ; add: 'two' ; add: 'three'!
O
st> Smalltalk at: #bar put: (FileStream stdout) !
O
st> foo do: [:item|bar << item ; cr ; nl ]!
one
three
two
O
st> 

But thanks for the note about |variable| -- I was convinced it didn't
work, but had forgotton to check with an example that wasn't 
sprinkled with ! everywhere.

And the URL. I'll chase that one down now.

-- 
Stewart Stremler




reply via email to

[Prev in Thread] Current Thread [Next in Thread]