BlueInk shouldn't add parentheses when not needed

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

BlueInk shouldn't add parentheses when not needed

Peter Uhnak
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


Reply | Threaded
Open this post in threaded view
|

Re: BlueInk shouldn't add parentheses when not needed

Nicolai Hess-3-2


2016-05-06 10:26 GMT+02:00 Peter Uhnák <[hidden email]>:
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.

would this help (added to the very start of needsParenthesisFor: , after checking that parent isn't nil) :

 parent isArray ifTrue: [ ^ false ].


 

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



Reply | Threaded
Open this post in threaded view
|

Re: BlueInk shouldn't add parentheses when not needed

Sven Van Caekenberghe-2
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
>
>


Reply | Threaded
Open this post in threaded view
|

Re: BlueInk shouldn't add parentheses when not needed

Peter Uhnak
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 ]




Reply | Threaded
Open this post in threaded view
|

Re: BlueInk shouldn't add parentheses when not needed

alistairgrant
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

Reply | Threaded
Open this post in threaded view
|

Re: BlueInk shouldn't add parentheses when not needed

Peter Uhnak


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.

Peter
Reply | Threaded
Open this post in threaded view
|

Re: BlueInk shouldn't add parentheses when not needed

alistairgrant
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