Re: [Pharo-users] [OrderedCollection] add a reference or a copy?

2019-07-24 Thread sergio ruiz
Okay. This makes the entire universe make more sense. Thanks! > On Jul 24, 2019, at 9:30 AM, Esteban Maringolo wrote: > > Yes, it is the same. Everything is passed by "reference" (*). > And if you copy the collection you'll get two collections referencing > the same object. peace,

[Pharo-users] [OrderedCollection] add a reference or a copy?

2019-07-24 Thread sergio ruiz
I think my understanding of OrderedCollections has been incorrect for a very long time. I have never had a situation where it mattered, but in modeling a current project, I think I have been approaching it incorrectly. Since I have been using Smalltalk, I assumed that a copy of an object is

Re: [Pharo-users] [OrderedCollection] add a reference or a copy?

2019-07-24 Thread Esteban Maringolo
Yes, it is the same. Everything is passed by "reference" (*). And if you copy the collection you'll get two collections referencing the same object. E.g. | a c1 c2 | a := Object new. b := OrderedCollection with: a. b identityIncludes: a. "true" c := b copy. c identityIncludes: a. "true" (*)

[Pharo-users] OrderedCollection as an instance variable

2019-07-24 Thread sergio ruiz
I'm implementing an instance variable as an OrderedCollection, and am doing something idiotic. I have an Artist class. An Artist can have many tracks: tracks ^ tracks ifNil: [ self tracks: OrderedCollection new ] tracks: anObject tracks := anObject Doing something like: a := Artist

[Pharo-users] P8 regression

2019-07-24 Thread Hilaire
Hi, We have been hit in DrGeo by another regression in Pharo8 (it is not present in DrGeo versions based on previous Pharo). When loading a Sketch with accentuated Latin characters (same occurs with Chinese but I have so far not enough information to assert it is the same error) there is a

Re: [Pharo-users] OrderedCollection as an instance variable

2019-07-24 Thread sergio ruiz
Oh! how about this: tracks: anObject tracks := anObject. ^ tracks ? > On Jul 24, 2019, at 10:48 AM, Sven Van Caekenberghe wrote: > > because your #tracks: returns self, not the collection value peace, sergio photographer, journalist, visionary Public Key:

Re: [Pharo-users] OrderedCollection as an instance variable

2019-07-24 Thread Paul DeBruicker
You should change your #tracks method to tracks ^tracks ifNil:[tracks:=OrderedCollection new] or tracks tracks ifNil:[self initializeTracks] ^tracks initializeTracks tracks:=OrderedCollection new. Then you don't have to worry about the implementation of #tracks: changing in the

Re: [Pharo-users] OrderedCollection as an instance variable

2019-07-24 Thread Sven Van Caekenberghe
because your #tracks: returns self, not the collection value > On 24 Jul 2019, at 16:46, sergio ruiz wrote: > > I'm implementing an instance variable as an OrderedCollection, and am doing > something idiotic. > > I have an Artist class. > > An Artist can have many tracks: > > tracks > ^

Re: [Pharo-users] P8 regression

