[Seaside-dev] Re: Seaside2.8a1-mb.487

Philippe Marschall philippe.marschall at gmail.com
Tue Oct 2 18:00:07 UTC 2007


2007/10/2, Bany, Michel <mbany at cincom.com>:
> > ... we have been told again and again that we can not use
> > #asString as a reliable string conversion method on VW.
>
> The rule is not exactly that. Maybe it is a good time to
> reformulate it (was it ever formulated?). How about this:
>
> 1. When a string representation of an object is needed
> for the UI, send #displayString to this object,
> 2. When it is needed to convert an object to a string
> during some computation, send #asString to the object,
> 3. All objects understand #displayString,
> (all objects are displayable)
> 4. Not all objects understand #asString
> (not all object are convertable).
>
> There is still an unresolved issue with this rule. In VW,
> #displayString does not necessarily answer a String :(
> as the name would suggest; sometimes we get a Text, sometimes
> a Symbol. Therefore, yes, if you erroneously or accidentally
> use #displayString as a conversion method, things may not
> work as intended.
>
>
> > Because it is extremely inconsitent. We use #displayString
> > everywhere but there as a conversion method.
>
> I see no extreme inconsistency sending two different messages
> for two different purposes.
>
>
> So where should we go? I can see three different approaches.
>
> 1. Be courageous and review the ca. 90 senders of #displayString
> in Seaside. See what the intention is. When clearly dealing with
> a conversion replace with #asString as I did for the #asFilename:
> method. This will apply to converting WAUrl objects to a String.
> When dealing with a UI output leave it unchanged. When in doubt
> leave it unchanged or ask for someone else's advice. This process
> will not break anything in Squeak since #asString and #displayString
> produces the same answer in all cases, and since the right messages
> will be used for the right intentions, this will improve the
> quality of  Seaside. Oh, and I volunteer for doing this huge
> change.
>
> 2. Forget about the issue and rewrite #testAsFileName
>
>         self assert: (library asFilename: #index) = #index
> displayString.

Not an option. It should really return 'index'.

> 3. Forget even more and move #testAsFileName to WAPlatformSpecificTest

Not an option. The semantis of #asFilename: are defined by the test.

I think we need to make a distinction between the short term (2.8) and
the long term (2.9). For 2.8 we don't have much choice but doing 1
unless we want to delay it for several months.

As a long term solution I don't think it makes much sense to force
this artificial complexity to the user. Hence I propose a selector
that combines the advantates of #asString and #displayString.

#toString
- returns a String always, no Symbol, no Text
- understood by all objects
- no conflicts with existing methods

Yes, this is like Rails implementing unicode because Ruby doesn't.

Cheers
Philippe


More information about the seaside-dev mailing list