Vectrex32

General Category => General Discussion => Topic started by: johnhenry on August 25, 2016, 02:00:08 PM

Title: Basic Interpreter
Post by: johnhenry on August 25, 2016, 02:00:08 PM
Is there a published manual for the BASIC version used on the Vectrex32?

Title: Re: Basic Interpreter
Post by: Vectrex32 on August 25, 2016, 02:01:07 PM
Yes. Go to http://vectrex32.com/category/documentation/ (http://vectrex32.com/category/documentation/).

- Bob
Title: Re: Basic Interpreter
Post by: crcasey 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
Title: Re: Basic Interpreter
Post by: Vectrex32 on November 15, 2016, 05:38:50 PM
Quote from: crcasey 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?

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
Title: Re: Basic Interpreter
Post by: crcasey 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
Title: Re: Basic Interpreter
Post by: crcasey 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
Title: Re: Basic Interpreter
Post by: Vectrex32 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
Title: Re: Basic Interpreter
Post by: Vectrex32 on November 15, 2016, 08:33:17 PM
Quote from: crcasey 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

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
Title: Re: Basic Interpreter
Post by: crcasey on November 15, 2016, 08:34:29 PM
Thanks, Sorry to keep up the basic (ha) questions.

-C
Title: Re: Basic Interpreter
Post by: crcasey 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
Title: Re: Basic Interpreter
Post by: Vectrex32 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
Title: Re: Basic Interpreter
Post by: crcasey 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
Title: Re: Basic Interpreter
Post by: Vectrex32 on November 15, 2016, 09:45:13 PM
It gives you an error, that the function call has the wrong number of arguments.

- Bob
Title: Re: Basic Interpreter
Post by: crcasey on November 15, 2016, 09:47:54 PM
Quote from: Vectrex32 on November 15, 2016, 09:45:13 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
Title: Re: Basic Interpreter
Post by: Vectrex32 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
Title: Re: Basic Interpreter
Post by: crcasey on November 15, 2016, 09:53:46 PM
Do you have to use AppendArrays to combine arrays or can use the + as a concatenation operator?  Can it be overloaded?

-Cecil
Title: Re: Basic Interpreter
Post by: Vectrex32 on November 15, 2016, 09:59:15 PM
You use AppendArrays to concatenate arrays. Operators can't be overloaded: this is BASIC not C++. Besides, if you overloaded + for an array, would it be concatenation or matrix addition?

- Bob