Giter VIP home page Giter VIP logo

Comments (8)

JalonSolov avatar JalonSolov commented on August 21, 2024 3

My question is: Why?

Long lines were a problem on printouts, but hopefully (almost?) all of us have moved beyond that stage.

I know people are sometimes annoyed by actually having to scroll horizontally, but others are just as annoyed by having to scroll vertically.

The simplest "fix" for this issue is to create a struct for the parameters, and pass the struct instead of all the separate parameters.

struct LongerFunctionNameParams {
    x u32
    y u32
    z u32
    first_parameter package_name.LongerTypeName
    second_parameter package_name.LongerTypeName
    third_parameter package_name.LongerTypeName
    fourth_parameter package_name.LongerTypeName
    fifth_parameter package_name.LongerTypeName
    sixth_parameter package_name.LongerTypeName
}

pub fn longer_function_name(params LongerFunctionNameParams) {
	first_variable := params.first_parameter.whatever
}

from v.

medvednikov avatar medvednikov commented on August 21, 2024 3

Yes, horizontal scrolling is never good.

This has indeed been approved by me.

from v.

TheOnlySilverClaw avatar TheOnlySilverClaw commented on August 21, 2024

Thinking about it, I personally actually don't care much whether V enforces an arbitrary width limit.
Others might expect that, though.

From my perspective, the opposite question would be warranted:
Why remove manually placed line breaks and mess up formatting without a good reason?

from v.

JalonSolov avatar JalonSolov commented on August 21, 2024

v fmt is an opinionated formatter. Same as go fmt before it.

That's why there are no options - you get what you get... and so does everyone else.

This makes it trivial to look at someone else's code and not have your first thought be "Gah! I have to format this before I can make sense of it!"

I could tell you horror stories...

from v.

TheOnlySilverClaw avatar TheOnlySilverClaw commented on August 21, 2024

Those are a bunch of non-arguments going in circles.

This looks like horror to me:
Screenshot from 2024-06-04 19-07-18

So I'd have to actively decide to extract it to a struct as a workaround, which renders the whole point of automatic consistency moot.

I can't remember the last time formatting issues actually kept me from understanding others' code.
But unreasonable default formatting makes me not want to use the language enforcing those on my own code.

An in this case, the formatter isn't just not helping, it's actively disrupting readability for no gain I can think of.

from v.

JalonSolov avatar JalonSolov commented on August 21, 2024

When Go's formatter was released, it was simultaneously the most loved AND most hated feature.

It doesn't give you any options - it always formats things the same way.

What "looks good" to one person may be a complete "horror" to another. The only way to make things fair is to always format the same way, regardless of individual preferences.

That said, if you can make a good case for why a particular thing should be formatted differently (and "because I like it better that way" is not good enough), then perhaps you can convince Alex that it's a change that should be made.

Otherwise, love it or hate it, the formatter will continue to act as it does.

from v.

BreathXV avatar BreathXV commented on August 21, 2024

I do think having long functions should break to be honest, it is a pain when you have to scroll loads horizontally but I do understand it is preference too.

from v.

TheOnlySilverClaw avatar TheOnlySilverClaw commented on August 21, 2024

That said, if you can make a good case for why a particular thing should be formatted differently (and "because I like it better that way" is not good enough), then perhaps you can convince Alex that it's a change that should be made.

Otherwise, love it or hate it, the formatter will continue to act as it does.

As I mentioned in both recently opened issues, that's exactly what I did before opening them:

image

from v.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.