Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why VBScript built-in function do have optional parameters or method oveloads, and I can't?

I do know VBScript does not have method overloads or optional parameters, but some built in methods like InStr (and may others) can be called in different ways (e.g. InStr([start,] string1, string2 [, compare])).

Are they optional parameters or method overloads?

How are they possible?

What is the reason because the language can do this, but the developer not?

like image 697
Albireo Avatar asked Oct 24 '25 03:10

Albireo


1 Answers

The InStr function has been a part of just about every incarnation of BASIC I can think of, including VBScript. I believe, it would have caused more trouble to remove it than to leave it there. Apart from this legacy, VBScript is aim at scripters, i.e. people who need to rapidly/simply perform a task. VBScript presents itself as a simply means to do so. I don't believe many would notice the absence of optional / default parameters.

One cool thing about VBScript is its integration to COM through CreateObject(). This means that any shortfall of VBScript can be overcome via creating code in a different language.

This, I believe, turns VBScript into a powerful tool for both VBScript scripters and developers. Scripters now have a limitless supply of objects that they can leverage from within their scripts, and developers now have a great unit testing platform for their COM objects.

like image 57
Stephen Quan Avatar answered Oct 26 '25 20:10

Stephen Quan