Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!news.duke.edu!news-feed-1.peachnet.edu!gatech!psuvax1!uwm.edu!msunews!harbinger.cc.monash.edu.au!news.cs.su.oz.au!tmx!news.tmx.com.au!news
From: Nick Ivanov <nick@oose.com.au>
Subject: Re: Intercepting message sends to statics (PP VW2.0)
Message-ID: <D4qLDM.DD8@online.tmx.com.au>
Nntp-Posting-Host: 203.5.19.181
Sender: news@online.tmx.com.au (System Administrator)
Organization: The Message eXchange Pty Ltd
Date: Wed, 1 Mar 1995 00:58:33 GMT
References:  <3ithjg$9ja@grant.cstar.andersen.com>
Lines: 48

ericlunt@eagle.andersen.com (Eric Lunt) wrote:
>
> I've tried to approach this problem from a number of angles, but
> I still haven't found a satisfactory solution.  Basically, I want
> to trap message sends to classes that don't exist in the image and
> perform some action (such as loading the class).  For instance,
> 
> example
> 
> 	^BogusClass new
> 
> If the class BogusClass does not exist in the image, I want to take
> some action.
> 
> The first solution is to always use Smalltalk #at: for class refs
> and possibly override the #at: implementation on SystemDictionary,
> but it's ugly to code.
> 
> The second solution is to always go through a "package" class for
> any direct messaging.  This is valid, but not the solution I'm
> looking for here.
> 
> I tried mucking around in #pushStatic: on Context and it worked
> great - if I was compiling or in simulation mode, that is.
> 
> You could always override #doesNotUnderstand: on UndefinedObject and
> travel up thisContext, but that's more downstream than I wanted to be.
> 
> So... any suggestions?
> 
> /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
> Eric Lunt
> ericlunt@eagle.andersen.com
> "These statements are mine!"


Hi Eric,

How about using

Smalltalk
    at: #<className> 
    ifAbsent: ["load class here and return it or do whatever"]

Hope this helps
Nick Ivanov


