Puting a Class Variable in a package

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

Puting a Class Variable in a package

Fernando Rodríguez
Hi,

I have a few String methods (stolen form squeak) that rely on a class variable
called HtmlEntities. I'm having to recreate this class variable by hand,
as you can't (afaik) add a class variable to a package (baaad smalltalk!).

OK, so what else can I do to automate this? O:-)  Can you programaticly add
a class variable?


Reply | Threaded
Open this post in threaded view
|

Re: Puting a Class Variable in a package

Ian Bartholomew-21
Fernando,

> OK, so what else can I do to automate this? O:-)  Can you programaticly
> add a class variable?

You can add a class variable in code, a package's preinstall script
would be a good place.

String addClassVarName: 'HtmlEntities'

However, take note of the comment for the #addClassVarName: method.
It's a bit more verbose but you should probably use

(ClassBuilder forModifying: String)
   classVariableString: String classVariableString , ' HtmlEntities';
   modifyOrCreate

--
Ian

Use the Reply-To address to contact me (limited validity).
Mail sent to the From address is ignored.


Reply | Threaded
Open this post in threaded view
|

Re: Puting a Class Variable in a package

Chris Uppal-3
In reply to this post by Fernando Rodríguez
Fernando,

> Can you programaticly add a class variable?

There are several ways.  I'd use:

    String addClassVarName: 'HtmlEntities'.

But then, I doubt if I'd want to replicate the mess of String>>asXxxx methods
from Squeak.

    -- chris