# [swift-evolution] thoughts on 'inout'

Oliver M selectedfordeletion at yahoo.com
Fri Feb 12 15:19:32 CST 2016

```@Brent Royal-GordonThe code below is with different spacing for = and : so it should look more distinguishable and familiar.I'm not sure what you mean by heavier and lighter.I've never looked at the statement var a = 7and wished I could use a lighter : instead of the =(did I understand you correctly on this point?)inout parameters are not rare in my code. I'd say they are about as common as only in parameters,and even then, the vast majority of my functions have them.

//main body code:
expandFibonacciSequence(inArray: fibonacciArray, by = 100)
combine(transform = localTransform, withTransform = parentTransform, toOutput: globalTransform)
addNoise(toColours: colourArray, withMaxRandomFactor = 0.05, outputColours: noisyColourArray)

//the corresponding function declarations:
expandFibonacciSequence(inArray numberArray: [Ints], by maxAdditions = Int) { var inCount = numberArray.count  for addIndex in 0…(maxAdditions - 1) { numberArray[inCount + addIndex] = numberArray[inCount + addIndex - 1] + numberArray[inCount + addIndex - 2] }}

addNoise(toColours originalColours: [Double], withMaxRandomFactor maxFactor = 0.05, outputColours newColours: [Double]) { //the originalColours array is passed by reference (associated variable) to keep memory usage low.
let numOfColours = originalColours.count for index in 0…numOfColours { let randomNumber = drand48() * maxFactor - maxFactor/2 newColours[index] = originalColours[index] + randomNumber }}

combine(transform localMatrix = [double], withTransform parentMatrix = [double], toOutput outputMatrix: [double]) {  outputMatrix[0] = localMatrix[0] * parentMatrix[0] + localMatrix[1] * parentMatrix[4] + localMatrix[2] * parentMatrix[8] + localMatrix[3] * parentMatrix[12]  outputMatrix[1] = localMatrix[0] * parentMatrix[1] + localMatrix[1] * parentMatrix[5] + localMatrix[2] * parentMatrix[9] + localMatrix[3] * parentMatrix[13]  //outputMatrix[2] ... //outputMatrix[3] … //outputMatrix[4] ... //and so on }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160212/a6f2d40b/attachment.html>
```