9

The MSDN page on ByRef and ByVal keywords isn't very helpful; unless I somehow skipped it, they're simply being referred to as "keywords" everywhere.

One of the main contributors of the Rubberduck project is working on a very cool Encapsulate Field refactoring, and the UI is coming along pretty nicely.. except I have a problem with the label above the dropdown for ByRef/ByVal, which says "Accessibility":

Rubberduck's "Encapsulate Field" refactoring dialog

I don't like "Accessibility" because I'm using it elsewhere for Public/Private/Friend access modifiers where it feels more accurate.

I don't want to use "Modifier" because IMO it's just a short for "access modifier".

I'd like that label to be accurate, but my vocabulary is apparently lacking and I don't know what to call these keywords.

What should this label say, to be accurate? What's the word I'm looking for? What "family of keywords" do ByRef/ByVal belong to?

Mathieu Guindon
  • 1,720
  • 16
  • 33
  • 2
    As one of the comments says, it shouldn't be there at all -- ByRef for a property is a bit insane. If even possible, it's evil -- allowing you to change the variables of callers without their knowledge. – jmoreno Dec 18 '15 at 02:07
  • A lot of documentation in the "VB Universe", (so, not specifically VBA) seems to refer to this as the "Passing Mechanism". – Damien_The_Unbeliever Dec 18 '15 at 08:14
  • @jmoreno I completely agree. I'll make it `ByVal` without a possibility to change it to `ByRef` other than manually editing the generated code, and "problem solved"! VBA can compile a tremendous amount of evil nonsense you know :-) still, I like that there's *finally* a place online that puts a name on these keywords. – Mathieu Guindon Dec 18 '15 at 15:31

5 Answers5

15

In this case, I would use "Pass As" (or "Pass").

You have a flow that perfectly matches this usage.

  • Variable name: foo
  • Pass as: ByVal / Pass: ByRef

This fits your workflow perfectly and incidentally is exactly what the article you reference indicates.

As you read through your options, it reads perfectly when using 'Pass As' as you can simply read through the heading and select the text appropriately - "'Variable name' foo, 'Pass As' value."

If you wanted to make it slightly read better you could make your list options "Value" and "Reference" depending on if your target audience is VBA programmers or non-VBA programmers who may be slightly less familiar with ByVal and ByRef keywords.

Or alternatively, change it to "Pass:" and make it "By Reference (ByRef)" and "By Value (ByVal)" in the dropdown. It looks like your dropdown has the space to show all this text. Or just the ByRef/ByVal keywords.

enderland
  • 12,091
  • 4
  • 51
  • 63
5

I would use either of these 3 terms to label a dropdown selecting that:

  1. Semantics
  2. Pass by
  3. Parameter modifier
Jimmy Hoffa
  • 16,039
  • 3
  • 69
  • 80
3

"Pass By Semantics" is probably closest to what you are looking for.

Oded
  • 53,326
  • 19
  • 166
  • 181
3

The most exact and formal term for this would be "Aliasing semantics".

When ByRef is used, the name inside the function is an alias for the caller's variable -- all changes to either one are immediately visible to the other. With ByVal, the name inside the function is a distinct copy of the caller's variable (of course, both the caller's and function's copy may refer to the same object, but they are distinct in that reassigning the parameter inside the function does not reassign the caller's variable).

The options would be

  • Alias (ByRef)
  • Copy (ByVal)

Some platforms add a third possibility, where aliasing the caller's variable is done but it is not allowed for more than one parameter to alias overlapping objects. (The idea behind C restrict keyword, one also finds this in IDL, where the attribute keyword is unique). .NET doesn't have a good way to encode this knowledge.

Ben Voigt
  • 3,227
  • 21
  • 24
-1

I'd call it an "[argument] category".

The argument has a name, a type and a category.

Lightness Races in Orbit
  • 8,755
  • 3
  • 41
  • 45