Re: Initing sublacss with superclass method

richard <[email protected]> Fri, 18 Jul 2025 10:07:24 +0100
Newsgroups gmane.comp.lib.gnustep.devel
Message-ID <8a3b8baf-4106-47ee-968e-f3bb94725fd4@edison>
--EdoMail687a0ecc_74b0dc51_5008
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

 =20
 =20
 =20
I don't know what OSX does, and having methods of a mutable class (other =
than -copy...) return immutable instances is unusual/unintuitive, but fro=
m a performance point of view (because character sets can consume a lot o=
f memory) it makes complete sense for these methods to return shared/sing=
leton instances of immutable character sets.
 =20

 =20

 =20

 =20
 =20
 =20
 =20
 =20
>  =20
> On 18 Jul 2025 at 10:00, Riccardo Mottola  <riccardo.mottola=40libero.i=
t>  wrote:
>  =20
>  =20
>  Hi,
>
> =46rederik Seiffert wrote:
> >  I had changed these return types from id to NSCharacterSet in
> >   https://github.com/gnustep/libs-base/pull/501, because that is what=

> >  the implementation returns by calling =E2=80=9Ecopy=E2=80=9C on the =
created set before
> >  returning. This matches Apple platforms both in the implementation a=
nd
> >  header declaration.
>
> Oh, missed that one. This explain why these warnings are =22new=22 (but=
 the
> code itself is the same).
> I must then check what that call does on NSMutableCharacterSet on Apple=

> and see if we need another subclass method or there is some
> inconsistency here.
> Will comment or make a PR in case.
>
> Riccardo
>
>    =20
     
--EdoMail687a0ecc_74b0dc51_5008
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

<div id=3D=22edo-message=22><div><div style=3D=22font-size:16px=22>I don'=
t know what OSX does, and having methods of a mutable class (other than -=
copy...) return immutable instances is unusual/unintuitive, but from a pe=
rformance point of view (because character sets can consume a lot of memo=
ry) it makes complete sense for these methods to return shared/singleton =
instances of immutable character sets.</div><div style=3D=22font-size:16p=
x=22><br></div><div style=3D=22font-size:16px=22><br></div><div id=3D=22e=
do-signature=22></div></div></div><div id=3D=22edo-original=22><div><bloc=
kquote type=3D=22cite=22 style=3D=22margin: 1ex 0 0 0 =21important; borde=
r-left: 1px =23ccc solid =21important; padding-left: 0.4ex =21important;=22=
><div id=3D=22edo-meta=22>On 18 Jul 2025 at 10:00, Riccardo Mottola &lt;<=
a href=3D=22mailto:riccardo.mottola=40libero.it=22>riccardo.mottola=40lib=
ero.it</a>&gt; wrote: <br><br></div>
 =20
 =20
  <pre>Hi,<br><br>=46rederik Seiffert wrote:<br>&gt; I had changed these =
return types from id to NSCharacterSet in<br>&gt; <a style=3D=22color: rg=
ba(0,0,255,0.8)=22 href=3D=22https://github.com/gnustep/libs-base/pull/50=
1=22>https://github.com/gnustep/libs-base/pull/501</a>, because that is w=
hat<br>&gt; the implementation returns by calling =E2=80=9Ecopy=E2=80=9C =
on the created set before<br>&gt; returning. This matches Apple platforms=
 both in the implementation and<br>&gt; header declaration.<br><br>Oh, mi=
ssed that one. This explain why these warnings are =22new=22 (but the<br>=
code itself is the same).<br>I must then check what that call does on NSM=
utableCharacterSet on Apple<br>and see if we need another subclass method=
 or there is some<br>inconsistency here.<br>Will comment or make a PR in =
case.<br><br>Riccardo<br><br></pre> =20
  <br> =20
 =20
</blockquote></div></div>
--EdoMail687a0ecc_74b0dc51_5008--