terminating a String in Smalltalk?
Hi all, How do you terminate a string in Smalltalk so that it can be written to a file? Thanks, Sheridan
On 03 Dec 2014, at 19:14, sheridan@sheridan-mahoney.com wrote:
Hi all,
How do you terminate a string in Smalltalk so that it can be written to a file?
Thanks,
Sheridan
[ this is a question for pharo-users ] I don't understand the question, what is 'terminate a string' ? Here is how you write to a file: 'myfile.txt' asFileReference writeStreamDo: [ :out | out nextPutAll: 'Hello World!' ]. If you want a line end, you can do 'myfile.txt' asFileReference writeStreamDo: [ :out | out nextPutAll: 'Hello World!'; cr ]. There is also #lf and #crlf. It is also possible to do line end conversions. What are you trying to do, what does not work ? Sven
Hi Sheridan, On Wed, Dec 3, 2014 at 10:14 AM, <sheridan@sheridan-mahoney.com> wrote:
Hi all,
How do you terminate a string in Smalltalk so that it can be written to a file?
You don't need to. Smalltalk objects include their size so there is no need to add a null byte to recognise their end. One may need to copy a string to add a null byte if passing a string to e.g. C, but inside the system no null termination is ever needed. You might want to read some treatment of the Smalltalk object model such as the last section of the Blue Book, or the Back to teh Future paper or my presentation on SPur at ESUG 2014, or... Thanks,
Sheridan
-- best, Eliot
participants (3)
-
Eliot Miranda -
sheridan@sheridan-mahoney.com -
Sven Van Caekenberghe