Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 11:22 09 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: V5.05.03 Bug Reports

     Page 2 of 4    
Author Message
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 01:58am 24 Jun 2020
Copy link to clipboard 
Print this post

Regarding short circuit evaluation.

This is a type of request that comes up regularly, ie, "can you add xxxx feature from yyyy language?". This is obviously not sustainable so generally I resist such calls.  Certainly, not implementing said feature is not a bug.  MMBasic was designed to resemble Microsoft BASIC and that is all that is promised.

MMBasic has evolved into a solid implementation of the "standard" BASIC language and I don't want to mess with it by adding features of marginal value.  This stability is important to the many people who write programs using MMBasic and in part allowed Peter to port it to the ARM architecture.

Geoff
Geoff Graham - http://geoffg.net
 
GregZone
Senior Member

Joined: 22/05/2020
Location: New Zealand
Posts: 114
Posted: 05:54am 24 Jun 2020
Copy link to clipboard 
Print this post

  thwill said  However I have accepted that BASIC apparently doesn't work this way, I never knew.

Regards,

Tom

Hi Tom. This interests me, as I'm familiar with short circuit evaluation from a prior life where I wrote an expression evaluator for an interpretive language.

My first instinct was indeed that simple optimisations, like logic expression short circuit, seemed a no-brainer for adding a performance optimisation.

But, sometimes seemingly obvious things aren't always that straight forward.

The easiest way to describe this is Edsger W. Dijkstra's clearly outlined argument, which you can find under the reference: "The use of short-circuit operators has been criticized as problematic", on the wikipedia article here:
Short-circuit evaluation

On this basis, I'd vote for leaving the status quo.
ie. I'd only consider implementing short-circuit evaluation as part of a new language implementation (not as a change to a language with an existing codebase / existing coding expectations).

Just my 2c for your consideration.

Regards
Greg
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3674
Posted: 09:43am 24 Jun 2020
Copy link to clipboard 
Print this post

It's "interesting" to mention Dijkstra in the context of BASIC - a language he utterly detested!

He commented "It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration."

(I reckon he meant a Basic heavy in GOTO and one-letter variable names, very poor notions of type, etc.)

Changing MMBasic to do short-circuit evaluation of And / Or presumably (to keep current programs working) would mean adding AndIf / OrIf / OrElse or some such operators - and then what happens to all the other MMBasic versions (PIC32 etc)?  May not even have flash space.

I can see why Geoff is not keen!!

John
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3852
Posted: 09:59am 24 Jun 2020
Copy link to clipboard 
Print this post

I wrote a rant, and then I thought better of it, the executive summary is that if you read this thread nobody including myself asked for the existing behaviour to be changed I just raised it as a "Possible Bug", I even added a "?" mark

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3852
Posted: 01:11pm 24 Jun 2020
Copy link to clipboard 
Print this post

Is this a bug in EVAL ?

Is this expected to work?
Print Eval("multiply(3,4)")

Function multiply(a, b)
 multiply = a * b
End Function


... it doesn't:
[1] Error: multiply is not declared


... and it doesn't work if multiply is declared before the PRINT statement either.

I'm probably doing something daft,

Tom
Edited 2020-06-24 23:15 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8600
Posted: 01:14pm 24 Jun 2020
Copy link to clipboard 
Print this post

  Quote  Is this a bug in EVAL ?


Not sure if it is a bug or a limitation. I've already raised it with Geoff. Currently eval only seems to work with in-built functions. I hope this can be overcome but it is definitely one for Geoff
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3852
Posted: 01:16pm 24 Jun 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  Is this a bug in EVAL ?


Not sure if it is a bug or a limitation. I've already raised it with Geoff. Currently eval only seems to work with in-built functions. I hope this can be overcome but it is definitely one for Geoff


OK, that would be nice to have.

Regards,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3852
Posted: 01:24pm 24 Jun 2020
Copy link to clipboard 
Print this post

Dang! it looks like GoSub s$ doesn't work either
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3674
Posted: 01:41pm 24 Jun 2020
Copy link to clipboard 
Print this post

Maybe

eval("gosub " + s$)

John
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3852
Posted: 01:47pm 24 Jun 2020
Copy link to clipboard 
Print this post

  JohnS said  Maybe

eval("gosub " + s$)

John


Tricksy, but it looks like you can't EVAL a GOSUB.

Looks like my unit-test framework is going to have to generate the .bas file containing the tests and construct a new file to execute them ... except the reason I was writing the framework is to test my code to lex .bas files in the firstplace
Edited 2020-06-24 23:48 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8600
Posted: 01:48pm 24 Jun 2020
Copy link to clipboard 
Print this post

  Quote  Is this a bug in EVAL ?


Yes and its my fault. Try again with the following line

Print Eval("MULTIPLY(3,4)")


Workround for V5.05.03 is that user functions must be in capitals in the eval string
Edited 2020-06-24 23:49 by matherp
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3674
Posted: 01:57pm 24 Jun 2020
Copy link to clipboard 
Print this post

Ah, so maybe

eval("GOSUB " + s$)

but also make sure s$'s content is upper case.

John
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8600
Posted: 02:04pm 24 Jun 2020
Copy link to clipboard 
Print this post

  Quote  Ah, so maybe

eval("GOSUB " + s$)


No in-built reserved words don't have the issue.

