**Description:**
Varargs (variable number of arguments) in functions and procedures, similar to Java's varargs feature, would allow users to pass a variable number of arguments to a function or procedure. This feature would enhance the flexibility of custom functions and procedures within PlantUML.
**Possible Syntax:**
```plantuml
!function $myFunction($arg1, $...args)
' Function implementation
!endfunction
```
**Rationale:**
Implementing varargs in PlantUML would significantly improve the preprocessor's versatility, enabling more dynamic and adaptable diagram generation. It would allow users to create more generalized functions and procedures that can handle varying input sizes, making the diagram creation process more efficient and user-friendly. This feature would be particularly useful for creating complex diagrams with variable components or for writing functions that need to handle a flexible number of inputs.
The addition of varargs would streamline the creation of procedures like $table, which currently require the use of %splitstring for handling multiple attributes. For instance, a table procedure that takes the first attribute as the entity name and the subsequent attributes as table fields can be cumbersome with %splitstring. Varargs would simplify this by allowing a direct and more intuitive way of passing a variable number of parameters, enhancing ease of use and readability.
Example: With varargs, a $table procedure could directly accept multiple field parameters without needing to split a single string, making the code cleaner and more maintainable.
```plantuml
@startuml
!define pk(x) <b><color:#b8861b><&key></color> x</b>
!define fk(x) <color:#aaaaaa><&key></color> x
!define column(x) <color:#efefef><&media-record></color> x
!procedure table($name, $fields="attribut1, attribut2, attribut3")
!$list = %splitstr($fields, ",")
entity $name {
*pk(id)
--
!foreach $field in $list
$field
!endfor
}
!endprocedure@enduml
```