[Pharo-users] Books about Pharo
This is a new thread because it's not limited to any specific topic. If you have questions about Pharo, especially "how do I do in Pharo", you can always ask in this mailing list. You can, if you like playing Russian Roulette, ask a Large Language Model "AI". But there is an amazing resource you should really trye. books.pharo.org Did you ever wonder where the manual for Pharo was? That's where. The site lists a bunch of Pharo books and booklets, all of which have free PDFs except for two of the books. In particular, you'll always want the most recent edition of "Pharo by Example" handy. These books are really useful. They are written by people know know their material thoroughly and do a good job of explaining it. If you want to make any serious use of Pharo, or even to have more happiness than headaches just playing with it, you owe it to yourself to get the free PDFs What do we owe the authors? Well, if you're not trying to make one pension support four people, you owe them the purchase of some of the books. Me, I'm giving them thanks, praise, and a heartfelt recommendation. Seriously, these books represent a HUGE amount of work and "you are a fool to yourself and a burden to others" if you don't take advantage of this great resource.
[Pharo-users] Re: How to run multiple images?
+1 Cheers On Wednesday, January 24, 2024 at 10:17:31 AM GMT+1, Marcus Denker wrote: Yes, I would like to have drag-n-drop support, too. Or more specifically: double click of the imagein the Finder opens that image. (I am on the mac)
[Pharo-users] Re: Iterating over a Dictionary
This has not changed since Smalltalk-80. Running Smalltalk-80 and looking in the browser, I see Dictionary>> do: aBlock super do: [:assoc | aBlock value: assoc value]. 'super' here is Set, a Dictionary being implemented as a Set of Associations (which was always a bad idea). Dictionary>>do: has ALWAYS iterated over the elements of a dictionary, NOT the associatons. I have Squeak, Pharo, Smalltalk-80, VisuaWorks, VisualAe, Smalltalk/X, and GNU Smalltalk (plus several others including my own). They all follow the ANSI standard in this respect., The distinction between #do: and #associationsDo: goes back to Smalltalk-80, as does #keysDo:. On Wed, 24 Jan 2024 at 05:33, Joachim Tuchel wrote: > > So there we already have dialect differences … > > Am 23.01.2024 um 17:32 schrieb James Foster via Pharo-users > : > > myDict associationsDo: [: anAssociation | ]. > myDict keysDo: [:aKey | ]. > myDict valuesDo: [:aValue | ]. > myDict do: [:aValue | ]. “An alias for #valuesDo:” > > James Foster > > On Jan 23, 2024, at 8:27 AM, Joachim Tuchel wrote: > > AI knows little about Smalltalk ;-) > > You can use do: with each Association as a parameter or you can use > keysAndValuesDo: > > myDic do: [:assoc| | key value| key := assoc key. value := assoc value. ...]. > > myDic keysAndValuesDo: [:key :value| ...] > > > Joachim > > > > Am 23.01.24 um 17:24 schrieb sergio ruiz: > > I need to iterate over a dictionary. > > I asked the AI buddy for a little help, and he says: > > | myDictionary | > > "Create a dictionary" > myDictionary := Dictionary new. > myDictionary at: 'one' put: 1. > myDictionary at: 'two' put: 2. > myDictionary at: 'three' put: 3. > > "Iterate over the dictionary" > myDictionary do: [ :key :value | > Transcript show: key , ' -> ', value printString ; nl. > ]. > > but when i try this, I get: > > ArgumentsCountMismatch: This block accepts 2 arguments, but was called with 1 > argument. > > Is the AI using a different dialect of smalltalk? > > how would I go about acting on each pair? > > Thanks! > > > peace, > sergio > photographer, journalist, visionary > > Public Key: > https://pgp.key-server.io/pks/lookup?op=get=0x69B08F58923AB3A2 > #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV > @sergio_101@mastodon.social > https://sergio101.com > http://www.codeandmusic.com > http://www.twitter.com/sergio_101 > http://www.facebook.com/sergio101 > > -- > > --- > Objektfabrik Joachim Tuchel mailto:jtuc...@objektfabrik.de > Fliederweg 1 http://www.objektfabrik.de > D-71640 Ludwigsburg http://joachimtuchel.wordpress.com > Telefon: +49 7141 56 10 86 0Fax: +49 7141 56 10 86 1 > >
[Pharo-users] Re: Iterating over a Dictionary
Wrong. If you want to iterate of the associations of a dictionary, you need #associationsDo:. #do: passes the *values* to the block, *NOT* the associations. On Wed, 24 Jan 2024 at 05:28, Joachim Tuchel wrote: > > AI knows little about Smalltalk ;-) > > You can use do: with each Association as a parameter or you can use > keysAndValuesDo: > > myDic do: [:assoc| | key value| key := assoc key. value := assoc value. ...]. > > myDic keysAndValuesDo: [:key :value| ...] > > > Joachim > > > > Am 23.01.24 um 17:24 schrieb sergio ruiz: > > I need to iterate over a dictionary. > > I asked the AI buddy for a little help, and he says: > > | myDictionary | > > "Create a dictionary" > myDictionary := Dictionary new. > myDictionary at: 'one' put: 1. > myDictionary at: 'two' put: 2. > myDictionary at: 'three' put: 3. > > "Iterate over the dictionary" > myDictionary do: [ :key :value | > Transcript show: key , ' -> ', value printString ; nl. > ]. > > but when i try this, I get: > > ArgumentsCountMismatch: This block accepts 2 arguments, but was called with 1 > argument. > > Is the AI using a different dialect of smalltalk? > > how would I go about acting on each pair? > > Thanks! > > > peace, > sergio > photographer, journalist, visionary > > Public Key: > https://pgp.key-server.io/pks/lookup?op=get=0x69B08F58923AB3A2 > #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV > @sergio_101@mastodon.social > https://sergio101.com > http://www.codeandmusic.com > http://www.twitter.com/sergio_101 > http://www.facebook.com/sergio101 > > -- > > --- > Objektfabrik Joachim Tuchel mailto:jtuc...@objektfabrik.de > Fliederweg 1 http://www.objektfabrik.de > D-71640 Ludwigsburg http://joachimtuchel.wordpress.com > Telefon: +49 7141 56 10 86 0Fax: +49 7141 56 10 86 1 >
[Pharo-users] Re: Iterating over a Dictionary
There are many books about Smalltalk. Stephane Ducasse has made many of them available as FREE pdfs. Of course Pharo by Example would be a good start. The latest edition of Pharo by Example I have ready to hand is 8.0, 2020, where what you want is chapter 13, Collections. aCollection do: [:element | ...] aKeyedCollection keysAndValuesDo: [:key :element | ...] dictionaries are keyed and so are sequences. You can iterate over the elements of any collection using #do: with a one-argument block. The elements will be passed to the block and the keys will NOT. If you want the keys, must use #keysAndValuesDo: with a two-argument block. The keys and corresponding elements will be passed to the block. You "AI buddy" is a treacherous lying ignorant bastard. Such is the start of AI. 1. Open a browser on Dictionary. 2. Select "enumerating" the the method category panel (top row, third from left). 3. In the method panel (top row, rightmost) you will see do: keysAndValuesDo: keysDo: valuesDo: 4. Selecting them one at a time you will see do: aBlock ^self valuesDo: aBlock keysAndValuesDo: aBlock ^self associationsDo: [:assoc | aBlock value: assoc key value: assoc value] keysDo: aBlock ^self associationsDo:: [:association | aBlock value: associatoin key] valuesDo: aBlock tally = 0 ifTrue: [^self]. 1 to: array size do: [:eachIndex | |eachAssociation| eachAssociation := array at: eachIndex. nil == eachAssociation ifFalse: [ aBlock value: eachAssociation value]]. Now to fully make sense of this, you'd have to understand how a Dictionary is implemented in Pharo. (An Array whose elements are reach either nil or an Association holding a key and a value. This is a traditional Smalltalk implementation of dictionaries, but others except and some are better.) But you CAN see quite easily from this code that #do:, #keysDo:, and #valuesDo: pass just one value to their block argument, while #keysAndValuesDo: passes TWO values. And this is typicalk of trying to glean understanding by looking at the system source code: it is easy, you won't undersand everything, but you'll learn *something*. On Wed, 24 Jan 2024 at 05:24, sergio ruiz wrote: > > I need to iterate over a dictionary. > > I asked the AI buddy for a little help, and he says: > > | myDictionary | > > "Create a dictionary" > myDictionary := Dictionary new. > myDictionary at: 'one' put: 1. > myDictionary at: 'two' put: 2. > myDictionary at: 'three' put: 3. > > "Iterate over the dictionary" > myDictionary do: [ :key :value | > Transcript show: key , ' -> ', value printString ; nl. > ]. > > but when i try this, I get: > > ArgumentsCountMismatch: This block accepts 2 arguments, but was called with 1 > argument. > > Is the AI using a different dialect of smalltalk? > > how would I go about acting on each pair? > > Thanks! > > > peace, > sergio > photographer, journalist, visionary > > Public Key: > https://pgp.key-server.io/pks/lookup?op=get=0x69B08F58923AB3A2 > #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV > @sergio_101@mastodon.social > https://sergio101.com > http://www.codeandmusic.com > http://www.twitter.com/sergio_101 > http://www.facebook.com/sergio101 >
[Pharo-users] Re: How to run multiple images?
Yes, I would like to have drag-n-drop support, too. Or more specifically: double click of the image in the Finder opens that image. (I am on the mac) I did use it a lot when it worked, but talking to people it seemed that it was not used a lot bu others. I think the reason was that was quite cumbersome, as it only worked for real if you had just *one* VM associated with the .image extension in the Finder. As soon as you need different vms, this stops to be practical, and the Finder even gets confused which vm to use and it is a mess. A real solution would be to have the Launcher be in charge and start the image with the correct VM, this is something I have on my endless TODO to look at to see how hard this would be to support. Marcus > On 23 Jan 2024, at 18:06, sergio ruiz wrote: > > I am in the same boat. > > I have been using the pharo launcher for a few years, and it lets you do all > of these things with no fuss.. > > check out: https://pharo.org/download > >> On Jan 23, 2024, at 11:39 AM, Davide Varvello via Pharo-users >> wrote: >> >> First: it is not possible anymore to drag and drop the image file on the VM >> (pharo.app), it was very comfortable. >> >> Second: If I open the pharo.app and choose an image that becomes the only >> running image, I can't launch the pharo.app to run another image in parallel > > > peace, > sergio > photographer, journalist, visionary > > Public Key: > https://pgp.key-server.io/pks/lookup?op=get=0x69B08F58923AB3A2 > #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV > @sergio_101@mastodon.social > https://sergio101.com > http://www.codeandmusic.com > http://www.twitter.com/sergio_101 > http://www.facebook.com/sergio101 >
[Pharo-users] Re: How to run multiple images?
Thanks both Sergio and Noury, I'm not a big fan of the pharo launcher, but I'll give it a chance. Anyway I found that the problem to run multiple VMs is a constraint of macos, see https://www.totalphase.com/support/articles/200349376-multiple-application-instances-on-mac-os-x/ so if you want to run a couple of pharo.apps you should run them via terminal: open -n "/mypath pharo.app" Cheers Davide On Tuesday, January 23, 2024 at 06:06:51 PM GMT+1, sergio ruiz wrote: I am in the same boat. I have been using the pharo launcher for a few years, and it lets you do all of these things with no fuss.. check out: https://pharo.org/download On Jan 23, 2024, at 11:39 AM, Davide Varvello via Pharo-users wrote: First: it is not possible anymore to drag and drop the image file on the VM (pharo.app), it was very comfortable. Second: If I open the pharo.app and choose an image that becomes the only running image, I can't launch the pharo.app to run another image in parallel peace, sergio photographer, journalist, visionary Public Key: https://pgp.key-server.io/pks/lookup?op=get=0x69B08F58923AB3A2 #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV@sergio_101@mastodon.socialhttps://sergio101.com http://www.codeandmusic.com http://www.twitter.com/sergio_101 http://www.facebook.com/sergio101