HOWEVER the statement is meaningless.
EVAL is a function so executing the EVAL string must return a value. You can think of the EVAL string as equivalent to having an implied LET command in front of it that then returns the value to the calling statement

thwill's original example usage was correct it just hit a bug I introduced in case conversion (or not)

My test program checked on 5.05.03

cls
subtorun$="atan2"
? topsub(4,5,subtorun$)
subtorun$="MYSUB1" 'note user functions must be in upper case in 5.05.03
? topsub(4,5,subtorun$)
end
'
function topsub(a,b, c$)
local d$=c$+"("+str$(a)+","+str$(b)+")"
print d$
pause 2000
topsub=eval(d$)
end function
'
function mysub1(x,y) 'case of the actual function doesn't matter
mysub1=x+y
end function

Edited 2020-06-25 00:13 by matherp
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3852
Posted: 03:08pm 24 Jun 2020
Copy link to clipboard 
Print this post

Thanks Peter, using upper-case resolved the issue.

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1084
Posted: 11:06pm 25 Jun 2020
Copy link to clipboard 
Print this post

Not a bug per say, but the editor opens on a line that generated an error if ON ERROR SKIP was used to bypass an expected error. It no longer opens on the last line edited.

For example, if my program includes
on error skip
 nunchuk open 3
if MM.ERRNO = 16 then
 print "No Nunchuk."
endif
then when the editor opens after running the program, it always puts the cursor on the 'nunchuk open 3' line if no nunchuk was connected. (Unless of course another error occurred later during execution.)
Visit Vegipete's *Mite Library for cool programs.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8600
Posted: 08:42am 26 Jun 2020
Copy link to clipboard 
Print this post

  Quote  but the editor opens on a line that generated an error if ON ERROR SKIP was used to bypass an expected error. It no longer opens on the last line edited.

Will fix in next beta
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1084
Posted: 09:50pm 27 Jun 2020
Copy link to clipboard 
Print this post

For the past while, the editor has been quite stable with no glitching associated with cutting, copying and pasting. But today I've had a few errors. (v5.0303 - release)

This time though I have a new data point. I have a mouse connected to com2 and it was the mouse position report that was pasted into the editor. Trouble is, I can't reproduce it at will.
open "com2:38400,256,MouseInt,8" as #4


The external hardware transmits 8 bytes of mouse data whenever the mouse moves, up to about 30 times a second. These 8 bytes (repeated a few times) replaced a line of text involved in a copy/paste operation.

=====
Mucking some more, I got another one. I was wiggling the mouse around (to ensure com2 traffic) while starting to copy. Here is a picture of the screen:



I had just pressed [F4] and arrow down once. The line selected was exactly the same as the line one above the gibberish line. There is one space character at the end of the non-gibberish line.

Here is a second picture after pressing [F5] to copy, down arrow once, [Enter] once to make space and [F5] to paste:



The format of the string received on com2 is 'M', 4 bytes of binary data, 'A', 'B' and finally '\r'
The actual 4 bytes depend on the movement of the mouse. (Inverse '@' is 0x00, isn't it?)
Inverse 'M' in the original line is '\r' which is removed in the pasted line. Inverse 'J' appears to have been changed to "\n\r"

If I save with [F1] and then immediately 'edit' again, the editor now shows:



Note the above is still a rare occurrence. I cannot reproduce it at will.

Does this help in any way?
Visit Vegipete's *Mite Library for cool programs.
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1084
Posted: 11:30pm 27 Jun 2020
Copy link to clipboard 
Print this post

A minor, not really a bug thing, if you are in the editor with a changed file and you press [ESC], you get a warning that there are unsaved changes and 2 more [ESC]s are required to quit. Any other key you type to cancel quitting gets put into the editor.
Visit Vegipete's *Mite Library for cool programs.
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 842
Posted: 04:59am 28 Jun 2020
Copy link to clipboard 
Print this post

This may be for Jim and MM Edit?
I'm using CMM2's 5.0503 and MM Edit V 4.0.1 OS Ver 10.

When I use the running man (with Auto Run On Load) the program transfers and runs well but the Chat window precedes some lines with several escape sequences (obviously these are not SEEN on the CMM2 VGA monitor). This also occurs if I "RUN" the program from the CMM2 or with commands from the Command Line.
This makes debugging error messages etc messy.
Is there a setting or is it just me?

Many thanks,

Andrew
(this is a sample)

 Trace on
 FileName$ = "Graph.TXT"
 Print FileName$
 OPEN FileName$ FOR OUTPUT AS #2
 for I = 0 to 10
   print #2, I, " Test"
   print I, " Test"
 Next I
 Close #2
end


> run
[?25h[2][3]Graph.TXT
[4][5][6][7] 0 Test
[8][6][7] 1 Test
[8][6][7] 2 Test
[8][6][7] 3 Test
[8][6][7] 4 Test
[8][6][7] 5 Test
[8][6][7] 6 Test
[8][6][7] 7 Test
[8][6][7] 8 Test
[8][6][7] 9 Test
[8][6][7] 10 Test
[8][9][10][?25h
>
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5916
Posted: 06:19am 28 Jun 2020
Copy link to clipboard 
Print this post

They are VT escape sequences.
If you don't like them, either switch to VT mode or preferably use TeraTerm.
ASCII mode will show all characters and will not interpret VT escape codes, That is why you are seeing them.

Jim
VK7JH
MMedit   MMBasic Help
 
     Page 2 of 4    
Print this page
© JAQ Software 2024