The Trunk: Collections-topa.764.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-topa.764.mcz

commits-2
Tobias Pape uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-topa.764.mcz

==================== Summary ====================

Name: Collections-topa.764
Author: topa
Time: 14 October 2017, 1:30:58.746815 pm
UUID: 8b1c780c-c4fb-4a8c-baac-050c5a3e67c2
Ancestors: Collections-pre.763

Improve #initializedInstance and #empty for certain collections

=============== Diff against Collections-pre.763 ===============

Item was added:
+ ----- Method: Bitset class>>initializedInstance (in category 'instance creation') -----
+ initializedInstance
+
+ ^ self new: 0!

Item was added:
+ ----- Method: ByteArray class>>empty (in category 'instance creation') -----
+ empty
+ "A canonicalized empty ByteArray instance."
+ ^ #[]!

Item was added:
+ ----- Method: NonPointersOrderedCollection class>>initializedInstance (in category 'instance creation') -----
+ initializedInstance
+ " There are no instances of me, just my subclasses "
+ ^ self ~~ NonPointersOrderedCollection ifTrue: [super initializedInstance]
+ !

Item was added:
+ ----- Method: Symbol class>>empty (in category 'instance creation') -----
+ empty
+ "A canonicalized empty symbol."
+ ^ #''!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-topa.764.mcz

Nicolas Cellier


2017-10-14 13:28 GMT+02:00 <[hidden email]>:
Tobias Pape uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-topa.764.mcz

==================== Summary ====================

Name: Collections-topa.764
Author: topa
Time: 14 October 2017, 1:30:58.746815 pm
UUID: 8b1c780c-c4fb-4a8c-baac-050c5a3e67c2
Ancestors: Collections-pre.763

Improve #initializedInstance and #empty for certain collections

=============== Diff against Collections-pre.763 ===============

Item was added:
+ ----- Method: Bitset class>>initializedInstance (in category 'instance creation') -----
+ initializedInstance
+
+       ^ self new: 0!

Item was added:
+ ----- Method: ByteArray class>>empty (in category 'instance creation') -----
+ empty
+       "A canonicalized empty ByteArray instance."
+       ^ #[]!

Item was added:
+ ----- Method: NonPointersOrderedCollection class>>initializedInstance (in category 'instance creation') -----
+ initializedInstance
+       " There are no instances of me, just my subclasses "
+       ^ self ~~ NonPointersOrderedCollection ifTrue: [super initializedInstance]

Hi Tobias,
if there is no instances, shouldn't the message fail?

+       !

Item was added:
+ ----- Method: Symbol class>>empty (in category 'instance creation') -----
+ empty
+       "A canonicalized empty symbol."
+       ^ #''!





Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-topa.764.mcz

Tobias Pape

> On 15.10.2017, at 22:42, Nicolas Cellier <[hidden email]> wrote:
>
>
>
> 2017-10-14 13:28 GMT+02:00  <[hidden email]>:
> Tobias Pape uploaded a new version of Collections to project The Trunk:
> http://source.squeak.org/trunk/Collections-topa.764.mcz
>
> ==================== Summary ====================
>
> Name: Collections-topa.764
> Author: topa
> Time: 14 October 2017, 1:30:58.746815 pm
> UUID: 8b1c780c-c4fb-4a8c-baac-050c5a3e67c2
> Ancestors: Collections-pre.763
>
> Improve #initializedInstance and #empty for certain collections
>
> =============== Diff against Collections-pre.763 ===============
>
> Item was added:
> + ----- Method: Bitset class>>initializedInstance (in category 'instance creation') -----
> + initializedInstance
> +
> +       ^ self new: 0!
>
> Item was added:
> + ----- Method: ByteArray class>>empty (in category 'instance creation') -----
> + empty
> +       "A canonicalized empty ByteArray instance."
> +       ^ #[]!
>
> Item was added:
> + ----- Method: NonPointersOrderedCollection class>>initializedInstance (in category 'instance creation') -----
> + initializedInstance
> +       " There are no instances of me, just my subclasses "
> +       ^ self ~~ NonPointersOrderedCollection ifTrue: [super initializedInstance]
>
> Hi Tobias,
> if there is no instances, shouldn't the message fail?

No, it should return nil:

See last sentence of Comment in Behavior>>initializedInstance
        "Answer an instance of the receiver which in some sense is initialized.  In the case of Morphs, this will yield an instance that can be attached to the Hand after having received the same kind of basic initialization that would be obtained from an instance chosen from the 'new morph' menu.   Return nil if the receiver is reluctant for some reason to return such a thing"

        ^ self new

Best regards
        -Tobias
>
> +       !
>
> Item was added:
> + ----- Method: Symbol class>>empty (in category 'instance creation') -----
> + empty
> +       "A canonicalized empty symbol."
> +       ^ #''!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-topa.764.mcz

Nicolas Cellier


