Towards a more consistent and sensible implementation of #isAbstract

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

Towards a more consistent and sensible implementation of #isAbstract

marcel.taeumel
Hi, there.

What are your thoughts on how to implement "MyClass class >> #isAbstract"? I think that one should always use #== and compare it to an actual class object like this:

MyClass class >> #isAbstract
   ^ self == MyClass

At the time of writing, we have various attempts in your image. You can browse them easily:


Best,
Marcel


Reply | Threaded
Open this post in threaded view
|

Re: Towards a more consistent and sensible implementation of #isAbstract

Hannes Hirzel
This looks like a useful cleanup

Many cases are like this

ArrayedCollection
isAbstract
        ^self = ArrayedCollection


So

isAbstract
        ^self == ArrayedCollection


is a better solution

--Hannes

On 12/7/17, Marcel Taeumel <[hidden email]> wrote:

> Hi, there.
>
> What are your thoughts on how to implement "MyClass class >> #isAbstract"? I
> think that one should always use #== and compare it to an actual class
> object like this:
>
> MyClass class >> #isAbstract
>    ^ self == MyClass
>
> At the time of writing, we have various attempts in your image. You can
> browse them easily:
>
>
> Best,
> Marcel

Reply | Threaded
Open this post in threaded view
|

Re: Towards a more consistent and sensible implementation of #isAbstract

Nicolas Cellier
I had the same question.
The case I had in mind when using = was:

    ArrayedCollection copy isAbstract.

No reason that it would not be abstract right?
Since = is inherited from Object and uses ==, it does not make a great difference currently...
Nevertheless, I let = for not insulting the future.

But if one wants to use == everywhere, I have no serious objection.


2017-12-08 7:15 GMT+01:00 H. Hirzel <[hidden email]>:
This looks like a useful cleanup

Many cases are like this

ArrayedCollection
isAbstract
        ^self = ArrayedCollection


So

isAbstract
        ^self == ArrayedCollection


is a better solution

--Hannes

On 12/7/17, Marcel Taeumel <[hidden email]> wrote:
> Hi, there.
>
> What are your thoughts on how to implement "MyClass class >> #isAbstract"? I
> think that one should always use #== and compare it to an actual class
> object like this:
>
> MyClass class >> #isAbstract
>    ^ self == MyClass
>
> At the time of writing, we have various attempts in your image. You can
> browse them easily:
>
>
> Best,
> Marcel




Reply | Threaded
Open this post in threaded view
|

Re: Towards a more consistent and sensible implementation of #isAbstract

Tobias Pape
Hi

> On 08.12.2017, at 09:54, Nicolas Cellier <[hidden email]> wrote:
>
> I had the same question.
> The case I had in mind when using = was:
>
>     ArrayedCollection copy isAbstract.
>
> No reason that it would not be abstract right?
> Since = is inherited from Object and uses ==, it does not make a great difference currently...
> Nevertheless, I let = for not insulting the future.
>
> But if one wants to use == everywhere, I have no serious objection.
>

I remember that for a portable solution (targetting a very old GemStone), I had to resort to the following strangeness:

MyTestCase
isAbstract
        ^ self name asString = 'MyTestCase'

Don't ask me why :D

Nevertheless, I'd actually like to not spell out the class name (b.c. of future renamings)
but since that is impossible to do practically, I'm fine with either #= or #==.
Consensus seems to be #==, so lets go with consistency and make them all #==

Best regards
        -Tobias

>
> 2017-12-08 7:15 GMT+01:00 H. Hirzel <[hidden email]>:
> This looks like a useful cleanup
>
> Many cases are like this
>
> ArrayedCollection
> isAbstract
>         ^self = ArrayedCollection
>
>
> So
>
> isAbstract
>         ^self == ArrayedCollection
>
>
> is a better solution
>
> --Hannes
>
> On 12/7/17, Marcel Taeumel <[hidden email]> wrote:
> > Hi, there.
> >
> > What are your thoughts on how to implement "MyClass class >> #isAbstract"? I
> > think that one should always use #== and compare it to an actual class
> > object like this:
> >
> > MyClass class >> #isAbstract
> >    ^ self == MyClass
> >
> > At the time of writing, we have various attempts in your image. You can
> > browse them easily:
> >
> >
> > Best,
> > Marcel
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Towards a more consistent and sensible implementation of #isAbstract

Chris Muller-3
In reply to this post by marcel.taeumel
With objects you should delegate to the the receiver to decide what #= means -- which in most cases will inherit that default implementation from Object anyway.  Sending #== is generally bad form.

Converting uses of #= to #== for "performance" is a bad idea except in the most inner, performance-critical code, and even then, it should be with a comment.


