Questions tagged [gnu-smalltalk]

GNU Smalltalk is a free implementation of the Smalltalk-80 language. It runs on most POSIX compatible operating systems (including GNU/Linux, of course), as well as under Windows. Smalltalk is a dynamic object-oriented language, well-versed to scripting tasks.

GNU Smalltalk is a free implementation of the Smalltalk-80 language. It runs on most POSIX compatible operating systems (including GNU/Linux, of course), as well as under Windows. Smalltalk is a dynamic object-oriented language, well-versed to scripting tasks.

115 questions
3
votes
3 answers

Difference between instances created with and without `new` in GNU Smalltalk

What is the difference between Rectangle origin: 5@5 extent: 40@30 and Rectangle new origin: 5@5 extent: 40@30
adius
  • 13,685
  • 7
  • 45
  • 46
3
votes
0 answers

GNU Smalltalk command line arguments parsing explanation/documentation

Scripts that come with GNU Smalltalk installation use the following code to parse command line arguments: Smalltalk arguments: '-h|--help --usage --version' do: [ :opt :arg | opt = 'help' ifTrue: [ do something ... ]. …
3
votes
2 answers

Combinations WITH repetitions in Smalltalk

I need to generate all the possible combinations of N numbers including repetitions. Problem input: I have N cells where I can put one number in the interval 0 to: 9, in each cell. Wrong solution (with N = 4): (0 to: 3) permutationsDo: [ : each |…
3
votes
2 answers

How to run GUI related code in GNU Smalltalk?

I have the following code form Dolphin Smalltalk: digitalClockProcess := [[ Processor sleep: 1000. (View desktop canvas) font: (Font name: 'Arial' pointSize: 36) beBold; text: Time now printString at:…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
3
votes
3 answers

In Smalltalk, if x is an array, and x at: 3 put: 123 will work, then how can (x at: 3) + 1 work?

That is, if we look at it as all objects and messages, then "Did this earlier: x := Array new: 20" x at: 3 put: 123 "this will put 123 into slot 3" can work only if x at: 3 return like a "cell" object, so the cell can take in an Interger…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
3
votes
3 answers

How to override equality method in Smalltalk?

I'm reading a book on Smalltalk and I have an exercise about the anomaly of disappearing element I'm not able to solve. Object subclass: Book [ | isbn | setIsbn: anIsbn [ isbn := anIsbn. ] …
caisah
  • 1,959
  • 1
  • 21
  • 31
3
votes
1 answer

Visualworks Cincom Smalltalk SUnit Test case for error condition

I have this piece of code. |temp| temp := 5 (temp < 3) ifFalse:[ self error: 'Invalid input'. ]. What will a SUnit test case look like, if I have to test that the above error is raised when I run this code? Currently when I run the above code,…
3
votes
5 answers

What is the correct way to define and call functions in GNU Smalltalk?

Transcript show: 'Derp'. printSomething: 'Derpy'. "The method above produced this error:" "prog.st:3: expected expression" printSomething: what 10 timesRepeat: [ Transcript show:what. Transcript cr. ]. I'm trying to teach…
Anderson Green
  • 30,230
  • 67
  • 195
  • 328
3
votes
2 answers

floating point raises divide by zero error in GNU smalltalk (gst)

I installed gnu small talk in my Mac using port. sudo port install gst The version is 3.2.5 gst -v GNU Smalltalk version 3.2.5 Copyright 2009 Free Software Foundation, Inc. Written by Steve Byrne (sbb@gnu.org) and Paolo Bonzini…
prosseek
  • 182,215
  • 215
  • 566
  • 871
2
votes
1 answer

How to see object/class/context browser in GNU Smalltalk?

I run get and now I'm seeing blank screen. I expected object browser, but there isn't. I think there is some command for that. How can I see those object/class/context browser in GNU Smalltalk?
eonil
  • 83,476
  • 81
  • 317
  • 516
2
votes
1 answer

Smalltalk Prime Generator with a connected list not working

Been trying to debug this code for a while but I can't seem to understand the problem at hand. The program that I'm making is a Smalltalk program that has to use a connected list with nodes to generate prime numbers. The problem at hand apparently…
2
votes
1 answer

Smalltalk anomaly - why are the variables always the same, but when computing booleans they are different?

I chose to try out Smalltalk for AOC 2022 puzzle 4. I'm predicating on each line and increment the counter if the constraints are met. I'm trying to understand why the '2-8,3-7' line doesn't met the requirements. Therefore, I started printing out…
2
votes
2 answers

How do I get the current module/script/file name in GNU Smalltalk?

GNU Smalltalk omits the script name in argv. #!/usr/bin/env gst -f | argv program | argv := Smalltalk arguments. (argv size) > 0 ifTrue: [ program := argv at: 1. Transcript show: 'Program: ', program; cr. ] ifFalse: [ Transcript…
mcandre
  • 22,868
  • 20
  • 88
  • 147
2
votes
1 answer

Smalltalk: Is there something like "is in" or "is contained"?

I'm having trouble with Smalltalk. Is there some operator like "is in" or "is contained / included"? I have classes Student and Exam (with attribute student) and collections StudentsList and ExamsList. In the ExamsList, I would like to show all…
VM808
  • 31
  • 1
2
votes
4 answers

Smalltalk and Assertions

Tryng out some smalltalk + TDD + "good practices" I've run into a kinda ugly block: How do I do an assertion in GNU Smalltalk? I'm just looking for a simple ifFalse: [Die] kind of thing
Tordek
  • 10,628
  • 3
  • 36
  • 67