2019-07-24 Thread Sven Van Caekenberghe
Can you include the file that you are trying to load ? Also, the stack trace is very short. Are you sure XML parser is ready for Pharo 8 (i.e. are its tests green) ? > On 24 Jul 2019, at 16:59, Hilaire wrote: > > Hi, > > We have been hit in DrGeo by another regression in Pharo8 (it is not >

Re: [Pharo-users] OrderedCollection as an instance variable

2019-07-24 Thread sergio ruiz
hmm… maybe this is cleaner.. tracks tracks ifNil: [ self tracks: OrderedCollection new ]. ^ tracks > > > because your #tracks: returns self, not the collection value peace, sergio photographer, journalist, visionary Public Key: http://bit.ly/29z9fG0 #BitMessage

Re: [Pharo-users] P7 regression

2019-07-24 Thread Hilaire
Hi Sven, Le 24/07/2019 à 17:05, Sven Van Caekenberghe a écrit : > Can you include the file that you are trying to load ? Attached. It looks like issue come when saving the file. The UTF8 characters are not saved properly. The unix file command was indicating it is an utf8 but Emacs shows it was

Re: [Pharo-users] OrderedCollection as an instance variable

2019-07-24 Thread Marcus Denker
> On 24 Jul 2019, at 17:30, sergio ruiz wrote: > > hmm… > > maybe this is cleaner.. > > tracks > tracks ifNil: [ self tracks: OrderedCollection new ]. > ^ tracks > I write these methods as tracks ^tracks ifNil: [ tracks := OrderedCollection new ]. - one line

Re: [Pharo-users] OrderedCollection as an instance variable

2019-07-24 Thread sergio ruiz
> > tracks > ^tracks ifNil: [ tracks := OrderedCollection new ]. > > - one line > - does not mix using accusers and not using accessors. Okay, I totally get the subtlety now. I don’t even need an accessor. Thanks! peace, sergio photographer, journalist, visionary Public Key:

Re: [Pharo-users] OrderedCollection as an instance variable

2019-07-24 Thread Richard Sargent
I will add that I prefer the static model to tell the truth about its data types. So, I prefer having an #initialize method which ensures the new object is created in a self-consistent way and anyone looking at it in an inspector will see useful and correct information. Leaving instance variables

Re: [Pharo-users] OrderedCollection as an instance variable

2019-07-24 Thread Esteban Maringolo
I agree with that, but in some cases, like reading objects from an ORM, you would be creating lots of instances of objects that are going to be discarded right away. This would put no stress on GC since it would happen in the "new" space, but would consume more memory (although I never measured

Re: [Pharo-users] P7 regression

2019-07-24 Thread Sven Van Caekenberghe
> On 24 Jul 2019, at 17:32, Hilaire wrote: > > Hi Sven, > > Le 24/07/2019 à 17:05, Sven Van Caekenberghe a écrit : >> Can you include the file that you are trying to load ? > > Attached. > > It looks like issue come when saving the file. The UTF8 characters are > not saved properly. The

Re: [Pharo-users] P7 regression

2019-07-24 Thread sk via Pharo-users
--- Begin Message --- Hi Hilaire I downloaded latest Dr Geo and took a quick look at how the files are saved. It looks like the xml contents are not encoded (in UTF-8) but simply written to a binary write stream, which means that when a WideString is written you should consistently get a badly

Re: [Pharo-users] P7 regression

2019-07-24 Thread Sven Van Caekenberghe
That is correct, sk. #writeStreamDo: is enough though, #utf8 is the default encoding > On 24 Jul 2019, at 22:16, sk via Pharo-users > wrote: > > > From: sk > Subject: Re: [Pharo-users] P7 regression > Date: 24 July 2019 at 22:16:50 GMT+2 > To: Any question about pharo is welcome > > > Hi

[Pharo-users] Save the date: October 22nd in Ghent for a Smalltalk WebCamp

2019-07-24 Thread Johan Brichau
Hi Seaside users, We are organising a Smalltalk WebCamp day in the Yesplan offices in Ghent on October 22nd. The idea originated in the Seaside channel of the Pharo discord group. However, it’s not supposed to be Seaside only. All Smalltalkers doing web development, possibly involving other

Re: [Pharo-users] P7 regression

2019-07-24 Thread Hilaire
[...] stream := WriteStream on: (String new: 4000). DrGeoXml new    app: self app;    saveOn: stream. [...] DrGeoXml>>saveOn: stream     | doc writer root |     doc := XMLDocument new version: '1.0'.     writer := XMLWriter on: stream.     root := XMLElement named: #drgenius.     self

Re: [Pharo-users] [OrderedCollection] add a reference or a copy?

2019-07-24 Thread Richard O'Keefe
To a very good approximation, Smalltalk doesn't copy anything unless you ask it to. In this respect it's just like Java, Python, Ruby, ECMAScript, and most OO languages. C++ *does* like to copy things, but it is unusual. On Thu, 25 Jul 2019 at 00:46, sergio ruiz wrote: > I think my

Re: [Pharo-users] OrderedCollection as an instance variable

2019-07-24 Thread Richard O'Keefe
Comment 1. You probably meant to write tracks: aCollection ^tracks := aCollection Comment 2. This is a poor design. As it is, any object can replace the tracks of an artist with *anything*. And even without doing that, any object can add and remove items to an artist's tracks,