Programmatic generation of new class

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

Programmatic generation of new class

Brad Selfridge
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Brad Selfridge
Reply | Threaded
Open this post in threaded view
|

Re: Programmatic generation of new class

mbratch
Try putting parentheses around `aDescriptorSystemClassName asSymbol`:

        descriptorSystem :=
        DynamicDescriptorSystem subclass: (aDescriptorSystemClassName asSymbol)
                        instanceVariableNames: ''
                        classVariableNames: ''
                        package: packageName asString

On Fri, Jul 29, 2016 at 10:50 AM Brad Selfridge <[hidden email]> wrote:
I'm trying to programmatically generate a new class, but am getting the
following error:

DynamicDescriptorSystem class(Object)>>doesNotUnderstand:
#subclass:instanceVariableNames:classVariableNames:package:

This is the method that I'm trying to execute:

buildNewDescriptorSystemUsing: aDescriptorSystemClassName

        descriptorSystem :=
        DynamicDescriptorSystem subclass: aDescriptorSystemClassName asSymbol
                        instanceVariableNames: ''
                        classVariableNames: ''
                        package: packageName asString

I see examples of this all over Pharo and I copied this code almost
verbatim.

What am I doing wrong?



-----
Brad Selfridge
--
View this message in context: http://forum.world.st/Programmatic-generation-of-new-class-tp4908659.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Programmatic generation of new class

Blondeau Vincent

Hi,

 