2017-10-16 9:06 GMT+02:00 Tobias Pape <[hidden email]>:

> On 15.10.2017, at 22:42, Nicolas Cellier <[hidden email]> wrote:
>
>
>
> 2017-10-14 13:28 GMT+02:00  <[hidden email]>:
> Tobias Pape uploaded a new version of Collections to project The Trunk:
> http://source.squeak.org/trunk/Collections-topa.764.mcz
>
> ==================== Summary ====================
>
> Name: Collections-topa.764
> Author: topa
> Time: 14 October 2017, 1:30:58.746815 pm
> UUID: 8b1c780c-c4fb-4a8c-baac-050c5a3e67c2
> Ancestors: Collections-pre.763
>
> Improve #initializedInstance and #empty for certain collections
>
> =============== Diff against Collections-pre.763 ===============
>
> Item was added:
> + ----- Method: Bitset class>>initializedInstance (in category 'instance creation') -----
> + initializedInstance
> +
> +       ^ self new: 0!
>
> Item was added:
> + ----- Method: ByteArray class>>empty (in category 'instance creation') -----
> + empty
> +       "A canonicalized empty ByteArray instance."
> +       ^ #[]!
>
> Item was added:
> + ----- Method: NonPointersOrderedCollection class>>initializedInstance (in category 'instance creation') -----
> + initializedInstance
> +       " There are no instances of me, just my subclasses "
> +       ^ self ~~ NonPointersOrderedCollection ifTrue: [super initializedInstance]
>
> Hi Tobias,
> if there is no instances, shouldn't the message fail?

No, it should return nil:

See last sentence of Comment in Behavior>>initializedInstance
        "Answer an instance of the receiver which in some sense is initialized.  In the case of Morphs, this will yield an instance that can be attached to the Hand after having received the same kind of basic initialization that would be obtained from an instance chosen from the 'new morph' menu.   Return nil if the receiver is reluctant for some reason to return such a thing"

        ^ self new

Best regards
        -Tobias

Ah OK, thanks,
I miss-interpreted the position of ^ and thought it would return self

>
> +       !
>
> Item was added:
> + ----- Method: Symbol class>>empty (in category 'instance creation') -----
> + empty
> +       "A canonicalized empty symbol."
> +       ^ #''!





Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-topa.764.mcz

Tobias Pape

> On 16.10.2017, at 18:48, Nicolas Cellier <[hidden email]> wrote:
>
>
>
> 2017-10-16 9:06 GMT+02:00 Tobias Pape <[hidden email]>:
>
> > On 15.10.2017, at 22:42, Nicolas Cellier <[hidden email]> wrote:
> >
> >
> >
> > 2017-10-14 13:28 GMT+02:00  <[hidden email]>:
> > Tobias Pape uploaded a new version of Collections to project The Trunk:
> > http://source.squeak.org/trunk/Collections-topa.764.mcz
> >
> > ==================== Summary ====================
> >
> > Name: Collections-topa.764
> > Author: topa
> > Time: 14 October 2017, 1:30:58.746815 pm
> > UUID: 8b1c780c-c4fb-4a8c-baac-050c5a3e67c2
> > Ancestors: Collections-pre.763
> >
> > Improve #initializedInstance and #empty for certain collections
> >
> > =============== Diff against Collections-pre.763 ===============
> >
> > Item was added:
> > + ----- Method: Bitset class>>initializedInstance (in category 'instance creation') -----
> > + initializedInstance
> > +
> > +       ^ self new: 0!
> >
> > Item was added:
> > + ----- Method: ByteArray class>>empty (in category 'instance creation') -----
> > + empty
> > +       "A canonicalized empty ByteArray instance."
> > +       ^ #[]!
> >
> > Item was added:
> > + ----- Method: NonPointersOrderedCollection class>>initializedInstance (in category 'instance creation') -----
> > + initializedInstance
> > +       " There are no instances of me, just my subclasses "
> > +       ^ self ~~ NonPointersOrderedCollection ifTrue: [super initializedInstance]
> >
> > Hi Tobias,
> > if there is no instances, shouldn't the message fail?
>
> No, it should return nil:
>
> See last sentence of Comment in Behavior>>initializedInstance
>         "Answer an instance of the receiver which in some sense is initialized.  In the case of Morphs, this will yield an instance that can be attached to the Hand after having received the same kind of basic initialization that would be obtained from an instance chosen from the 'new morph' menu.   Return nil if the receiver is reluctant for some reason to return such a thing"
>
>         ^ self new
>
> Best regards
>         -Tobias
>
> Ah OK, thanks,
> I miss-interpreted the position of ^ and thought it would return self

I should have done an ifFalse: [nil] right?

>
> >
> > +       !
> >
> > Item was added:
> > + ----- Method: Symbol class>>empty (in category 'instance creation') -----
> > + empty
> > +       "A canonicalized empty symbol."
> > +       ^ #''!