On Thu, Dec 7, 2017 at 2:30 AM, Marcel Taeumel <[hidden email]> wrote:
Hi, there.

What are your thoughts on how to implement "MyClass class >> #isAbstract"? I think that one should always use #== and compare it to an actual class object like this:

MyClass class >> #isAbstract
   ^ self == MyClass

At the time of writing, we have various attempts in your image. You can browse them easily:


Best,
Marcel






Reply | Threaded
Open this post in threaded view
|

Re: Towards a more consistent and sensible implementation of #isAbstract

marcel.taeumel
So it comes down to what "being abstract" actually means in the environment. :-) I think it means #== considering the current VM and the role of classes. Not sure in a the generic, object-oriented sense, though.

Best,
Marcel

Am 10.12.2017 00:02:06 schrieb Chris Muller <[hidden email]>:

With objects you should delegate to the the receiver to decide what #= means -- which in most cases will inherit that default implementation from Object anyway.  Sending #== is generally bad form.

Converting uses of #= to #== for "performance" is a bad idea except in the most inner, performance-critical code, and even then, it should be with a comment.


On Thu, Dec 7, 2017 at 2:30 AM, Marcel Taeumel <[hidden email]> wrote:
Hi, there.

What are your thoughts on how to implement "MyClass class >> #isAbstract"? I think that one should always use #== and compare it to an actual class object like this:

MyClass class >> #isAbstract
   ^ self == MyClass

At the time of writing, we have various attempts in your image. You can browse them easily:


Best,
Marcel






Reply | Threaded
Open this post in threaded view
|

Re: Towards a more consistent and sensible implementation of #isAbstract

Nicolas Cellier


2017-12-10 9:53 GMT+01:00 Marcel Taeumel <[hidden email]>:
So it comes down to what "being abstract" actually means in the environment. :-) I think it means #== considering the current VM and the role of classes. Not sure in a the generic, object-oriented sense, though.

Best,
Marcel

Am 10.12.2017 00:02:06 schrieb Chris Muller <[hidden email]>:

With objects you should delegate to the the receiver to decide what #= means -- which in most cases will inherit that default implementation from Object anyway.  Sending #== is generally bad form.

Converting uses of #= to #== for "performance" is a bad idea except in the most inner, performance-critical code, and even then, it should be with a comment.

Absolutely, if it's only for the sake of optimization, it's a bad decision.
Not to mention that isAbstract is not performance critical at all.

Maybe the intention is to really test for identity.
That's because we have the knowledge that classes are the unique instance of their metaclass.
So using = could be seen as an un-necessary indirection.

Reducing the level of indirection may reduce complexity.
But it is also reducing extensibility as noted by Marcel.

But do we want to elimiate complexity at all?
I see this related to "complex versus complicated" and the original biological analogy.
Are resilient/adptative systems necessarily complex?
If so, ideally such complex system should be built from simple behavior/rules.
What we want to avoid if possible is complicated things.

Nicolas

On Thu, Dec 7, 2017 at 2:30 AM, Marcel Taeumel <[hidden email]> wrote:
Hi, there.

What are your thoughts on how to implement "MyClass class >> #isAbstract"? I think that one should always use #== and compare it to an actual class object like this:

MyClass class >> #isAbstract
   ^ self == MyClass

At the time of writing, we have various attempts in your image. You can browse them easily:


Best,
Marcel










Reply | Threaded
Open this post in threaded view
|

Re: Towards a more consistent and sensible implementation of #isAbstract

marcel.taeumel
Either way, this looks like we should strive for consistency first. At the moment, it is not only #= vs. #== but there are also forms like "self name = #Foo" as mentioned by Tobias. Even if we vote for #=, class name comparison seems inappropriate.

Best,
Marcel

Am 10.12.2017 11:09:17 schrieb Nicolas Cellier <[hidden email]>:



2017-12-10 9:53 GMT+01:00 Marcel Taeumel <[hidden email]>:
So it comes down to what "being abstract" actually means in the environment. :-) I think it means #== considering the current VM and the role of classes. Not sure in a the generic, object-oriented sense, though.

Best,
Marcel

Am 10.12.2017 00:02:06 schrieb Chris Muller <[hidden email]>:

With objects you should delegate to the the receiver to decide what #= means -- which in most cases will inherit that default implementation from Object anyway.  Sending #== is generally bad form.

Converting uses of #= to #== for "performance" is a bad idea except in the most inner, performance-critical code, and even then, it should be with a comment.

Absolutely, if it's only for the sake of optimization, it's a bad decision.
Not to mention that isAbstract is not performance critical at all.

Maybe the intention is to really test for identity.
That's because we have the knowledge that classes are the unique instance of their metaclass.
So using = could be seen as an un-necessary indirection.