The parentheses are not useful here: the unary message send (asSymbol) is made before the keyword one (subclass:instanceVariableNames:classVariableNames:packageJ

 

I tried :      

Object  subclass: 'Foo' asSymbol instanceVariableNames: '' classVariableNames: '' package: 'AAA' asString

On a fresh Pharo5.0 image and it works nice.

 

Vincent

 

De : Pharo-users [mailto:[hidden email]] De la part de Mark Bratcher
Envoyé : vendredi 29 juillet 2016 17:00
À : Any question about pharo is welcome
Objet : Re: [Pharo-users] Programmatic generation of new class

 

Try putting parentheses around `aDescriptorSystemClassName asSymbol`:

 

        descriptorSystem :=
        DynamicDescriptorSystem subclass: (aDescriptorSystemClassName asSymbol)
                        instanceVariableNames: ''
                        classVariableNames: ''
                        package: packageName asString

 

On Fri, Jul 29, 2016 at 10:50 AM Brad Selfridge <[hidden email]> wrote:

I'm trying to programmatically generate a new class, but am getting the
following error:

DynamicDescriptorSystem class(Object)>>doesNotUnderstand:
#subclass:instanceVariableNames:classVariableNames:package:

This is the method that I'm trying to execute:

buildNewDescriptorSystemUsing: aDescriptorSystemClassName

        descriptorSystem :=
        DynamicDescriptorSystem subclass: aDescriptorSystemClassName asSymbol
                        instanceVariableNames: ''
                        classVariableNames: ''
                        package: packageName asString

I see examples of this all over Pharo and I copied this code almost
verbatim.

What am I doing wrong?



-----
Brad Selfridge
--
View this message in context: http://forum.world.st/Programmatic-generation-of-new-class-tp4908659.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.


!!!*************************************************************************************
"Ce message et les pièces jointes sont confidentiels et réservés à l'usage exclusif de ses destinataires. Il peut également être protégé par le secret professionnel. Si vous recevez ce message par erreur, merci d'en avertir immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant être assurée sur Internet, la responsabilité de Worldline ne pourra être recherchée quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne saurait être recherchée pour tout dommage résultant d'un virus transmis.

This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Worldline liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.!!!"
Reply | Threaded
Open this post in threaded view
|

Re: Programmatic generation of new class

Peter Uhnak
In reply to this post by Brad Selfridge
Can you show the full trace? Because I am regularly doing something similar without any problems.
In fact if I copy/paste your code (and just change the classes that I have) it works fine.

Btw. did you override such methods in your system?

Peter

On Fri, Jul 29, 2016 at 07:05:04AM -0700, Brad Selfridge wrote:

> I'm trying to programmatically generate a new class, but am getting the
> following error:
>
> DynamicDescriptorSystem class(Object)>>doesNotUnderstand:
> #subclass:instanceVariableNames:classVariableNames:package:
>
> This is the method that I'm trying to execute:
>
> buildNewDescriptorSystemUsing: aDescriptorSystemClassName
>
> descriptorSystem :=
> DynamicDescriptorSystem subclass: aDescriptorSystemClassName asSymbol
> instanceVariableNames: ''
> classVariableNames: ''
> package: packageName asString
>
> I see examples of this all over Pharo and I copied this code almost
> verbatim.
>
> What am I doing wrong?
>
>
>
> -----
> Brad Selfridge
> --
> View this message in context: http://forum.world.st/Programmatic-generation-of-new-class-tp4908659.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: Programmatic generation of new class

Ben Coman
In reply to this post by Brad Selfridge
On Fri, Jul 29, 2016 at 10:05 PM, Brad Selfridge <[hidden email]> wrote:

> I'm trying to programmatically generate a new class, but am getting the
> following error:
>
> DynamicDescriptorSystem class(Object)>>doesNotUnderstand:
> #subclass:instanceVariableNames:classVariableNames:package:
>
> This is the method that I'm trying to execute:
>
> buildNewDescriptorSystemUsing: aDescriptorSystemClassName
>
>         descriptorSystem :=
>         DynamicDescriptorSystem subclass: aDescriptorSystemClassName asSymbol
>                         instanceVariableNames: ''
>                         classVariableNames: ''
>                         package: packageName asString
>
> I see examples of this all over Pharo and I copied this code almost
> verbatim.
>
> What am I doing wrong?

*very* strange.  That looks correct.  The only thing I can think of is
that you copy/pasted from somewhere and ended up with a hidden
character or strange unicode character that looks like a character but
is not.  Just for an experiments, can you try:
* Type it all out by hand
* Using ALL strings rather than those two calls.
* Change DynamicDescriptorSystem for Object.
* Try in a freshly downloaded Image.

cheers -ben

Reply | Threaded
Open this post in threaded view
|

Re: Programmatic generation of new class

Clément Béra
In reply to this post by Peter Uhnak
On old versions of Pharo you need to use:
#subclass:instanceVariableNames:classVariableNames:poolDictionaries:package:

That might be it.

On Fri, Jul 29, 2016 at 6:14 PM, Peter Uhnak <[hidden email]> wrote:
Can you show the full trace? Because I am regularly doing something similar without any problems.
In fact if I copy/paste your code (and just change the classes that I have) it works fine.

Btw. did you override such methods in your system?

Peter

On Fri, Jul 29, 2016 at 07:05:04AM -0700, Brad Selfridge wrote:
> I'm trying to programmatically generate a new class, but am getting the
> following error:
>
> DynamicDescriptorSystem class(Object)>>doesNotUnderstand:
> #subclass:instanceVariableNames:classVariableNames:package:
>
> This is the method that I'm trying to execute:
>
> buildNewDescriptorSystemUsing: aDescriptorSystemClassName
>
>       descriptorSystem :=
>       DynamicDescriptorSystem subclass: aDescriptorSystemClassName asSymbol
>                       instanceVariableNames: ''
>                       classVariableNames: ''
>                       package: packageName asString
>
> I see examples of this all over Pharo and I copied this code almost
> verbatim.
>
> What am I doing wrong?
>
>
>
> -----
> Brad Selfridge
> --
> View this message in context: http://forum.world.st/Programmatic-generation-of-new-class-tp4908659.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: Programmatic generation of new class

Brad Selfridge
I forgot to mention that I'm working in Pharo 4.0. I changed the "package:" parameter to "category:" and it worked like a charm. I guess that I need to move up to Pharo 5.0 pretty soon.
Brad Selfridge
Reply | Threaded
Open this post in threaded view
|

Re: Programmatic generation of new class

Tudor Girba-2

> On Jul 29, 2016, at 8:07 PM, Brad Selfridge <[hidden email]> wrote:
>
> I forgot to mention that I'm working in Pharo 4.0. I changed the "package:"
> parameter to "category:" and it worked like a charm. I guess that I need to
> move up to Pharo 5.0 pretty soon.

Yes, you do :)

Doru

>
>
> -----
> Brad Selfridge
> --
> View this message in context: http://forum.world.st/Programmatic-generation-of-new-class-tp4908659p4908717.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>

--
www.tudorgirba.com
www.feenk.com

"Be rather willing to give than demanding to get."