LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

MPSEND "" gives error

Root / SmileBASIC Bug Reports / [.]

SquareFingersCreated:
When multiplayer communications are on, MPSEND with an empty string generates the error "Illegal function call". Besides the fact that this really shouldn't generate an error, it generates the wrong error. MPSEND is not a function.

Isn't it? I'm pretty sure it is a function.

Can't you check what it is by looking at what colour it's highlighted?

SB doesn't use the mathematical definition of "function" (Most programming languages don't, but it's less noticeable since they always use (), while SB doesn't)

It's not a function in SB's eyes, he means. SB could at least TRY to be consistent and call it "Illegal call" or something. But yeah, functions in programming languages don't have the same rules as mathematical functions either.

What makes some things "functions" and others "subroutines"? There's really no difference, since all DEFs can be called using NAME (inputs) OUT (outputs). For example, MPSEND "" OUT

There's no difference that you acknowledge, if you choose not to acknowledge the difference that functions can have their actual parameters surrounded by parentheses, sure. EDIT: To be more precise, their actual parameter list.

Functions can have their actual parameter list surrounded by parentheses.
I guess that's true.

It's true that you can call every builtin (but not keyword) as an OUT without receiver variables. As with functions, you can call them as OUT with only one receiver variable. Just as well, you can use RETURN in non-function DEFs, and you can pass SOME values to the statement and get away with it (I forget if this is just a parsing ambiguity or not.) So he may have a point, that every statement in SB is just some kind of function; there are just some that don't return anything. Just as well, the command syntax and the function/expression syntax are likely just sugar which could boil down to OUT and some intermediates, I don't know. In terms of implementation, every built-in name that when called, does something, can just be implemented as a function anyway. Random mentioned this about PRINT being a keyword, and he as well makes a point. This is programming, not math (unless you're Haskell, I guess,) so we're allowed to write routines that don't return anything (or some null value, or something) and just that has happened many times. Void functions in C, for example. These languages don't have any sort of "subroutines" at all, because they don't need them. Just functions. Ruby is an interesting example. Everything you define with the def keyword is just a function, with parens around the arguments, and they all return values. But semantically, you can treat them as though they're just "commands." You don't have to wrap the arguments in parentheses if it's not ambiguous, and you don't need anything to receive the return value. puts, for example, Ruby's print function.
puts "Hello!"
puts("Hello!")
string = puts "Hello!" # returns the output string
So BASIC in general is somewhat of an outlier in this regard. Functions and other statements are different here, on the surface, but not by necessity. It could be possible that internally it's all some kind of function call, or weird OUT chain, or something.. But yeah, they're different.

(Maybe this discussion should be in its own thread)