Preferences

BASIC is far worse than that. Like, at least in Python, len() is a regular function. In BASIC, tons of core features are implemented as statements, with rather weird syntax that got even more weird over time.

   LINE (x1, y1) - (x2, y2), 5, FB
Can you remember what it does? (no, it doesn't draw a line; it would, if not for "FB").

Or, for example, MID$ is a function, except when it's not:

   MID$(s$, 1) = "foo"
Then there's stuff like DEFINT and GOSUB and ON STRIG and ...

The reason for all this is that BASIC was never designed as a language in which the standard library could mostly be written, or even described, in that language. Thus, most features were implemented as intrinsics, with magic syntax and/or semantics, which varies drastically from feature to feature. This goes even for the standard functions - e.g. MID$ is a function (except when it's not, as above) - but it can take either 2 or 3 arguments, which is not something that you can declare yourself. As a result, when language evolved, it also did so in a haphazard way, as with LINE re-purposed for other reasons.

The original BASIC was very simple (but also non-extensible). The BASIC that most people remember - at its peak - was actually more complicated than an equivalent subset of Python.


And then there was Applesoft's assembly language extension mechanism: "&".

Enhancing Applesoft using ampersand routines: https://link.springer.com/content/pdf/10.3758/BF03203836.pdf

>Applesoft BASIC's ampersand (&) jump feature gives the programmer an easy and fast way to connect machine language routines to BASIC. When the Applesoft interpreter encounters an "&," it does an immediate and unconditional jump to location $3F5 (decimal 1013). This feature, originally described as being "intended for the computer's internal use only" and "not a proper APPLESOFT command" (Apple Computer, 1978, p. 123), has become the favorite procedure for executing machine language routines from a running Applesoft program.

Most BASICs had something like that. Here's something from QBASIC documentation:

   Transfers control to a machine-language procedure.

   CALL ABSOLUTE ([argumentlist,] offset%)

       ▪ argumentlist    Arguments passed to a machine-language procedure
                         as offsets from the current data segment.
       ▪ offset%         The offset from the current code segment, set by
                         DEF SEG, to the starting location of the procedure.

   Example:
       'Calls routine for printing the screen to a local printer.
       DIM a%(2)
       DEF SEG = VARSEG(a%(0))
       FOR i% = 0 TO 2
          READ d%
          POKE VARPTR(a%(0)) + i%, d%
       NEXT i%
       DATA 205, 5, 203  : ' int 5  retf  'Machine-language code
                                          'for printing screen.
       CALL ABSOLUTE(VARPTR(a%(0)))
       DEF SEG
And before that, there was DEF USR: http://www.antonis.de/qbebooks/gwbasman/defusr.html

    >>> s = 'foobar'
    >>> s[1:2] = 'xxx'
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: 'str' object does not support item assignment
Dammit Python! Immutable strings.
> LINE (x1, y1) - (x2, y2), 5, FB

> Can you remember what it does? (no, it doesn't draw a line; it would, if not for "FB").

Yes. Draws a filled box (FB), from top-left (x1,y1) to bottom right (x2,y2) in Purple (colour 5).

Although thinking about it... I'm pretty sure that the co-ords of 0,0 were bottom left, not top left on DOS based graphic screens, so is quite probably bottom-left to top-right.

Source: One of my first 'paid' jobs was as a QB45 programmer for an accountancy firm in the mid 1990s.

This item has no comments currently.

Keyboard Shortcuts

Story Lists

j
Next story
k
Previous story
Shift+j
Last story
Shift+k
First story
o Enter
Go to story URL
c
Go to comments
u
Go to author

Navigation

Shift+t
Go to top stories
Shift+n
Go to new stories
Shift+b
Go to best stories
Shift+a
Go to Ask HN
Shift+s
Go to Show HN

Miscellaneous

?
Show this modal