[squeak-dev] Association >> #printString and friends
Nicolas Cellier
nicolas.cellier.aka.nice at gmail.com
Wed May 1 21:09:38 UTC 2013
+1 add those spaces
2013/5/1 Frank Shearar <frank.shearar at gmail.com>
> I decided to finally play around with Traits. I decided I was going to
> reinvent the field of integers by making a TGroup trait and composing
> two of those with some aliasing, just like how we get a(n algebraic)
> field from overlaying two groups together. I defined my field thusly:
>
> Object subclass: #MyInteger
> uses: TGroup @ {#inverse -> #negated. #* -> #+} + TGroup @
> {#inverse -> #reciprocal}
> instanceVariableNames: 'value'
> classVariableNames: ''
> poolDictionaries: ''
> category: 'Algebra'.
>
> But there's a problem. When I accept the above, the class definition
> prints out, and those Associations print themselves without
> whitespace. That means that '#* -> #+' becomes '#*->#+', which is the
> Symbol #*-> followed by garbage. Using #'*' doesn't work, because #'*'
> printString == '#*'.
>
> The easy solution is to change Association's #printOn: to put
> whitespace around the -> (and ditto for #storeOn:). But before I
> "just" do that, I'd like to hear comments on the idea.
>
> It would mean that "1->2" would print as "1 -> 2" (and storeString as
> "(1 -> 2)").
>
> I have a small test suite for the change, including this seemingly
> innocuous snippet, which fails with a SyntaxError when it runs:
>
> self assert: #+ -> #bar equals: (Compiler evaluate: (#+ -> #bar)
> storeString).
>
> frank
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20130501/f80cc50a/attachment.htm
More information about the Squeak-dev
mailing list
|