Alan Knight | 1 Jun 2004 07:12
Picon
Favicon

Re: [Q] class creation on the fly?

Hmmm,

Behavior new
         superclass: Object;
         setInstanceFormat: Object format;
         methodDictionary: MethodDictionary new.

seems to work fine for me. Web Toolkit uses these if you define methods 
within a page, which admittedly isn't all that common, but I've not had a 
problem debugging or inspecting them, or with mysterious crashes.

At 09:15 PM 5/31/2004, Thomas Gagné wrote:
>Why does a dynamic class require a name?  If something is identified 
>automatically in a domain for which a class must be created to accomodate 
>instances of, it won't have a name.  It's class will be referenced and 
>instances created from it, but it is (in my case at least) transient.
>
>Imagine a class created to handle a database projection.  The programmer 
>doesn't need to name the projection, it simply exists because it was 
>projected (the existentialists among us need to resist the urge...).  It 
>has behaviors and data unique to itself and the programmer (or program) 
>knows how to communicate with it but does so without naming it.
>
>The closest I came without hacking too deeply (but seemed to caus 
>instability in the image) was:
>
>newClass := Behavior new
>        setInstanceFormat: self format;
>        setSuperclass: self;
>        methodDictionary: MethodDictionary new.
(Continue reading)

Thomas Gagné | 1 Jun 2004 07:17
Picon

Re: [Q] class creation on the fly?

What happens to you when you bring one up inside the inspector, or are 
you saying you never have need to?

Alan Knight wrote:

> Hmmm,
>
> Behavior new
>         superclass: Object;
>         setInstanceFormat: Object format;
>         methodDictionary: MethodDictionary new.
>
> seems to work fine for me. Web Toolkit uses these if you define 
> methods within a page, which admittedly isn't all that common, but 
> I've not had a problem debugging or inspecting them, or with 
> mysterious crashes.
>
--

-- 
.tom
remove email address' dashes for replies
The last calendar you'll ever need is at <http://www.coordidate.org/>
Opensource middleware at <http://isectd.sourceforge.net/>
<http://gagne.homedns.org/~tgagne/>

Alan Knight | 1 Jun 2004 13:52
Picon
Favicon

Re: [Q] class creation on the fly?

It doesn't like it if I switch to the methods view in the inspector, wants 
an #organization, which a behavior doesn't have. Otherwise it seems fine. 
And the "Browse" option doesn't work, as the browser can't find the class. 
If I defined #organization to return ClassOrganizer new and #definition to 
return self printString then the basic inspector worked.

However, if I add a method, at least if I add it using
newClass := (Behavior new
                         superclass: Core.Association;
                         setInstanceFormat: Core.Association format;
                         methodDictionary: MethodDictionary new).
newClass compile: 'printOn: aStream
    aStream nextPutAll: ''fred'''
    notifying: nil
   ifFail: [3 halt].
newClass new inspect.

then the source code for the method wasn't found and I ended up with 
decompiled code for it. I suspect I just need to set the source pointer 
properly (i.e. to the original string, as source pointers can be strings as 
well as being indexes into a source file).  I've made an AR (47598) for the 
browsing issues. If you know of others I'll add them.

Oh, I should note that I was trying this in a 7.2.1 prerelease build. I 
don't think much has changed in this area, but it's possible there were 7.2 
problems that have already been fixed for 7.2.1.

At 01:17 AM 6/1/2004, Thomas Gagné wrote:
>What happens to you when you bring one up inside the inspector, or are you 
>saying you never have need to?
(Continue reading)

Denis Johnson | 1 Jun 2004 14:29
Picon

Re: [Q] class creation on the fly?

Sorry to barge in, but on a related question, is there indeed a way to 
temporarily switch off logging changes ? I have a case where I have a 
web service client class built on the fly in a SUnit test to exercise 
the web service and then delete the client class. It would be nice not 
to pollute the change log each time the test is run.

regards Denis

Alan Knight wrote:

> It doesn't like it if I switch to the methods view in the inspector, 
> wants an #organization, which a behavior doesn't have. Otherwise it 
> seems fine. And the "Browse" option doesn't work, as the browser can't 
> find the class. If I defined #organization to return ClassOrganizer new 
> and #definition to return self printString then the basic inspector worked.
> 
> However, if I add a method, at least if I add it using
> newClass := (Behavior new
>                         superclass: Core.Association;
>                         setInstanceFormat: Core.Association format;
>                         methodDictionary: MethodDictionary new).
> newClass compile: 'printOn: aStream
>    aStream nextPutAll: ''fred'''
>    notifying: nil
>   ifFail: [3 halt].
> newClass new inspect.
> 
> then the source code for the method wasn't found and I ended up with 
> decompiled code for it. I suspect I just need to set the source pointer 
> properly (i.e. to the original string, as source pointers can be strings 
(Continue reading)

Terry Raymond | 1 Jun 2004 15:22

RE: [Q] class creation on the fly?

Denis

Here are patches we used with Objectivity to prevent
logging of dynamic classes.  They were developed under
5i.4.

Terry

===========================================================
Terry Raymond       Smalltalk Professional Debug Package
Crafted Smalltalk   *Breakpoints* and *Watchpoints* for
80 Lazywood Ln.                  VW and ENVY/Developer
Tiverton, RI  02878
(401) 624-4517      traymond <at> craftedsmalltalk.com
<http://www.craftedsmalltalk.com>
===========================================================

> -----Original Message-----
> From: Denis Johnson [mailto:denis.johnson <at> rmb.com.au]
> Sent: Tuesday, June 01, 2004 8:29 AM
> To: Alan Knight
> Cc: vwnc <at> cs.uiuc.edu
> Subject: Re: [Q] class creation on the fly?
>
>
> Sorry to barge in, but on a related question, is there indeed
> a way to
> temporarily switch off logging changes ? I have a case where I have
a
> web service client class built on the fly in a SUnit test to
(Continue reading)

Thomas Gagné | 1 Jun 2004 14:21
Picon

Re: [Q] class creation on the fly?

Alan Knight wrote:

> It doesn't like it if I switch to the methods view in the inspector, 
> wants an #organization, which a behavior doesn't have. Otherwise it 
> seems fine. And the "Browse" option doesn't work, as the browser can't 
> find the class. If I defined #organization to return ClassOrganizer 
> new and #definition to return self printString then the basic 
> inspector worked.

I got farther using Class, but Trippy couldn't discover if the class was 
supposed to be private or not because it didn't exist in its own 
environment and eventually complained.

>
> <snip>
>
> then the source code for the method wasn't found and I ended up with 
> decompiled code for it. I suspect I just need to set the source 
> pointer properly (i.e. to the original string, as source pointers can 
> be strings as well as being indexes into a source file).  I've made an 
> AR (47598) for the browsing issues. If you know of others I'll add them.

I didn't know that and had just accepted it wouldn't be able to show me 
the source since the code wouldn't (shouldn't) be written to the changes 
file.  That would be great if it worked.

--

-- 
.tom
remove email address' dashes for replies
The last calendar you'll ever need is at <http://www.coordidate.org/>
(Continue reading)


Gmane