One of my goals with BASIC Anywhere Machine: compatibility with GW-BASIC.
If I did not care about that compatibility, I’d definitely be getting rid of multi-purpose features in functions because it makes for messy implementation code.
For example: POINT.
POINT (x,y) returns the colour at the pixel coordinate.
POINT(0) and, alternatively, POINT(2) gives the current x coordinate resulting from the last graphics statements.
POINT(1) and, alternatively, POINT(3) gives the current y coordinate resulting from the last graphics statements.
I would never have implemented POINT that way. It is a lousy idea.
That, however, is not the worst of it.
It is the messy code related to implementation:
if (name=='point') {
Skip('(');
var a = Expression();
if (tok==',') {
Skip(',');
var b = Expression();
Skip(')');
return 'Point(('+a+'), ('+b+'))';
}
else {
Skip(')');
return 'PointPos('+a+')';
}
}
In the grand scheme of things, any developer could figure out what is going on there.
However…
Code that is intertwingled makes for risky code. It makes for less robust code and increases risk of problems going forward, problems that increase in likelihood when a project can have who knows how many people updating/adding/touching the code (I.e. TW core).
Clean and focused implementation code wins the day.
But it is only a few lines of code? Well …
What you are suggesting for length[] is the kind of stuff that adds another dime to a nickel and dime mess to the code that makes TW work.
I’m against that kind of change to length[] because I have zero-tolerance for things that create risk to stability. With all due respect to the talent on TW development: even if all of them are the world’s elite programmers, I insist on solid and very focused segments of code.
What you are asking for re length
, it should be a new and dedicated operator for that functionality. Otherwise, I’m going to have some significant reservations about the thought-processes behind TW development.
Keep the TW code clean and focused.