Hi,
I thought that I already asked about this but apparently not... Right now when I have an array like observations := { MElement -> { #change -> #(name owner uuid). #add -> #(). #remove -> #() }. MContainer -> { #change -> #(). #add -> #(add:). #remove -> #(remove:). }. }. it gets formatted into observations := {(MElement -> {(#change -> #(#name #owner #uuid)). (#add -> #()). (#remove -> #())}). (MContainer -> {(#change -> #()). (#add -> #(#add:)). (#remove -> #(#remove:))})}. Which is really ugly with all the _uneeded_ parenthesis. I tried to look into BlConfigurableFormatter>>needsParenthesisFor: where it is being added, but any change I try to make I end up breaking some test as the behavior is not very obvious for me. Can this be changed/fixed easily? And second, perhaps less important... do we really need to reformat #(name owner uuid) into #(#name #owner #uuid)? Seems a bit superfluous too. Thanks, Peter |
2016-05-06 10:26 GMT+02:00 Peter Uhnák <[hidden email]>:
would this help (added to the very start of needsParenthesisFor: , after checking that parent isn't nil) : parent isArray ifTrue: [ ^ false ].
|
In reply to this post by Peter Uhnak
I have seen this too, and I hate it as well.
I would definitively prefer the minimal syntax: no parenthesis when not needed, not extra $# when not needed. > On 06 May 2016, at 10:26, Peter Uhnák <[hidden email]> wrote: > > Hi, > > I thought that I already asked about this but apparently not... > > Right now when I have an array like > > observations := { > MElement -> { > #change -> #(name owner uuid). > #add -> #(). > #remove -> #() > }. > > MContainer -> { > #change -> #(). > #add -> #(add:). > #remove -> #(remove:). > }. > }. > > it gets formatted into > > observations := {(MElement > -> > {(#change -> #(#name #owner #uuid)). > (#add -> #()). > (#remove -> #())}). > (MContainer > -> > {(#change -> #()). > (#add -> #(#add:)). > (#remove -> #(#remove:))})}. > > Which is really ugly with all the _uneeded_ parenthesis. > > I tried to look into BlConfigurableFormatter>>needsParenthesisFor: where it is being added, but any change I try to make I end up breaking some test as the behavior is not very obvious for me. > > Can this be changed/fixed easily? > > > And second, perhaps less important... do we really need to reformat #(name owner uuid) into #(#name #owner #uuid)? Seems a bit superfluous too. > > Thanks, > Peter > > |
parent isArray ifTrue: [ ^ false ]. Wow this actually seems to work, thanks! We could integrate it for Pharo 6. As for the Literal Array, this appears to solve it BlConfigurableFormatter>>visitLiteralNode: aLiteralNode aLiteralNode value isLiteral ifFalse: [ ^ self writeString: '''<an unprintable nonliteral value>''' ]. aLiteralNode parent isLiteralArray ifTrue: [ self writeString: (aLiteralNode sourceText withoutPrefix: '#') ] ifFalse: [ self writeString: aLiteralNode sourceText ] |
In reply to this post by Sven Van Caekenberghe-2
On 6 May 2016 at 10:56, Sven Van Caekenberghe <[hidden email]> wrote:
> I have seen this too, and I hate it as well. > > I would definitively prefer the minimal syntax: no parenthesis when not needed, not extra $# when not needed. > >> On 06 May 2016, at 10:26, Peter Uhnák <[hidden email]> wrote: >> And second, perhaps less important... do we really need to reformat #(name owner uuid) into #(#name #owner #uuid)? Seems a bit superfluous too. I'll put in a vote the other way. As a new-to-Pharo user it is much faster for me to understand what is happening with the #'s present. Cheers, Alistair |
On Fri, May 6, 2016 at 7:25 PM, Alistair Grant <[hidden email]> wrote: On 6 May 2016 at 10:56, Sven Van Caekenberghe <[hidden email]> wrote: Well most options of the formatter are configurable (thus the name ConfigurableFormatter), so we can do the same for these things. Peter |
On Sun, May 08, 2016 at 01:08:52PM +0200, Peter Uhnák wrote:
> On Fri, May 6, 2016 at 7:25 PM, Alistair Grant <[hidden email]> wrote: > > On 6 May 2016 at 10:56, Sven Van Caekenberghe <[hidden email]> wrote: > > I have seen this too, and I hate it as well. > > > > I would definitively prefer the minimal syntax: no parenthesis when not > needed, not extra $# when not needed. > > > >> On 06 May 2016, at 10:26, Peter Uhnák <[hidden email]> wrote: > >> And second, perhaps less important... do we really need to reformat # > (name owner uuid) into #(#name #owner #uuid)? Seems a bit superfluous too. > > I'll put in a vote the other way. As a new-to-Pharo user it is much > faster for me to understand what is happening with the #'s present. > > > Well most options of the formatter are configurable (thus the name > ConfigurableFormatter), so we can do the same for these things. I'm fine with it being configurable. :-) Thanks, Alistair |
Free forum by Nabble | Edit this page |