Author Topic: Basic Interpreter  (Read 769 times)

johnhenry

  • Newbie
  • *
  • Posts: 1
    • View Profile
Basic Interpreter
« on: August 25, 2016, 02:00:08 PM »
Is there a published manual for the BASIC version used on the Vectrex32?

« Last Edit: August 25, 2016, 02:02:04 PM by Vectrex32 »

Vectrex32

  • Administrator
  • Full Member
  • *****
  • Posts: 102
    • View Profile
Re: Basic Interpreter
« Reply #1 on: August 25, 2016, 02:01:07 PM »

crcasey

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Basic Interpreter
« Reply #2 on: November 15, 2016, 05:13:52 PM »
What is the reason that you have decided not to cast variable types, but allow any type to be changed at any time to a different type?  IE why can an array be changed to a int with no warning.  It seems this makes it harder to find an accidental misassignment.

Not that this is a bug, or even wrong.  I just wondered what your thinking on this is.

-Cecil

Vectrex32

  • Administrator
  • Full Member
  • *****
  • Posts: 102
    • View Profile
Re: Basic Interpreter
« Reply #3 on: November 15, 2016, 05:38:50 PM »
What is the reason that you have decided not to cast variable types, but allow any type to be changed at any time to a different type?

If I may state it a little more precisely: a variable can be set to any value of any type at any time.

I anguished for quite a while over whether I should use static or dynamic typing. I settled on dynamic partly because I thought it was easier for novice programmers, partly because it simplified my implementation, and partly because it let me re-initialize arrays - something I envisioned being useful when working with sprites.

- Bob

crcasey

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Basic Interpreter
« Reply #4 on: November 15, 2016, 08:27:27 PM »
Another question along this line...

Why keep = as both assignment and as an expression?

I find the C way of = being assignment and == being compare expression makes the code read more clearly.

-Cecil

crcasey

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Basic Interpreter
« Reply #5 on: November 15, 2016, 08:29:23 PM »
Also a quick question on assignment and pointers...

a=10
b=a
b=b+10

is a = 10 or is a=20 now?

How about with more complex types like arrays?

-Cecil

Vectrex32

  • Administrator
  • Full Member
  • *****
  • Posts: 102
    • View Profile
Re: Basic Interpreter
« Reply #6 on: November 15, 2016, 08:29:58 PM »
BASIC has always used = for both assignment and comparison, so I'm just keeping with that tradition.

- Bob

Vectrex32

  • Administrator
  • Full Member
  • *****
  • Posts: 102
    • View Profile
Re: Basic Interpreter
« Reply #7 on: November 15, 2016, 08:33:17 PM »
Also a quick question on assignment and pointers...

a=10
b=a
b=b+10

is a = 10 or is a=20 now?

How about with more complex types like arrays?

-Cecil

a remains 10. However, if you did:

dim a[1]
a[1] = 10
b = a
b[1] = 20

then a[1] would also be 20. So scalar assignments are copies of the value while array assignments are copies of the references.

- Bob
 

crcasey

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Basic Interpreter
« Reply #8 on: November 15, 2016, 08:34:29 PM »
Thanks, Sorry to keep up the basic (ha) questions.

-C

crcasey

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Basic Interpreter
« Reply #9 on: November 15, 2016, 09:27:32 PM »
I don't think I have run into a basic version that normally can use a float type in the FOR ... STEP  <Float> format before.

Is this carried over from a Basic I have not used?  I can totally see where this will be great for camera moves and sprite translations.

-Cecil

Vectrex32

  • Administrator
  • Full Member
  • *****
  • Posts: 102
    • View Profile
Re: Basic Interpreter
« Reply #10 on: November 15, 2016, 09:33:41 PM »
Actually, I think BASIC has always allowed floating point values in FOR statements. I remember doing it in BASIC Plus on a PDP-11 in the late 70s. It requires some care due to the imprecise nature of floating point values.

- Bob

crcasey

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Basic Interpreter
« Reply #11 on: November 15, 2016, 09:44:17 PM »
Function handling question...

If you define:

FUNCTION MyFunction(a, b)
RETURN a + b
ENDFUNCTION


What happens if you call it...

a=MyFunction(1)
print a

Of if you call it...

a=Myfunction(1,2,3)
print a

Just wondering how that error was handled.

-Cecil

Vectrex32

  • Administrator
  • Full Member
  • *****
  • Posts: 102
    • View Profile
Re: Basic Interpreter
« Reply #12 on: November 15, 2016, 09:45:13 PM »
It gives you an error, that the function call has the wrong number of arguments.

- Bob

crcasey

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Basic Interpreter
« Reply #13 on: November 15, 2016, 09:47:54 PM »
It gives you an error, that the function call has the wrong number of arguments.

- Bob

Same function def.
A more strange case, but likely follows string cat rules.

a="A number is "
b=3.33333

print myfunction(a,b)

-C

Vectrex32

  • Administrator
  • Full Member
  • *****
  • Posts: 102
    • View Profile
Re: Basic Interpreter
« Reply #14 on: November 15, 2016, 09:53:11 PM »
Argument a will be a string, b will be a number, and when the function executes the plus sign, it will act as a string concatenation, with b being converted to a string.

- Bob