Re: [Pharo-users] singleton trait

2017-01-21 Thread stepharong
Yes I like your blog entry. But my point is orthogonal :) On Sat, Jan 21, 2017 at 11:19:24AM +0100, stepharong wrote: Pay attention that Singleton should not be about access but time. If you can by adding on instance variable avoid to need a singleton then it means that it was not a

Re: [Pharo-users] singleton trait

2017-01-21 Thread Sven Van Caekenberghe
> On 21 Jan 2017, at 11:59, Peter Uhnak wrote: > > On Sat, Jan 21, 2017 at 11:19:24AM +0100, stepharong wrote: >> Pay attention that Singleton should not be about access but time. >> >> If you can by adding on instance variable avoid to need a singleton >> then it means that

Re: [Pharo-users] singleton trait

2017-01-21 Thread Peter Uhnak
On Sat, Jan 21, 2017 at 11:19:24AM +0100, stepharong wrote: > Pay attention that Singleton should not be about access but time. > > If you can by adding on instance variable avoid to need a singleton > then it means that it was not a singleton. > > A singleton is often: >you **CANNOT**

Re: [Pharo-users] singleton trait

2017-01-21 Thread stepharong
Pay attention that Singleton should not be about access but time. If you can by adding on instance variable avoid to need a singleton then it means that it was not a singleton. A singleton is often: you **CANNOT** have two instances at the same time. Many people do not use well

Re: [Pharo-users] singleton trait

2017-01-19 Thread Siemen Baader
On Thu, Jan 19, 2017 at 3:51 PM, Siemen Baader wrote: > > On Thu, Jan 19, 2017 at 11:33 AM, Cyril Ferlicot D. < > cyril.ferli...@gmail.com> wrote: > >> >> You just need a class variable #UniqueInstance and those methods: >> >> current >> "Can also be named #default or

Re: [Pharo-users] singleton trait

2017-01-19 Thread Cyril Ferlicot D.
On 19/01/2017 15:51, Siemen Baader wrote: > > Wouldn't a class instance variable be better? I want new singletons for > every subclass. > http://rmod-pharo-mooc.lille.inria.fr/MOOC/Slides/Week3/C019-W3S03-Basic-Variables.pdf I use a class variable because I try to avoid a maximum the use of the

Re: [Pharo-users] singleton trait

2017-01-19 Thread jtuc...@objektfabrik.de
Am 19.01.17 um 15:51 schrieb Siemen Baader: Wouldn't a class instance variable be better? I want new singletons for every subclass. http://rmod-pharo-mooc.lille.inria.fr/MOOC/Slides/Week3/C019-W3S03-Basic-Variables.pdf I would also have used super new, why BasicNew? But my wish to create

Re: [Pharo-users] singleton trait

2017-01-19 Thread Siemen Baader
On Thu, Jan 19, 2017 at 11:33 AM, Cyril Ferlicot D. < cyril.ferli...@gmail.com> wrote: > > You just need a class variable #UniqueInstance and those methods: > > current > "Can also be named #default or #instance" > ^ UniqueInstance > ifNil: [ UniqueInstance := self

Re: [Pharo-users] singleton trait

2017-01-19 Thread Siemen Baader
On Thu, Jan 19, 2017 at 11:37 AM, Sven Van Caekenberghe wrote: > The Traits would be cool to standardise the behaviour and to mark it as > such (implicit documentation) Exactly. > , however, Traits cannot add instance/class variables IIUC, that limits > what they can do (and

Re: [Pharo-users] singleton trait

2017-01-19 Thread Denis Kudriashov
2017-01-19 11:37 GMT+01:00 Sven Van Caekenberghe : > The Traits would be cool to standardise the behaviour and to mark it as > such (implicit documentation), however, Traits cannot add instance/class > variables IIUC, that limits what they can do (and would make it more than > one

Re: [Pharo-users] singleton trait

2017-01-19 Thread Sven Van Caekenberghe
The Traits would be cool to standardise the behaviour and to mark it as such (implicit documentation), however, Traits cannot add instance/class variables IIUC, that limits what they can do (and would make it more than one step). > On 19 Jan 2017, at 11:33, Cyril Ferlicot D.

Re: [Pharo-users] singleton trait

2017-01-19 Thread Cyril Ferlicot D.
On 19/01/2017 11:23, Siemen Baader wrote: > Is there a trait to quickly create singletons in Pharo, along the way of > the Ruby Singleton mixin? > > https://ruby-doc.org/stdlib-1.9.3/libdoc/singleton/rdoc/Singleton.html > > (and ideally also observer/observable, which I am going to need next..)

[Pharo-users] singleton trait

2017-01-19 Thread Siemen Baader
Is there a trait to quickly create singletons in Pharo, along the way of the Ruby Singleton mixin? https://ruby-doc.org/stdlib-1.9.3/libdoc/singleton/rdoc/Singleton.html (and ideally also observer/observable, which I am going to need next..) -- Siemen