Re:30 years later, QBasic is still the best
by pvg on Sunday May 27, 2018 @01:55AM
(#17165662)
You can't take the address of a A$, for instance, and do anything with it. And in your case 'A' is always in bytes unlike a C pointer which has arithmetic that depends on its type. PEEKs and POKEs are not pointers.
[ Parent
| on HN ]
Re:30 years later, QBasic is still the best
by badsectoracula on Sunday May 27, 2018 @07:57AM
(#17166538)
QBasic has VARADR (or VARADDR) that gives you the memory location for a variable. QuickBasic also has SADD which gives you the memory location for the first character of a string, although for some reason it isn't available in QBasic (but you can figure out from the string data anyway, VARADR(A$) points to a pair of length+data words).
Real pointers, those used by Assembly are also untyped.
Other Basic dialects, including QBasic's big brother, had a Varadr function or similar, to take an address.
C is not the absolute truth in pointer manipulation across programming languages.
Next you'll be telling me laser pointers have colours and there are several dog breeds named 'pointer'. Pointer dogs are furry.
I don't need jokes about laser pointers to present languages, some of them much older than C, which have pointers with 1:1 features to C ones.
Of course, it kind of hurts the urban myth that C is a special snowflake among systems programming languages, having languages almost 10 years older with such features.
The original comment was a comparison of pointers in C and PEEKs and POKEs in BASIC. So making up stuff about how assembly has 'pointers' or trying to start some argument about C with a statement nobody made is not really much more directly related to what we're discussing than a comment about the music of the Pointer Sisters.
So back to Basic then, this is Turbo Basic (1987)
' a = *addr
a = PEEK (addr%)
' *addr = value
POKE addr%, value
'a = addr
a = addr
'addr++
INCR addr%, 2
'a = &variable
DEF SEG = VARSEG(variable)
a = VARPTR(varible)
a = VARPTR$(varible)
Album, http://www.bitsavers.org/pdf/borland/Borland_Turbo_BASIC_Own...Or to stay with QuickBasic dialects, Freebasic music tunes
https://www.freebasic.net/wiki/wikka.php?wakka=TblComparison...
Which also provides the SIZEOF chord, simplifying the increment operations of memory addresses.