Cleaning up and 2.0 - Addition and Concatenation (Program Bug and Problems)

by Jim ⌂ @, Russell, KY, Saturday, March 26, 2016, 04:33 (455 days ago)

A flurry of posts on Sourceforge has been happening about little issues and ideas. I would like to post a couple of additional changes to propose.

To make BASIC256 easier for students to transition to VB.NET I would like to change the "&" operator for Binary And to "&&". This will allow "&" to be concatenate. Also Binary OR would change to "||" to make the operators consistent with other languages.

It has also been suggested that the ZX80 form of print "PRINT 1;'+';2;'=';(1+2)" using semicolons to concatenate and to suppress the new line. I would like to propose that ";" also be an operator for concatenate and that it could be used anywhere.

With these new concat operators "&" and ";", I would also like to change the behavior of "+". Currently (1.99.99.16) "+" does 1) if either or both are strings (even numeric strings) then concatenate; 2) if they are integers - add as integers; 3) add mixed integers amd floats as floats. I would like to propose for 2.0 to make "+" the following: 1) if both are integers then add as integers; 2) if both are mixed floats, integers, or strings that could be converted to floats then add as floats; 3) concatenate. This makes "+" more number-centric and makes the behavior more like '-' that tries to convert strings to floats.

The current test suite runs successfully with these changes but the example programs would need to be tested before this is released.

What think you all?

Cleaning up and 2.0 - Addition and Concatenation

by igendel ⌂ @, Wednesday, April 06, 2016, 21:44 (444 days ago) @ Jim

Hi Jim,

Just to clarify, when you write "Binary AND" and "Binary OR", do you mean Bitwise AND and OR? Because that would really confuse users with background in C/C++, where && and || are the Logical AND and OR.

Unless it's for backward compatibility, I think three different operators for string concatenation are too much. In fact, for the sake of avoiding bugs I'd even give up the string-to-number functionality of the "+" operator altogether:
Number + number => number
String + string => string
Number + string => [Error]

(You can see I prefer strong-typing languages :-) )

I am looking at this from the perspective of a complete beginner, e.g. my children. Perhaps there's a different audience for this which is bigger and more important...

Sincerely,
Ido

Cleaning up and 2.0 - Addition and Concatenation

by francisco, Wednesday, May 11, 2016, 09:25 (409 days ago) @ Jim
edited by francisco, Wednesday, May 11, 2016, 09:28

Good day,

I'd prefer to maintain as much as possible the language backwards compatible. Otherwise, at each new revision people are forced to review all the changes to the language, review all their programs looking if they use any of the changed functionalities, change them if necessary, an retest the programs.

I think this should be avoided exception made of very big reasons.

(I'm refering specifically to convert and add with the "+" operator two strings containing digits)

Also, if the language is not seen as very stable, this can prevent new people from using it.

Sincerely,

Francisco

Cleaning up and 2.0 - Addition and Concatenation

by Jim ⌂ @, Russell, KY, Monday, August 08, 2016, 14:19 (320 days ago) @ francisco

After much thought and input from the community, you make a good point.

+ will
if both are integers, it will add as integer
if both are numbers and either are floating point, it will add as floats
if either are strings, it will concatenate

the new ; operator will always concatenate

This should ensure backward compatibility and keep BASIC-256 moving forward.

Jim

RSS Feed of thread
powered by my little forum