Coder Social home page Coder Social logo

Comments (4)

alichtman avatar alichtman commented on June 19, 2024 1

TL;DR: Your change is alright by me but doesn't completely solve the issue. We have to refactor the massive one-liners to really improve readability.

I agree that we have a readability problem to solve here. Personally, I like ts/sw=4, but I see the argument for using ts=2 here.

That said, I think the real fix is breaking up some of the massive one-liners. For example, the first link you included has 0 leading spaces but is still unruly to read and work with.

from zinit.

pschmitt avatar pschmitt commented on June 19, 2024 1

Some lines we cannot split easily without refactoring it all and possibly (probably) hurting performance. zsh expansion is powerful, but afaik there's no readable way to split these lines other than storing temporary results in a variable and doing the rest of the work in a second statement.

The best way forward here is to add a bunch of comments explaining the weirdest exps IMO. And unspaghetti what we encounter along the way. For instance I "fixed" the first example in #116:

builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
builtin print -P "${ZINIT[col-error]}ERROR:%f%b Couldn't find ${ZINIT[col-obj]}zinit-side.zsh%f%b."
return 1
}

Doing it all in one go would be a huge undertaking.

Another thing: to make things better I'm all for adopting a "return early" approach (I don't know the real tech term) ie:

Instead of:

fun() {
	  if check_is_okay {
	    long_block_of_code
	    return 0
	  } elif check_not_okay {
	    another_block_of_code
	    return 1
	  }
}

that:

fun() {
	  if check_not_okay {
	    another_block_of_code
	    return 1
	  }
	  # check is okay here
	  block_of_code
	  return 0
}

It's a poor example, but I'm sure you get my point.

Edit: It's a guard clause.

from zinit.

alichtman avatar alichtman commented on June 19, 2024 1

Doing it all in one go

Yep, minor fixes over a long period of time is alright. Any improvements > no improvements :)

from zinit.

vladdoster avatar vladdoster commented on June 19, 2024

Closing in favor of #238.

from zinit.

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.