The Calling Of Things

14 October, 2026
All pages

Okay, so we have a real programming language trying to also be a scripting language. I can make this work. The main thing is to be able to easily call external programs, and last post I came up with a way to do that: command parameters. There is something else we might want to be able to call like that: subprograms!

Not a lot of people know this, but BASIC developed two "standard" versions before home computers made it popular. The first, Dartmouth BASIC, being a compiled language, had a way of calling functions in other modules using CALL subprogram(parameters). But when Microsoft created it as an interpreter for microcomputers, it didn't need that functionality. For various historical reasons, most versions of BASIC are copied from Microsoft so they didn't get it either. But a few did derive theirs from Dartmouth instead of Microsoft. Texas Instruments is one, as they had BASIC on their minicomputers way before they put it on a microcomputer. So they did have CALL subprogram(parameters). (This is also why they had SEG$() instead of LEFT$() et al.)

But I'm getting distracted. Whilst I like the CALL subprogram(parameters) syntax, it is a little heavy. Turns out that it was Microsoft, of all people, who later came up with another way: subprogram parameters. But you know what? This looks a lot like calling an external program! So why not make them one and the same? This kinda plays nicely into the statement vs. function paradigm. After all, external programs don't "return a value" - they might create output, but returning a value is a different concept. And subprograms don't return a value, either. They're essentially executed "for their side-effects".

There are nuances to this, though. For instance, how do you determine what to do if you have an external program with the same name as one of your subprograms? Priority in namespaces is actually a big thing to navigate, but we can probably make a start here. It probably makes sense for a subprogram to have priority over an external program of the same name. Though that then brings up how to call the external program anyway. Actually, that also brings up whether we want to always support calling an external program. To be honest, no, I don't want that. I would want a way to mark the program as "in script mode" where this is supported like this. But if in a program that is not in script mode, there would still be a need to call external programs.

Not sure what order to tackle these, but some have easier answers than others. Having an internal call to load an external program No Matter What seems to be a very BASIC-like solution, in any case. So how about RUN "program name", "parameters". I'm not sure there is any particular command to do this that gained popularity. Early, Microsoft tended to use SYSTEM to make OS calls, though that was not always what it did, either. On some platforms that exited the BASIC interpreter. On others, it opened a machine langauge monitor. I've also seen EXEC but I feel like RUN is just nicer. And that is kind of a default in multiple other BASICs to load and run another BASIC program, so that's a behavioural extension that makes sense. And it means the name and parameters of an external program can be created programmatically, as they're string expressions.

Turns out there could be another way, in certain circumstances. Scripting environments usually also allow you to specify an external program with a pathname. So you can do ./path/to/program in a script to execute that program. We can easily support that if the program is in scripting mode - it's just a small amount of additional parsing. Although it does mean we can't support / as a valid character in a subprogram name - but I can't see why we want to even do that. Subprogram names are identifiers, just like variables, and are essentially what are called "unquoted literals", so they will have a limited range of permitted characters anyway. And / is very unlikely to be one of them! In fact, I can say now that because the forward slash will be part of at least one valid operator in expressions, it can't be part of an identifier of any sort.

So the presence of a / in the statement name would mean it's going to be an external program. That's straightforward.

There's another thing to address: how do we convert strings into parameter lists?

One thing characteristic of most operating systems is that a program being invoked will get a list of parameters. Not a string they have to parse themselves, but a list. When calling something with RUN "program name", "parameters" we can definitely instead do RUN "program name", "parameter", "parameter" and so on. That means a programmer calling that can unambiguously provide each parameter. Using the scripting notation, that would be program parameter, parameter, .... And that looks a great deal like calling a subprogram without the CALL! Wonderful!

But do we need the commas? Well, that takes us to strings and string parsing and string expressions.