You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by David Rees <d....@usa.net> on 2001/04/01 22:47:05 UTC

Re: [VOTE] the simple stuff

On 28 Mar 2001 10:03:06 +0200, Stefan Bodewig wrote:

>David Rees <d....@usa.net> wrote:
>
>>>Stefan Bodewig wrote:
>>>
>>>> Glenn McAllister <gl...@somanetworks.com> wrote:
>>>>
>>>> ${myclasspath} should invoke .toString() on the thingy named
>>>> myclasspath, be it a <path> or a <property>.
>>>>
>>>> Stefan
>>>
>>>And that's probably the clearest explaination I've head yet. :-)
>>
>> Should it really be toString()?
>
>Yes.
>
>> Perhaps a toAntAttributeString() that falls back to toString()?
>
>Do you mean whoever expands the ${} should look whether the referenced
>object has a toAntAttributeString() method and invoke this - and fall
>back to toString if it doesn't? Why?
>


Because the use of toString() is overloaded already. Its used for
debugging, its used for displaying, it is used by other application,
and it used for the Ant string. If I want to use it differently for
debugging, some other application and/or Ant then I am out of luck.

This is actually a well known "problem" in the Smalltalk world. The
method printString (same as toString) has been on the list of "bad"
design decisions for at least ten years. About 6? years ago they
introduced printDisplayString so at least you could distinguish
between the string the system uses and the string user sees. However
its not as big a problem in Smalltalk because you can add a method at
Object. The typical solution would be to add Object.toAntString() and
have it return the results of toString(). Then you can easily override
for the places you need to. You clearly can't do this in Java so you
need to add complexity in the caller.

dave