2

As far as I know, := seems to do an assignation by copy. The operator => seems to do a similar assignation, but is used when assigning a parameter to a member variable of an object.

so...

receivesTheCopy := isBeingCopied

memberVariable => passedParameter

I'm working on someone else's old code and I have a variable reaching a value that I never see explicitly assigned to it with :=. I was thinking that maybe when it is assigned to a memberVariable with => it was passed by reference, and thus the passedParameter variable stayed tied to the memberVariable state.

moodymudskipper
  • 46,417
  • 11
  • 121
  • 167
VincentDM
  • 469
  • 6
  • 17

1 Answers1

9

:= is an assignment.

=> has multiple purposes:

  1. Parameter passing: Which formal parameter is passed which argument (if it isn't done by order).
  2. Record and array aggregates: Which field gets which value.
  3. Aspects: Separating aspect names from the expressions they are assigned.

In neither case it has anything to do with pass-by-reference or pass-by-value.

Jacob Sparre Andersen
  • 6,733
  • 17
  • 22
  • Hi @JacobSparreAndersen, When you mention: "Parameter passing: Which formal parameter is passed which argument" wouldn't that be either pass-by-reference or pass-by-value? – VincentDM Jul 13 '17 at 14:30
  • 5
    When passing parameters, `=>` does nothing more than _associate_ a formal parameter name with an argument. The "pass by" semantics are governed by the parameter mode and the type of the parameter. – Marc C Jul 13 '17 at 15:21
  • 5
    Ada parameter passing modes are IN, OUT, IN OUT. None of these modes specifies passing by reference or passing by value. – Jim Rogers Jul 13 '17 at 21:02