Hi squeakers,
I was wondering how do squek start. Where is the entry point in the image. Abd so on.
Have you more information about it?
Thanks
___________________________________________________________________________ Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire. http://fr.mail.yahoo.com
This is a great question.
SmalltalkImage>>snapshot: save andQuit: quit embedded: embeddedFlag
the idea is that this is the same method that shutdown the image and that restart it. In fact when shutdoiwn the PC points on the next instruction to be executed that is to resume and restart the image :)
Stef
On 4 juin 06, at 02:06, mathieu wrote:
Hi squeakers,
I was wondering how do squek start. Where is the entry point in the image. Abd so on.
Have you more information about it?
Thanks
______________________________________________________________________ _____ Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire. http://fr.mail.yahoo.com _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
stéphane ducasse a écrit :
This is a great question.
SmalltalkImage>>snapshot: save andQuit: quit embedded: embeddedFlag
the idea is that this is the same method that shutdown the image and that restart it. In fact when shutdoiwn the PC points on the next instruction to be executed that is to resume and restart the image :)
Stef
Ok so if I have understand what you say evry time I quit, the image while restart whith at the following instruction (base on my 3.8 image):
quit & (resuming == false) ifTrue: [self quitPrimitive].
"Here" -> Cursor normal show. Smalltalk setGCParameters. resuming == true ifTrue: [Smalltalk clearExternalObjects]. Smalltalk processStartUpList: resuming == true. resuming == true ifTrue:[ self setPlatformPreferences. self readDocumentFile]. Smalltalk isMorphic ifTrue: [SystemWindow wakeUpTopWindowUponStartup]. "Now it's time to raise an error" resuming == nil ifTrue: [self error:'Failed to write image file (disk full?)']. ^ resuming
___________________________________________________________________________ Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire. http://fr.mail.yahoo.com
Am 04.06.2006 um 19:57 schrieb mathieu:
stéphane ducasse a écrit :
This is a great question.
SmalltalkImage>>snapshot: save andQuit: quit embedded: embeddedFlag
the idea is that this is the same method that shutdown the image and that restart it. In fact when shutdoiwn the PC points on the next instruction to be executed that is to resume and restart the image :)
Stef
Ok so if I have understand what you say evry time I quit, the image while restart whith at the following instruction (base on my 3.8 image):
quit & (resuming == false) ifTrue: [self quitPrimitive].
"Here" -> Cursor normal show. Smalltalk setGCParameters. resuming == true ifTrue: [Smalltalk clearExternalObjects]. Smalltalk processStartUpList: resuming == true. resuming == true ifTrue:[ self setPlatformPreferences. self readDocumentFile]. Smalltalk isMorphic ifTrue: [SystemWindow wakeUpTopWindowUponStartup]. "Now it's time to raise an error" resuming == nil ifTrue: [self error:'Failed to write image file (disk full?)']. ^ resuming
Almost. The program counter (PC) is frozen "inside" the snapshotPrimitive (right above the code you snipped). When saving the image (storing an object memory snapshot), that primitive returns false, so the quitPrimitive is not called. When starting an image (resuming from an earlier snapshot), it returns true. Some startup methods need to be run only when starting up, not every time the image is saved. That's why the value of this flag is passed to the startUp: methods of the classes in the startUpList.
- Bert -
Greetings from Finland. I am very excited about Squeak and SmallTalk - I have find myself trying and exploring new programming things and that hasn't happen since days of Commodore 64.
Now I am trying to build (with one partner) a program which uses MySQL. I wonder what would be best way to do login screen and actual program.
Now we have morphs in windows which has login and password fields and button. At this time idea is that this startup screen test login information and then sends user (or user id) to another screen.
I tested various styles and this kind of test "works" with button.
test := DatabaseTest new. loginbutton := MyButtonMorph new send: #executeTest to: test"; openInHand".
But what would be the best way to send many variables or values with button click. (I have couple TextFieldMorphs storing values)
I have googled a lot - and most examples deals scriptable buttons. (And that is something I am not familiar with - as a novice I must see code and try different things and see what's happening...)
Hi Marko,
How are things in Finland? I hear it is nice there and there seems to be a bit of a marketing campaign to get Americans to visit.
Anyway let's get to your question. There are a number of ways to pass variables around. The least effective way is to call methods with a lot of parameters. Usually when I see methods with lots of parameters there is a problem and the problem most likely is that the methods is implemented in the wrong class.
Consider for a moment an example (since you asked for code examples)
Object subclass: Car
Object subclass: Engine
Object subclass: Fuel
Object subclass: Spark
Now we all know that for engine it run it needs Fuel and Spark so we could model the car so that it has each
Car instanceVariables: 'engine fuel spark'
Then we have
Car>>start "Start the car" self engine startWithFuel: self fuel andSpark: self spark onCar: self
Engine>>startWithFuel: someFuel andSpark: someElectricity onCar: aCar "run the engine" [someFuel notEmpty] whileTrue: [ movement := someFuel burnFuelWith: someElectricity ]. aCar addMovement: movement
Car>>addMovement: someMovement "handle the movement of the engine through a transmission" self transmission handleMovement: someMovement
Ok so now I'm just amusing myself and thinking of the car being in idle so not using the fuel to move at all, wasting gas and promoting global warming.
Getting back to your question what would happen instead if we have the parameters modeled where they are needed. Ask yourself does the car need gas and fuel or does the engine need it instead?
So
Car instanceVariables: 'engine'
Engine instanceVariables: 'fuel spark transmission car'
Now when we build the objects we get much less parameter passing.
Car>>start "start the car" self engine start
Engine>>start "start the engine" [self fuel notEmpty] whileTrue: [ movement := self fuel burnFuelWith: self spark ]. self transmission addMovement: movement
Now this was a long answer to your question and you may be sitting there saying; "What does this have to do with databases and buttons"!
Well if you model your parameters in objects they don't need passing.
TestDatabase instanceVariables: 'dataSource user password myDBConnection'
Then your button's method #executeTest TestDatabase>>executeTest self myDBConnection on: self dataSource logon: self user password: self password.
Where dataSource can have host and port and dbname ...
I hope this helps for specific examples you could try http://www.google.com/search?hl=en&q=mysql+squeak
If this doesn't make sense, feel free to ask questions. Let me know how it goes!
Happy coding!
Ron Teitelbaum President / Principal Software Engineer US Medical Record Specialists Ron@USMedRec.com
From: Marko Koivuniemi Sent: Monday, June 05, 2006 4:14 PM
Greetings from Finland. I am very excited about Squeak and SmallTalk - I have find myself trying and exploring new programming things and that hasn't happen since days of Commodore 64.
Now I am trying to build (with one partner) a program which uses MySQL. I wonder what would be best way to do login screen and actual program.
Now we have morphs in windows which has login and password fields and button. At this time idea is that this startup screen test login information and then sends user (or user id) to another screen.
I tested various styles and this kind of test "works" with button.
test := DatabaseTest new. loginbutton := MyButtonMorph new send: #executeTest to: test"; openInHand".
But what would be the best way to send many variables or values with button click. (I have couple TextFieldMorphs storing values)
I have googled a lot - and most examples deals scriptable buttons. (And that is something I am not familiar with - as a novice I must see code and try different things and see what's happening...)
-- Marko _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
The problem with not testing my code:
Engine>>start "start the engine" [self fuel notEmpty] whileTrue: [ movement := self fuel burnFuelWith: self spark ]. self transmission addMovement: movement
Doesn't move until the gas runs out! :)
So how about:
Engine>>start "start the engine" self spark turnOnElectricity. self engageStarter. self car isKeyInOnPosition whileTrue: [ self runEngine ].
Engine>>runEngine "run engine and pass movement to car" self fuel notEmpty ifTrue: [ movement := self fuel burnFuelWith: self spark self transmission addMovement: movement ] ifFalse: [ self flashAnnoyingGasGuageLight. ].
Ok I realize I'm probably only amusing myself but just incase it helps someone I thought I'd point out my mistake!
Happy coding!
Ron
From: Ron Teitelbaum Sent: Tuesday, June 06, 2006 9:43 AM
Hi Marko,
How are things in Finland? I hear it is nice there and there seems to be a bit of a marketing campaign to get Americans to visit.
Anyway let's get to your question. There are a number of ways to pass variables around. The least effective way is to call methods with a lot of parameters. Usually when I see methods with lots of parameters there is a problem and the problem most likely is that the methods is implemented in the wrong class.
Consider for a moment an example (since you asked for code examples)
Object subclass: Car
Object subclass: Engine
Object subclass: Fuel
Object subclass: Spark
Now we all know that for engine it run it needs Fuel and Spark so we could model the car so that it has each
Car instanceVariables: 'engine fuel spark'
Then we have
Car>>start "Start the car" self engine startWithFuel: self fuel andSpark: self spark onCar: self
Engine>>startWithFuel: someFuel andSpark: someElectricity onCar: aCar "run the engine" [someFuel notEmpty] whileTrue: [ movement := someFuel burnFuelWith: someElectricity ]. aCar addMovement: movement
Car>>addMovement: someMovement "handle the movement of the engine through a transmission" self transmission handleMovement: someMovement
Ok so now I'm just amusing myself and thinking of the car being in idle so not using the fuel to move at all, wasting gas and promoting global warming.
Getting back to your question what would happen instead if we have the parameters modeled where they are needed. Ask yourself does the car need gas and fuel or does the engine need it instead?
So
Car instanceVariables: 'engine'
Engine instanceVariables: 'fuel spark transmission car'
Now when we build the objects we get much less parameter passing.
Car>>start "start the car" self engine start
Engine>>start "start the engine" [self fuel notEmpty] whileTrue: [ movement := self fuel burnFuelWith: self spark ]. self transmission addMovement: movement
Now this was a long answer to your question and you may be sitting there saying; "What does this have to do with databases and buttons"!
Well if you model your parameters in objects they don't need passing.
TestDatabase instanceVariables: 'dataSource user password myDBConnection'
Then your button's method #executeTest
TestDatabase>>executeTest self myDBConnection on: self dataSource logon: self user password: self password.
Where dataSource can have host and port and dbname ...
I hope this helps for specific examples you could try http://www.google.com/search?hl=en&q=mysql+squeak
If this doesn't make sense, feel free to ask questions. Let me know how it goes!
Happy coding!
Ron Teitelbaum President / Principal Software Engineer US Medical Record Specialists Ron@USMedRec.com
From: Marko Koivuniemi Sent: Monday, June 05, 2006 4:14 PM
Greetings from Finland. I am very excited about Squeak and SmallTalk - I have find myself trying and exploring new programming things and that hasn't happen since days of Commodore 64.
Now I am trying to build (with one partner) a program which uses MySQL. I wonder what would be best way to do login screen and actual program.
Now we have morphs in windows which has login and password fields and button. At this time idea is that this startup screen test login information and then sends user (or user id) to another screen.
I tested various styles and this kind of test "works" with button.
test := DatabaseTest new. loginbutton := MyButtonMorph new send: #executeTest to: test"; openInHand".
But what would be the best way to send many variables or values with button click. (I have couple TextFieldMorphs storing values)
I have googled a lot - and most examples deals scriptable buttons. (And that is something I am not familiar with - as a novice I must see code and try different things and see what's happening...)
-- Marko _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Hello Mathieu,
m> I was wondering how do squek start. Where is the entry point in the m> image. Abd so on.
If your question is "What does the Squeak VM do when it loads an image", I'm not qualified to reply. If nobody else here replies, the people who know can be found on Squeak dev.
If you mean how to manipulate the start of a squeak image here goes:
The VM accepts a startup script which besides some options takes the name of an image and the name of a Smalltalk source file which is executed at startup.
example on Windows: squeak.exe myImage.image myStartup.st More details on the Swiki, search for VM Command Line Options.
And Squeak has an autostart facility which executes certain methods when the image starts.
This is done via: Smalltalk addToStartupList YourStartupClass
YourStartupClass needs a class side method startUp: anIgnoredObject which is sent at the the start of the image. The parameter of startUp: is ignored afaik.
Another option is (not tested myself): SmalltalkImage current snapshot: true andQuit:false. self inform: yourStartupMessge.
If I'm totally beside your question I suggest you come back with a more specific one.
Cheers,
Herbert mailto:herbertkoenig@gmx.net
Hello Mathieu,
HK> Another option is (not tested myself): HK> SmalltalkImage current snapshot: true andQuit:false. HK> self inform: yourStartupMessge.
forgot to tell you: this has to be done in a workspace with a _single_ doIt.
From Stef's reply I learned why this works. The instruction pointer will just continue where it left off in snapshot:andQuit.
Thanks Stef!
Cheers,
Herbert mailto:herbertkoenig@gmx.net
Am 04.06.2006 um 10:14 schrieb Herbert König:
Hello Mathieu,
HK> Another option is (not tested myself): HK> SmalltalkImage current snapshot: true andQuit:false. HK> self inform: yourStartupMessge.
forgot to tell you: this has to be done in a workspace with a _single_ doIt.
From Stef's reply I learned why this works. The instruction pointer
will just continue where it left off in snapshot:andQuit.
Indeed, "saving an image" actually just freezes the execution inside the snapshot:andQuit: method. It's like hibernating your laptop computer - you just resume wherever you where before. The difference to modern computers though is that there *is* no way to cold-boot. The current Squeak image is actually running continuously for the last 10 years, only temporarily suspended to disc, so to say. There are 10 year old objects in the image, literally!
And even that image was not boot-strapped, but cloned from a Smalltalk-80 image. I think the last actual bootstrapping happened before 1976, so you could say we work with bits that are 30 years old. Next time you see nil, say hi to a very old friend ;-)
- Bert -
beginners@lists.squeakfoundation.org