Reducing the level of indirection may reduce complexity.
But it is also reducing extensibility as noted by Marcel.

But do we want to elimiate complexity at all?
I see this related to "complex versus complicated" and the original biological analogy.
Are resilient/adptative systems necessarily complex?
If so, ideally such complex system should be built from simple behavior/rules.
What we want to avoid if possible is complicated things.

Nicolas

On Thu, Dec 7, 2017 at 2:30 AM, Marcel Taeumel <[hidden email]> wrote:
Hi, there.

What are your thoughts on how to implement "MyClass class >> #isAbstract"? I think that one should always use #== and compare it to an actual class object like this:

MyClass class >> #isAbstract
   ^ self == MyClass

At the time of writing, we have various attempts in your image. You can browse them easily:


Best,
Marcel










Reply | Threaded
Open this post in threaded view
|

Re: Towards a more consistent and sensible implementation of #isAbstract

Hannes Hirzel
On 12/10/17, Marcel Taeumel <[hidden email]> wrote:
> Either way, this looks like we should strive for consistency first. At the
> moment, it is not only #= vs. #== but there are also forms like "self name =
> #Foo" as mentioned by Tobias. Even if we vote for #=, class name comparison
> seems inappropriate.

Seaside (Grease / jQuery) uses

GRAbstractDictionaryTest
isAbstract
        ^ self name = #GRAbstractDictionaryTest

JSObjectTest

isAbstract
        ^ self name = #JSObjectTest


> Best,
> Marcel
> Am 10.12.2017 11:09:17 schrieb Nicolas Cellier



> <[hidden email]>:
>
>
> 2017-12-10 9:53 GMT+01:00 Marcel Taeumel <[hidden email]
> [mailto:[hidden email]]>:
>
> So it comes down to what "being abstract" actually means in the environment.
> :-) I think it means #== considering the current VM and the role of classes.
+1

> Not sure in a the generic, object-oriented sense, though.
>
> Best,
> Marcel
> Am 10.12.2017 00:02:06 schrieb Chris Muller <[hidden email]
> [mailto:[hidden email]]>:
> With objects you should delegate to the the receiver to decide what #= means
> -- which in most cases will inherit that default implementation from Object
> anyway.  Sending #== is generally bad form.

Bad because of what?

> Converting uses of #= to #== for "performance" is a bad idea except in the
> most inner, performance-critical code, and even then, it should be with a
> comment.
>
> Absolutely, if it's only for the sake of optimization, it's a bad decision.
> Not to mention that isAbstract is not performance critical at all.
>
> Maybe the intention is to really test for identity.
+1
> That's because we have the knowledge that classes are the unique instance of
> their metaclass.
+1

 So using = could be seen as an un-necessary indirection.

+1
> Reducing the level of indirection may reduce complexity.

> But it is also reducing extensibility as noted by Marcel.

In  which sense?

>
> But do we want to elimiate complexity at all?
> I see this related to "complex versus complicated" and the original
> biological analogy.
> Are resilient/adptative systems necessarily complex?
>
> If so, ideally such complex system should be built from simple
> behavior/rules.
> What we want to avoid if possible is complicated things.
>
> Nicolas
>
>
> On Thu, Dec 7, 2017 at 2:30 AM, Marcel Taeumel <[hidden email]
> [mailto:[hidden email]]> wrote:
>
> Hi, there.
>
> What are your thoughts on how to implement "MyClass class >> #isAbstract"? I
> think that one should always use #== and compare it to an actual class
> object like this:
>
> MyClass class >> #isAbstract
>    ^ self == MyClass
>
> At the time of writing, we have various attempts in your image. You can
> browse them easily:
>
>
> Best,
> Marcel
>
>
To summarize: We need a definition of what 'isAbstract' means and how
it should be implemented.

BTW Pharo has the same problem. Different implementations, including

isAbstract
    ^ true

or

isAbstract
    ^ false


--Hannes

Reply | Threaded
Open this post in threaded view
|

Re: Towards a more consistent and sensible implementation of #isAbstract

David T. Lewis
In reply to this post by Nicolas Cellier
On Sun, Dec 10, 2017 at 11:09:04AM +0100, Nicolas Cellier wrote:

