Skip to content

Proposal: remove shifts into variables in favour of positional parameter to local variables #188

Open
@ReDTerraN

Description

@ReDTerraN

Most of the current xpanes functions looks like this example the moment:

  local window_name="$1"
  shift
  local index_offset="$1"
  shift  
  local interval="$1"
  shift
  local repstr="$1"
  shift
  local cmd="$1"

While this works fine and from an resource optimization perspective, as multiple shifts is lightweight operations.
The readability takes a hit as all functions becomes very much larger than they need to be.

For most functions we should in theory be able to do following:

 local window_name="$1"
 local index_offset="$2"
 local interval="$3"
 local repstr="$4"
 local cmd="$5"

and in cases we need to fully reset the positional parameters we can do this instead:

  local window_name="$1"
  local index_offset="$2"
  local interval="$3"
  local repstr="$4"
  local cmd="$5"
  shift 5

@greymd is there any reason to why we utilize multiple shifting? Do you want me to proceed creating a patch to move the functions to the proposed syntax?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions