Author Topic: New BASIC, for fun  (Read 17120 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: New BASIC, for fun
« Reply #15 on: April 30, 2012, 05:23:18 PM »
Code: [Select]
a = 10
s = 1

FOR x = 1 TO a STEP s
  IF x = 5 THEN s = .5
  IF x = 10 THEN
    a = 15
    s = 1
  END IF
  PRINT FORMAT("%g",x),"\n"
NEXT

jrs@laptop:~/sb/test$ scriba 4var.sb
1
2
3
4
5
5.5
6
6.5
7
7.5
8
8.5
9
9.5
10
11
12
13
14
15
jrs@laptop:~/sb/test$
« Last Edit: April 30, 2012, 08:02:03 PM by JRS »

SteveA

  • Guest
Re: New BASIC, for fun
« Reply #16 on: April 30, 2012, 06:13:50 PM »
Then Sb and Yabasic share the same peculiarity.
That is very uncommon.

Marcus

  • Guest
Re: New BASIC, for fun
« Reply #17 on: May 01, 2012, 12:09:16 AM »
Code: [Select]
a = 10
s = 1

FOR x = 1 TO a STEP s
  IF x = 5 THEN s = .5
  IF x = 10 THEN
    a = 15
    s = 1
  END IF
  PRINT FORMAT("%g",x),"\n"
NEXT

jrs@laptop:~/sb/test$ scriba 4var.sb
1
2
3
4
5
5.5
6
6.5
7
7.5
8
8.5
9
9.5
10
11
12
13
14
15
jrs@laptop:~/sb/test$

Very nice!

But I'm not sure it works like this in yabasic at all; what I meant was just that I want compability with yabasic in general, as people seem to like it that much.

However, this SB example illustrates perfectly what I'm after :) Can you find more hidden candy like that in SB?
« Last Edit: May 01, 2012, 12:11:34 AM by Marcus »

SteveA

  • Guest
Re: New BASIC, for fun
« Reply #18 on: May 01, 2012, 06:46:44 AM »
Isn't this sort of a "Kobayashi Maru", where you set up a test and in mid-stream you alter or change the conditions of the test ?
Why would you do that ?

The following snippets are extracts from: ECMA-55 (Basic Standard), section 13:

<quotation...>
"The action of the for-statement and the next-statement is defined in terms of other statements, as follows:

FOR v = initial-value TO limit STEP increment
(block)
NEXT v

is equivalent to:
Code: [Select]
      LET own1 = limit
      LET own2 = increment
      LET v = initial-value
line1 IF (v-own1)*SGN (own2) > 0 THEN line2
      (block)
      LET v = v+own2
      GOTO line1
line2 REM continued in sequence


Here v is any simple-numeric-variable, own1 and own2 are variables associated with a particular for-block and not accessible to the programmer, and line1 and line2 are line numbers and not accessible to the programmer.
A program shall not transfer control into a for-body by any statement other than a return statement."<...end>

And,
<quotation...>
The variables "own1" and "own2" associated with a for-block are assigned values only upon entry to the for-block through its for-statement."<...end>

To me, the key notes here are:
..."own1 and own2 are variables ... not accessible to the programmer,..."

and,
...variables "own1" and "own2" ... assigned values only upon entry to the for-block...

« Last Edit: May 01, 2012, 07:34:15 AM by SteveA »

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: New BASIC, for fun
« Reply #19 on: May 01, 2012, 08:58:11 AM »
Quote from: Marcus
Can you find more hidden candy like that in SB?

It's Halloween at the ScriptBasic project and all you need to do is open your bag and help yourself. We promise not to to make your visit too scary.  :D

« Last Edit: May 01, 2012, 09:25:40 AM by JRS »

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: New BASIC, for fun
« Reply #20 on: May 01, 2012, 10:05:53 AM »
Quote
Isn't this sort of a "Kobayashi Maru", where you set up a test and in mid-stream you alter or change the conditions of the test ?

@Steve: Please don't apply for any missile silo operator jobs! 

ScriptBasic is a scripting language that happens to use traditional Basic (for the most part) as it's syntax. What may be lost in performance is returned 10 fold in simplicity with the expectation the language is smart enough to assume the obvious.

« Last Edit: May 01, 2012, 12:28:10 PM by JRS »

SteveA

  • Guest
Re: New BASIC, for fun
« Reply #21 on: May 04, 2012, 08:25:05 AM »
ScriptBasic is a scripting language that happens to use traditional Basic (for the most part) as it's syntax.

Well, I'm not an absolute pureist.
I think that is one of the faults of the BASIC language and some might say part of its charm, the fact that despite attempts to create Industry Standards, in both the US and Europe, developers refused to adhere to them.
Instead, we have a hundred plus different dialects of a language, each with their own nuances and idiosyncrasies.

Take C as an example, the C language is clearly defined as to what is and what isn't considered "C".
You can't call it "C" if it isn't really compliant with the "C" Standards.

Javascript is Javascript, Perl is Perl.
You don't generally run into various dialects of the most popular and widely used, modern languages.

I think in the case of Basic, in an effort to expand the language and add functionality, developers failed to recognise the importance of standardization.
With the exception of x86 Assembly Language, I personally don't know of another programming language that suffers from the same problem of having too many dialects to choose from. Each with their own following and user base.

Contrarily, the C/C++ user base seems to cluster more around which IDE to use.

If you know C, then you know C.
If you know C++, then you know C++.
If you know Perl, then you know Perl.
If you know Basic, then you need to specify which dialect of Basic you are proficient in.

From the perspective of the end-users, does having too many differing dialects enhance or dilute the appeal of using a particular language ?

Offline John

  • Forum Support / SB Dev
  • Posts: 3512
    • ScriptBasic Open Source Project
Re: New BASIC, for fun
« Reply #22 on: May 04, 2012, 06:17:20 PM »
Quote
From the perspective of the end-users, does having too many differing dialects enhance or dilute the appeal of using a particular language ?

Variety is the spice of life.

Why do some people build hot rods or return a classic cars to mint condition when they can pick up a car off a lot?
« Last Edit: May 04, 2012, 09:58:27 PM by JRS »