[vwnc] Question about invoking class side methods on an object instance..

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

[vwnc] Question about invoking class side methods on an object instance..

Rick Flower
Hi all...

While I'm not exactly an ST/VW newbie, I've never had to do this  
before.. I want to have a object that has some class side methods  
indicating what properties it has and invoke these on an instantiated  
object.  However, I find that I get a DNU when looking for the class-
side methods when invoked on an instance.. However, if I invoke these  
methods on a uninstantiated class then it works OK.

Is this a feature of ST, or am I missing something?  Below is some  
code I'm working on related to Seaside -- specifically for menu  
descriptions:

Smalltalk.MyApp defineClass: #MSWMenuBase
        superclass: #{Seaside.WAComponent}
        indexedType: #none
        private: false
        instanceVariableNames: ''
        classInstanceVariableNames: ''
        imports: ''
        category: ''

Smalltalk.MyApp defineClass: #MSWMenu_Home
        superclass: #{MyApp.MSWMenuBase}
        indexedType: #none
        private: false
        instanceVariableNames: ''
        classInstanceVariableNames: ''
        imports: ''
        category: ''

menuItem1 class isAdminFeature
        ^ false

menuItem1 class isLoggedInContent
        ^ true


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Question about invoking class side methods on an object instance..

Rick Flower
Never mind.. I found that if I put the keyword "class" before the  
method name being called then it works fine..

-- Rick

On Jan 1, 2009, at 1:33 PM, Richard E. Flower wrote:

> Hi all...
>
> While I'm not exactly an ST/VW newbie, I've never had to do this
> before.. I want to have a object that has some class side methods
> indicating what properties it has and invoke these on an instantiated
> object.  However, I find that I get a DNU when looking for the class-
> side methods when invoked on an instance.. However, if I invoke these
> methods on a uninstantiated class then it works OK.
>
> Is this a feature of ST, or am I missing something?  Below is some
> code I'm working on related to Seaside -- specifically for menu
> descriptions:
>
> Smalltalk.MyApp defineClass: #MSWMenuBase
> superclass: #{Seaside.WAComponent}
> indexedType: #none
> private: false
> instanceVariableNames: ''
> classInstanceVariableNames: ''
> imports: ''
> category: ''
>
> Smalltalk.MyApp defineClass: #MSWMenu_Home
> superclass: #{MyApp.MSWMenuBase}
> indexedType: #none
> private: false
> instanceVariableNames: ''
> classInstanceVariableNames: ''
> imports: ''
> category: ''
>
> menuItem1 class isAdminFeature
> ^ false
>
> menuItem1 class isLoggedInContent
> ^ true
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Question about invoking class side methods on an object instance..

Travis Griggs-3
In reply to this post by Rick Flower

On Jan 1, 2009, at 1:33 PM, Richard E. Flower wrote:

> Hi all...
>
> While I'm not exactly an ST/VW newbie, I've never had to do this
> before.. I want to have a object that has some class side methods
> indicating what properties it has and invoke these on an instantiated
> object.  However, I find that I get a DNU when looking for the class-
> side methods when invoked on an instance.. However, if I invoke these
> methods on a uninstantiated class then it works OK.
>
> Is this a feature of ST, or am I missing something?  Below is some
> code I'm working on related to Seaside -- specifically for menu
> descriptions:
>
> Smalltalk.MyApp defineClass: #MSWMenuBase
> superclass: #{Seaside.WAComponent}
> indexedType: #none
> private: false
> instanceVariableNames: ''
> classInstanceVariableNames: ''
> imports: ''
> category: ''
>
> Smalltalk.MyApp defineClass: #MSWMenu_Home
> superclass: #{MyApp.MSWMenuBase}
> indexedType: #none
> private: false
> instanceVariableNames: ''
> classInstanceVariableNames: ''
> imports: ''
> category: ''
>
> menuItem1 class isAdminFeature
> ^ false
>
> menuItem1 class isLoggedInContent
> ^ true

An instance uses an expression like:

self class theClassMethod

to send messages to its classes.

--
Travis Griggs
Objologist
For every adage, there is an equal and contrary un-adage

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Question about invoking class side methods on an object instance..

Claus Kick
In reply to this post by Rick Flower
Richard E. Flower wrote:

> Hi all...
>
> While I'm not exactly an ST/VW newbie, I've never had to do this  
> before.. I want to have a object that has some class side methods  
> indicating what properties it has and invoke these on an instantiated  
> object.  However, I find that I get a DNU when looking for the class-
> side methods when invoked on an instance.. However, if I invoke these  
> methods on a uninstantiated class then it works OK.

So you have an object which is an instance of a class and you want to
send methods of the class to the object?

Just do

myObj class myClassMethod.

That way, you can always send class methods.

> Is this a feature of ST, or am I missing something?  

This is actually an OO feature which should even work in Java...

myObject.getClass().myClassMethod();


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Question about invoking class side methods on an objectinstance..

Andres Valloud-6
In reply to this post by Rick Flower
Keep in mind that the keyword "class" is actually a message.  For
example, try debugging this expression (type it in a workspace, right
click, debug it).

1.0d class instanceByteSize

Andres.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Richard E. Flower
Sent: Thursday, January 01, 2009 1:56 PM
To: Richard E. Flower
Cc: VW NC
Subject: Re: [vwnc] Question about invoking class side methods on an
objectinstance..

Never mind.. I found that if I put the keyword "class" before the method
name being called then it works fine..

-- Rick

On Jan 1, 2009, at 1:33 PM, Richard E. Flower wrote:

> Hi all...
>
> While I'm not exactly an ST/VW newbie, I've never had to do this
> before.. I want to have a object that has some class side methods
> indicating what properties it has and invoke these on an instantiated
> object.  However, I find that I get a DNU when looking for the class-
> side methods when invoked on an instance.. However, if I invoke these
> methods on a uninstantiated class then it works OK.
>
> Is this a feature of ST, or am I missing something?  Below is some
> code I'm working on related to Seaside -- specifically for menu
> descriptions:
>
> Smalltalk.MyApp defineClass: #MSWMenuBase
> superclass: #{Seaside.WAComponent}
> indexedType: #none
> private: false
> instanceVariableNames: ''
> classInstanceVariableNames: ''
> imports: ''
> category: ''
>
> Smalltalk.MyApp defineClass: #MSWMenu_Home
> superclass: #{MyApp.MSWMenuBase}
> indexedType: #none
> private: false
> instanceVariableNames: ''
> classInstanceVariableNames: ''
> imports: ''
> category: ''
>
> menuItem1 class isAdminFeature
> ^ false
>
> menuItem1 class isLoggedInContent
> ^ true
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Question about invoking class side methods on an object instance..

Rick Flower
In reply to this post by Claus Kick
Thanks Claus & Travis!

-- Rick

On Jan 1, 2009, at 2:33 PM, Claus Kick wrote:

> Richard E. Flower wrote:
>
>> Hi all...
>>
>> While I'm not exactly an ST/VW newbie, I've never had to do this
>> before.. I want to have a object that has some class side methods
>> indicating what properties it has and invoke these on an instantiated
>> object.  However, I find that I get a DNU when looking for the class-
>> side methods when invoked on an instance.. However, if I invoke these
>> methods on a uninstantiated class then it works OK.
>
> So you have an object which is an instance of a class and you want to
> send methods of the class to the object?
>
> Just do
>
> myObj class myClassMethod.
>
> That way, you can always send class methods.
>
>> Is this a feature of ST, or am I missing something?
>
> This is actually an OO feature which should even work in Java...
>
> myObject.getClass().myClassMethod();
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc