Talk:Methods

From m204wiki
Revision as of 03:05, 29 August 2016 by NMichell (talk | contribs) (InterNames)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

I landed on this page to discover more about the InternalNames block so I’m hesitant to perform an Edit in case I’ve misunderstood it.

It seems to me that the example given in this article is confusing: -

  subroutine add(%petrol is float nameRequired optional, -
    %oil is float nameRequired optional)
    internalNames
    %parm.petrol is %petrol
    %parm.oil is %oil
  end internalNames
  ...
  %petrol = %petrol + %parm.petrol
  %oil = %oil + %parm.oil


Surely something like...

%parm.petrol = %valueToBeReturnedToCaller

...would make more sense.


The explanation that follows the example compounds the problem: -

This example illustrates how if petrol and oil were private class variables, the InternalNames block makes it possible to have parameters in a method declaration with the same name, but to avoid naming conflict or confusion between the private class variables and the parameter names.

As I write this, I wonder if the situation envisaged is where the private class has a %petrol variable and the parameter name-mapping is to allow that to be distinct from the %petrol parameter. Hhmmm - that code needs a rewrite.

Happy to be corrected if I’ve missed a trick.

NMichell

e: nickmichell@gmail.com