Undocumented features (or at least I think so)

Good evening everyone

Just one or two questions about some aspects of the language.

I’ve “discovered” these two features through experimentation:

– unpack from an array

v=[1,2,3]
arr<<v
(x,y,z)=arr[0]
?x,y,z

– FOR-IN loop over a string

s="Test"
for c in s do ?c,

I’ve gone through the documentation quite thoroughly :saluting_face: , and at no point are these two features mentioned.

So my question is: are these actually usable features, or is there a reason they’re not documented?

Thanks.

JF

Thank you. When I wrote the manual I wasn’t aware of these two features. I had a quick look to the source code and found the for loop over a string. Most probably the feature was added long time ago and not documented. I’ll add both features to the manual the next days.

Good evening, and thank you for your feedback.
While you’re updating the documentation, it might be helpful to provide more details about how to use BLOAD and BSAVE.
I’ve tried using them myself, but without success.

Thanks. — JF

(x,y,z)=arr[0]

I added support for this back in 2017. In python this type of syntax is called packed/unpacked assignment. In es6 they call it destructuring. Take a look at samples/distro-examples/tests/eval-test.bas for examples. IN was always part of Nicholas’ implementation, I added in FOR char in str in 2019.

Hi

Continuing with the topic of undocumented features, here are two more.

IFF (condition, return_value_true, return_value_false)
This is an inline version of if, using either iff or if.
Try: if(1, "true", "false") or iff(1, "true", "false").
Found in: core/samples/distro-examples/tests/iifs.bas, line 28.

TRANSLATE (source, what [, with]):
The translate function supports a fourth parameter for case insensitivity.
Try : translate("foo bar", " BAR", "d", true) or translate("foo bar", " BAR", "d", false).
Found in: core/samples/distro-examples/tests/strings.bas, line 119.

JF

I added the undocumented features to the manual and the corresponding files in the language reference.

I had a look the source code of BSAVE and BLOAD. They somehow do, what is described in the language reference. BSAVE saves a part of the RAM starting at address with a length length. And BLOAD somehow loads it. But I have to admit, that I have no clue what this is good for. Maybe it is useful for debugging or maybe it was used for the old PALM devices. Maybe @chrisws knows more.

Hi

Alright, two last ones in the category of undocumented features (I think I’ve gone through everything this time!)

s = REPLACE(source, pos, str [, len])
The str argument in REPLACE can now be a number.

Example:

a = "1234"  
num = 9  
b = replace(a, 2, num, 2)

Found in: core/samples/distro-examples/tests/replace-test.bas, line 15

OPTION keyword

OPTION PREDEF AUTOLOCAL
All variables are local by default.

Found in: core/samples/distro-examples/tests/scope.bas, line 1

That’s all folks.
JF

1 Like

Thank you. I have updated the website.

2 Likes