> 2017-12-10 9:53 GMT+01:00 Marcel Taeumel <[hidden email]>:
>
> > So it comes down to what "being abstract" actually means in the
> > environment. :-) I think it means #== considering the current VM and the
> > role of classes. Not sure in a the generic, object-oriented sense, though.
> >
> > Best,
> > Marcel
> >
> > Am 10.12.2017 00:02:06 schrieb Chris Muller <[hidden email]>:
> > With objects you should delegate to the the receiver to decide what #=
> > means -- which in most cases will inherit that default implementation from
> > Object anyway.  Sending #== is generally bad form.
> >
> > Converting uses of #= to #== for "performance" is a bad idea except in the
> > most inner, performance-critical code, and even then, it should be with a
> > comment.
> >
> > Absolutely, if it's only for the sake of optimization, it's a bad decision.
> Not to mention that isAbstract is not performance critical at all.
>
> Maybe the intention is to really test for identity.
> That's because we have the knowledge that classes are the unique instance
> of their metaclass.
> So using = could be seen as an un-necessary indirection.
>
> Reducing the level of indirection may reduce complexity.
> But it is also reducing extensibility as noted by Marcel.
>
> But do we want to elimiate complexity at all?
> I see this related to "complex versus complicated" and the original
> biological analogy.
> Are resilient/adptative systems necessarily complex?
> If so, ideally such complex system should be built from simple
> behavior/rules.
> What we want to avoid if possible is complicated things.

Is one of these two approaches less complicated and easier to understand
with respect to Environments? I don't know the answer, just asking.

Dave


>
> Nicolas
>
> >
> > On Thu, Dec 7, 2017 at 2:30 AM, Marcel Taeumel <[hidden email]>
> > wrote:
> >
> >> Hi, there.
> >>
> >> What are your thoughts on how to implement "MyClass class >>
> >> #isAbstract"? I think that one should always use #== and compare it to an
> >> actual class object like this:
> >>
> >> MyClass class >> #isAbstract
> >>    ^ self == MyClass
> >>
> >> At the time of writing, we have various attempts in your image. You can
> >> browse them easily:
> >>
> >>
> >> Best,
> >> Marcel
> >>
> >>
> >>
> >>
> >
> >
> >
> >

>


Reply | Threaded
Open this post in threaded view
|

Re: Towards a more consistent and sensible implementation of #isAbstract

Nicolas Cellier


2017-12-10 16:26 GMT+01:00 David T. Lewis <[hidden email]>:
On Sun, Dec 10, 2017 at 11:09:04AM +0100, Nicolas Cellier wrote:
> 2017-12-10 9:53 GMT+01:00 Marcel Taeumel <[hidden email]>:
>
> > So it comes down to what "being abstract" actually means in the
> > environment. :-) I think it means #== considering the current VM and the
> > role of classes. Not sure in a the generic, object-oriented sense, though.
> >
> > Best,
> > Marcel
> >
> > Am 10.12.2017 00:02:06 schrieb Chris Muller <[hidden email]>:
> > With objects you should delegate to the the receiver to decide what #=
> > means -- which in most cases will inherit that default implementation from
> > Object anyway.  Sending #== is generally bad form.
> >
> > Converting uses of #= to #== for "performance" is a bad idea except in the
> > most inner, performance-critical code, and even then, it should be with a
> > comment.
> >
> > Absolutely, if it's only for the sake of optimization, it's a bad decision.
> Not to mention that isAbstract is not performance critical at all.
>
> Maybe the intention is to really test for identity.
> That's because we have the knowledge that classes are the unique instance
> of their metaclass.
> So using = could be seen as an un-necessary indirection.
>
> Reducing the level of indirection may reduce complexity.
> But it is also reducing extensibility as noted by Marcel.
>
> But do we want to elimiate complexity at all?
> I see this related to "complex versus complicated" and the original
> biological analogy.
> Are resilient/adptative systems necessarily complex?
> If so, ideally such complex system should be built from simple
> behavior/rules.
> What we want to avoid if possible is complicated things.

Is one of these two approaches less complicated and easier to understand
with respect to Environments? I don't know the answer, just asking.

Dave


Hi David,
I don't think so.
Different environments may have different bindings, but those point on same class.
== suppress one level of indirection with implicit knowledge that classes are unique.
IMO = does not make things more complicated.
But such indirection might be useful only if one day someone start using copies of a class and give a new definition of =
That's hypothetical for now.

>
> Nicolas
>
> >
> > On Thu, Dec 7, 2017 at 2:30 AM, Marcel Taeumel <[hidden email]>
> > wrote:
> >
> >> Hi, there.
> >>
> >> What are your thoughts on how to implement "MyClass class >>
> >> #isAbstract"? I think that one should always use #== and compare it to an
> >> actual class object like this:
> >>
> >> MyClass class >> #isAbstract
> >>    ^ self == MyClass
> >>
> >> At the time of writing, we have various attempts in your image. You can
> >> browse them easily:
> >>
> >>
> >> Best,
> >> Marcel
> >>
> >>
> >>
> >>
> >
> >
> >
> >

>