I would like to add a new input to an existing method, but do not change all previous calls to the method. Does Specman support optional parameters to a method? Like in C++:
void cpp_func(int bla, int foo = 0) {
//do something ...
};
and then you can call it both cpp_func(10)
and cpp_func(10, 0)
.
Really appreciate any help.
Yes, Specman supports default value expressions in method parameters.
For example, the following code:
extend sys {
goo() : uint is { return 111; };
boo() : uint is { return 222; };
foo(x: uint, y: uint = 100, z: uint = boo() + goo()) is {
print x;
print y;
print z;
};
run() is only {
foo(11);
foo(11,22);
foo(11,22,33);
};
};
Will result in:
x = 11
y = 100
z = 333
x = 11
y = 22
z = 333
x = 11
y = 22
z = 33