BSLang / BS

Implementation of the BS language as created by Mark Rendle at BuildStuff.lt 2014. Refer to this repo for information and canonical list of language features
208 stars 9 forks source link

Suggestion from MS-DOS #18

Open Vershner opened 2 years ago

Vershner commented 2 years ago

Just saw your talk at NDC Oslo - marvellous!

Here's a great feature from MS-DOS batch script: Variables whose contents start with a non-zero integer are considered to be numbers. Okay... Variables whose contents start with "0x" are considered to be hex. That's not too bad, but... Variables whose contents start with"0" are considered to be octal. Err.... ...except, of course, 08 & 09 are not valid octal and so throw an error whenever they're evaluated.

Years ago I spent weeks trying to figure out why my weekly backup script would occasionally fail.

I think this has great potential to be expanded as well: Variables starting with "01" should be assumed to be binary. Variables starting with "00" should be assumed to be international telephone numbers.

barkermn01 commented 2 years ago

that as good till the last bit,

Variables starting with "00" should be assumed to be international telephone numbers.

telephone numbers are strings of numeric characters otherwise the 0's would be dropped from the start so that would have to be 00 assumed to be a string.

Argavyon commented 25 minutes ago

I believe you mean "literals" rather than "variables" Speaking of, each numeric representation should be its own type. When operating two numeric types, they will both be cast to a base equal to two thirds of the sum of the operands' bases, if that is an integer, or to unary otherwise (programmers should be advised to make sure two thirds of the sum of the bases of all their different base numbers is always an integer for performance reasons).