This project is read-only.

(Concept) Copycat params.

Topics: VB Language Design
Sep 13, 2014 at 3:52 PM

Option 1

The parameters following the first with a type, have the same type.
MyMethod ( x As Integer, y , z ) As Integer
Which will map to be the equivalent
MyMethod ( x As Integer, y As Integer, z As Integer ) As Integer
     ParamName ::= 
      TypeName ::=
       CopyCat ::= ',' ParamName
      CopyCats ::= CopyCat+
        ByType ::= "ByRef" | "ByVal"
        AsType ::= "As " TypeName 
 ParamWithType ::= ByType? ParamName AsType
         Param ::= ParamWithType CopyCats?
        Params ::= '(' Param ( ',' Param )* ')'
    FuncParams ::= Params AsType

Option 2

Grouping parameter names before the type.
MyMethod ( {x,y} As Integer ) As Integer
Which will map to be the equivalent
MyMethod ( x As Integer, y As Integer ) As Integer
CopyCatParam ::= ByType? '{' ParamName (',' ParamName )*  '}' AsType
       Param ::= ByType? ParamName AsType
   ParamKind ::= CopyCatParam | Param
      Params ::= '(' ParamKind ( ',' ParamKind )* ')'
  FuncParmas ::= Params AsType
Sep 16, 2014 at 12:11 AM
Edited Sep 16, 2014 at 12:18 AM
I don't like #1, but #2 could be helpful. One advantage of #2 over another possible alternative: MyMethod (x, y as Integer) is that the role of ByRef would be clearer. Personally, if I were designing a language, the syntax would be something like Sub Foo(X,Y: Int32; ref W,Z: Double), using semicolon to distinguish distinct declaratory clauses, but VB doesn't use semicolons for such things. Given that VB uses commas to separate separate declaration clauses, using some other character to group arguments, at least when using ByRef, would be helpful. Alternatively, since it's less common to have many ByRef parameters than many ByVal parameters, the language could simply require that each ByRef have its type declared individually.