Commenting variable names

Roel Wuyts rwuyts at vub.ac.be
Tue May 16 08:27:10 UTC 2000


Well, we thought about this too a little while ago (but didn't do anything
with it, sorry). The nice thing is that you currently can accept the
following:

  Parent subclass #Child
      instanceVariableNames: 'foo "comment for foo" bar "bar comment"  ugh'
      classVariableNames: 'ick "more comment here" ack'
      poolDictionaries: ''
      Category: 'cat'


This accepts fine (probably some unintended side-effect of the
implementation of the string message used to split the instance variables :)
:) ), but the information is just lost because it is stored nowhere... I
like to put the comments there (I would change the template a bit to take
larger instance variable comments into account). As I said, I did not have
time to actually get down and make sure the comment is stored and displayed
again.

> In Smalltalk, I can attach comments to
>  - classes (using the [?] button in the browser)
>  - methods (using "..." in the code)
> but I can't attach comments to instance variables or class variables.
> Of course it's possible to put the variable comments in the class comment,
> but that prevents the development of a tool that would let me select a
> variable name in a method and ask for its comment.
>
> It seems to me that the smallest change to Smalltalk that would address
> that issue would be to tweak the interface of
>
>  Parent subclass #Child
>      instanceVariableNames: 'foo bar ugh'
>      classVariableNames: 'ick ack'
>      poolDictionaries: ''
>      Category: 'cat'
>
> to allow instanceVariableNames and classVariableNames to be
> arrays containing symbols (for variable names) and strings (for comments)
> like
>
>  Parent subclass #Child
>      instanceVariableNames: #(
>   foo 'A free observable otter'
>   bar 'One o'' them grizzly critters'
>   ugh 'Usual Gross Hack'
>      )
>      classVariableNames: #(
>   ick 'Don''t use this, it's going away'
>   ack 'Log stream, lazy initialisation used'
>      )
>      poolDictionaries: ''
>      Category: 'cat'
>
> The arguments could be symbol/string arrays or simple strings like they
> are now, so existing fileins would still work.
>
> Since variable names in a class have to be distinct, a common
>  aClass commentFor: aVariableName => aString or nil
> would serve for extracting the information.
>
> However, implementing this looks as though it would require a change
> to the representation of Class (the comments have to be stored somewhere),
> so I'm not game to try it.  In any case, I'm up to my ears in other work.
>
> Perhaps someone with a bit more time and a lot more Squeak experience
> would like to implement this or something better.  It'd certainly be nice
> to have.
>
> Or perhaps there are some Smalltalk conventions I don't understand yet
> which explain why such a facility wouldn't really add much.
>


--
Roel Wuyts                    Programming Technology Lab
rwuyts at vub.ac.be              Vrije Universiteit Brussel
http://prog.vub.ac.be/~rwuyts
Webmaster of European Smalltalk User Group: www.esug.org





More information about the Squeak-dev mailing list