|
Post by tsh73 on Feb 18, 2021 15:43:00 GMT -5
Found while translating program from other BASIC
unary minus from array of function call while in brackets - does not get flagged as error - but does not work right (instead of calling function/returning array value, returns argument)
y(3)=123
i = 3 print y(i) '123 print (0-y(i)) '-123 print (-y(i)) 'expected error, got 3 'it doesn't actually access array (it would error out of 0..10 print (-y(654)) 'expected error, got 654 print (-y(-654)) 'expected error, got -654
'same thing about functions print print f(i) 'in function, x=3 // 3.01 print (0-f(i)) 'in function, x=3 // -3.01 print (-f(i)) 'expected error, got 3 'it doesn't actually access function - no message "in function" print (-f(654)) 'expected error, got 654, no message "in function"
function f(x) print "in function, x=";x f=x+0.01 end function
Results:
123 -123 3 654 -654
in function, x=3 3.01 in function, x=3 -3.01 3 654
|
|
|
Post by Carl Gundel on Feb 19, 2021 18:08:46 GMT -5
Found while translating program from other BASIC unary minus from array of function call while in brackets - does not get flagged as error - but does not work right (instead of calling function/returning array value, returns argument) print (-y(i)) 'expected error, got 3
Interesting. Not surprisingly this doesn't even compile on LB5.
|
|
|
Post by tsh73 on Feb 20, 2021 2:54:26 GMT -5
What? Unary minus still not to be supported in LB 5? That surprises me.
|
|
|
Post by Carl Gundel on Feb 20, 2021 8:48:57 GMT -5
What? Unary minus still not to be supported in LB 5? That surprises me. Could still happen, but it's not high on my list. Persuade me.
|
|
|
Post by Brandon Parker on Feb 20, 2021 20:47:07 GMT -5
It looks to me like it has made it to the top of the list all on its own ... endOfCarlsList = Int(rnd(1) * 100)
Dim CarlsList$(endOfCarlsList)
For i = 0 To (endOfCarlsList - 1) CarlsList$(i) = generateWords$(Int(rnd(1) * 6) + 4, Int(rnd(1) * 6) + 4) Next i CarlsList$(endOfCarlsList) = "UnaryMinus Implementation"
perform = coffeeBreak(endOfCarlsList)
For i = 0 To endOfCarlsList Print (i + 1);". ";CarlsList$(i) Next i End
Function coffeeBreak(listCount) carlIsOnCoffeeBreak = listCount While (carlIsOnCoffeeBreak) donuts$ = CarlsList$(carlIsOnCoffeeBreak - 1) CarlsList$(carlIsOnCoffeeBreak - 1) = CarlsList$(carlIsOnCoffeeBreak) CarlsList$(carlIsOnCoffeeBreak) = donuts$ carlIsOnCoffeeBreak = (carlIsOnCoffeeBreak - 1) Wend End Function
Function generateWords$(length1, length2) generateWords$ = chr$(Int((rnd(1) * 26) + 65)) For i = 1 To length1 generateWords$ = generateWords$;chr$(Int((rnd(1) * 26) + 97)) Next i generateWords$ = generateWords$;" ";chr$(Int((rnd(1) * 26) + 65)) For i = 1 To length2 generateWords$ = generateWords$;chr$(Int((rnd(1) * 26) + 97)) Next i End Function {:0) Brandon Parker
|
|
|
Post by tsh73 on Feb 21, 2021 4:01:32 GMT -5
Ok I'll try. (I let it be slept over) Please bear with me, no offense meant. 1. It always was supported in BASICS. Datmouth BASIC www.dartmouth.edu/basicfifty/commands.htmlDavid Ahl codes www.atariarchives.org/basicgames/showpage.php?page=167line 5 5 DEFFNA(Z)=30*EXP(-COS(Z/16))-30 Spectum BASIC (just checked in emulator. Oh these keys.) Microsof GW/Quick basic (just checked under Win XP - had to google how to exit from GWBasic) There big chances users will trip over it while converting old basic program, like I did recently. 2. It is routinely supported in other languages C/C++ C# Pascal (just checked some version (ABC.NET). Oh these ":=" ) Fortran (just checked G95. Had to open manual just to find out that compiled file is a.exe) Python (just checked 3.4.3) There big chances users will trip over it while converting programs from other languages 3. Unary minus concept "with us" from math. It is expected to work. If I do ball deflecting from a wall, I will write dx = -dx . And it doesn't work as of now. 4. Thing that does not work as expected seems broken (be it old program being converted or new program written) Picking up new language is hard. Things that seems illogical or broken adds to the chance user drop it for good. So not to add to list of things that "seems illogical or broken" is good thing. Quoting user from another forum: 5. "It never was supported" is bad answer. It is a new language after all. I suppose author care of his users.
|
|
|
Post by tenochtitlanuk on Feb 21, 2021 4:24:03 GMT -5
Well put Anatoly. Agree strongly with all your points...
EDIT' Many of my generation really got into programming on the BBC Computer. From the BBC computer manual..
-5 This shows one of the few ‘unary’ operators that we are used to. The - just acts on the 5 to make it a negative number.
|
|
|
Post by Carl Gundel on Feb 23, 2021 17:18:49 GMT -5
Ok I'll try. (I let it be slept over) Please bear with me, no offense meant. 1. It always was supported in BASICS. Datmouth BASIC www.dartmouth.edu/basicfifty/commands.htmlDavid Ahl codes www.atariarchives.org/basicgames/showpage.php?page=167line 5 5 DEFFNA(Z)=30*EXP(-COS(Z/16))-30 Spectum BASIC (just checked in emulator. Oh these keys.) Microsof GW/Quick basic (just checked under Win XP - had to google how to exit from GWBasic) There big chances users will trip over it while converting old basic program, like I did recently. Thanks for taking the time to do this. I do find this (1. It always was supported in BASICS) to be the strongest argument, not so much the other points (except that I consider point 4 to be part of point 1). That said, I have other stuff that I'm working on that is much more important. Thanks again.
|
|