Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perltidy? #8

Open
wchristian opened this issue Nov 11, 2016 · 7 comments
Open

perltidy? #8

wchristian opened this issue Nov 11, 2016 · 7 comments

Comments

@wchristian
Copy link

The code is in kind of an ad-hoc style. Any chance of adding a .perltidyrc file to be used consistently?

@Corion
Copy link
Owner

Corion commented Nov 11, 2016

I'm not sure if Perltidy supports the new signatures that I'm using. Also, I'm not sure where my code is particularly ad-hoc :-) If Perltidy works on Windows, I'll try installing it, but I'd prefer not to spend hours trying to configure it in a way that it doesn't mess up all code.

I'm planning to look at moving OpenGL::Glew into a local copy of the OpenGL / pogl distribution this weekend, and that code certainly should follow the style of OpenGL when it is merged. I'm not sure if Perltidy can handle some files but not others.

@wchristian
Copy link
Author

Looking at app-shadertoy.pl it's not just the formatting of it, but also the kinda eclectic structuring of it that makes it hard to read for me (wild mix of pod, comments, module level code, functions, etc.). Additionally there's a mix of spaces and tabs.

In any case, i still think it'd be valuable to have. I added a basic .perltidyrc file and ran all the things through it so you can see what happens: https://github.com/wchristian/app-shadertoy/tree/tidy (careful looking at the commit in browser, it's kinda big)

It handles the signatures fine.

As for perltidy and windows: I use Komodo IDE on windows and have perltidy and komodo configured so i can hit ctrl+e and it'll tidy the open file or selected block of text. Has been working great for years. :)

@Corion
Copy link
Owner

Corion commented Nov 11, 2016

I like how Perltidy will change and fix the mixture of tabs and spaces - this is due to me switching editors recently and my new settings haven't propagated through all the code. There should be no tabs left anywhere.

Unfortunately, the rest of your settings seem pretty unacceptable to me, or require lots of fiddling with .perltidyrc which I would rather not spend time on:

my @vertices = ( -1.0, -1.0,   1.0, -1.0,    -1.0,  1.0,    
                  1.0, -1.0,   1.0,  1.0,    -1.0,  1.0
               );

gets converted to

my @vertices
    = (-1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0);

losing the "pairs" information.

my $config = {
    grab => 0,
};

gets converted to

my $config = {grab => 0,};

making it hard to add more config items later.

I'm not interested in fighting another tool just to prevent it from making understandable but stupid mistakes all the time. I know that the above is likely inconsistent with other syntactically identical situations but as there is information that is conveyed not in the syntax but in the whitespace, the forced unification through Perltidy is not worth it to me.

But there certainly are sections that benefit from the unification. I guess that running the code through Perltidy and cleaning the relevant parts by importing them into git manually is sensible, but not as an ongoing part of the process.

@wchristian
Copy link
Author

Easily fixed by adding comment markers. Give me a sec.

@wchristian
Copy link
Author

Please consider: wchristian@587c525

@wchristian
Copy link
Author

If you're familiar enough with Perltidy to know which knobs to twiddle, I'll compile a list of the things I don't like and I'll get back.

Please do, i'd happily do that, and i already know the setting needed for the signatures one. :)

But I'm already not that keen on adding special markers for "leave this untouched".

I can understand that, but consider: In the case of the vertices a comment explaining what is what and why it's like that would be appropiate, and in the case of the config, the marker can probably go away once you have more than one config pair. Some of the things are also that way because i configured a very long line length.

Generally once you're past the initial settling in bit, tidy is really smooth flying, especially if you have someone familiar on hand. :)

@Corion
Copy link
Owner

Corion commented Nov 30, 2016

I'm writing these down so that I don't forget. If there are easy fixes for them, tell me, but I'm not promising that these are all things that annoy me with the perltidy settings ;)

Things that break using Perltidy for the moment for me:

  • Doesn't work with defaults in signatures

The following makes Perl::Tidy stop parsing:

sub foo( $options={} ) {
}
  • Reindenting of number-lists

This is especially annoying as for OpenGL, there usually are flat lists of floats passed around and
the whitespace there has semantic meaning. There is the "comment at first line" workaround.

  • Inlining of single-argument method calls

    My::Class->new(
    some => 'argument',
    );

gets inlined to

My::Class->new( some => 'argument', );

which is not what I want, because likely I'll add more arguments later. I understand that this is hard to disambiguate for Perl::Tidy from other function calls that might be safely moved onto a single line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants