33

In many dialects of BASIC, the PRINT statement can be abbreviated with a single question mark when entering programs or direct-mode commands. So instead of typing PRINT "HELLO, WORLD" you can save a few characters by typing ? "HELLO, WORLD".

I have two related questions:

  1. When and where did this convention originate? It seems to be used by all the microcomputer Microsoft-derived BASICs that I'm familiar with, but it's not mentioned in the 1976 manual for Apple's original BASIC, nor (unless I've overlooked it) is it mentioned in the ECMA-116 standard from 1986. Is the question mark PRINT then a Microsoft convention, or does it predate Microsoft's original BASIC interpreter?

  2. Why was the question mark in particular chosen, and not some other character that happened to be unused by the language? To me it would have been more logical to use ? for INPUT and something else—maybe !—for PRINT. Did whoever originally chose the question mark give any rationale for this decision?

Psychonaut
  • 7,133
  • 2
  • 24
  • 54
  • 15
    I think the abbreviation was meant to be used primarily in the REPL, in which case it should be interpreted as the programmer inquiring about the value of the expression, not the program. – user3840170 Apr 18 '22 at 05:58
  • related: https://stackoverflow.com/questions/23597690/following-standards-or-not – Sep Roland May 01 '22 at 15:28

2 Answers2

27

When and where did this convention originate? [...] or does it predate Microsoft's original BASIC interpreter?

I would put Time-Shared BASIC as the first, but that's just an educated guess due to HP Time-Shared BASIC being not only extremely influential to later implementations (*1), but also being one of the first interpreter based BASIC, which is the important part here, as Dartmouth BASIC and all direct successors (Super Basic, etc.) were compilers.

[Maury Markowitz checked the TSB manuals and it does not show up, so it must be later.]

It was that introduction of interactive interpreters that led to the "invention" of the question mark command. Or better, shortcut, as it's really all about less typing for interactive queries. Usability in program source is more of a side effect.

Why was the question mark in particular chosen, and not some other character that happened to be unused by the language? [...] Did whoever originally chose the question mark give any rationale for this decision?

It seems, at least to me, rather obvious. The meaning of "?" isn't really "Print ...", but to ask the interpreter about something. Think of it as "Tell me ..." or "What is ...", as in "what is 2+2", or "What is (the content of variable) A".

This usage became possible the moment BASIC was no longer a compiled language, but interpreted. This enabled two new and very convenient use cases for/with BASIC:

  • Using BASIC as a pocket ... well, desktop, calculator to solve expressions.
  • Stopping a BASIC program at arbitrary locations and inspecting state/content of variables. (*2)

Both are based on simply printing the result of an expression, so use of PRINT as interactive command (*3) came quite naturally. Except that it's 5 characters plus a space - not really what anyone would love to type over and over. Having a single stroke replacing five would be welcome, and using a punctuation character may even avoid typing the space.

So, what punctuation, available in 7 bit ASCII, would you choose to ask the computer for something?


*1 - Most notable with microcomputer BASICs that followed HP's style of string handling by indexing, like Wozniak's Integer BASIC, Atari-BASIC or Sinclair BASIC.

*2 - This may be surprising to young folks only accustomed to interpreters, but in ye-goode-olde-time(tm) of compiled BASIC one had to use a machine monitor to inspect memory once a program was STOPed. That is, if the environment allowed this at all. :))

*3 - Interpreters also mark the point when BASIC instructions became directly executable. With compilers such as Dartmouth BASIC, only editing was interactive. Heck, even INPUT was only added two years later with the Third Edition in 1966.

Raffzahn
  • 222,541
  • 22
  • 631
  • 918
  • 1
    Futhermore, in DTSS on the original hardware, you edited in the (language-independent) front-end machine, and BASIC jobs were compiled and run on the mainframe. – dave Apr 18 '22 at 12:36
  • 1
    small fyi: you got a typo in footnote 1 where you wrote sting instead of string. Can't edit though due to the 6-char limit – masterX244 Apr 19 '22 at 13:15
  • @masterX244 Thx. – Raffzahn Apr 19 '22 at 17:55
  • Looking in the 1975 version of the HP BASIC manual, I do not see the ? as a short form for PRINT noted:

    http://bitsavers.org/pdf/hp/2000TSB/22687-90001_AccessBasic9-75.pdf

    I looked in the V4 Dartmouth, HP, Wang, SUPER BASIC and BASIC-PLUS manuals and none of them list it.

    – Maury Markowitz Aug 12 '23 at 18:09
  • @MauryMarkowitz Interesting. I would have put it back here with the first interactive one. Dartmouth wasn't one. I guess that shortcut didn't work and I have to dig thru some more manuals. Thanks for checking. – Raffzahn Aug 12 '23 at 20:50
  • 2
    Well I only checked due to a question on another forum, and I too expected it to be HP. Since MS is essentially BASIC-PLUS I checked that, and then SUPER BASIC from Tymshare. Neither had it. It may indeed be an MS invention, but I'm still looking. – Maury Markowitz Aug 13 '23 at 01:31
  • It's a bit odd to mention Sinclair BASIC in this context as it doesn't support the ? shortcut. – tofro Aug 15 '23 at 07:09
  • @tofro ? Huh? The footnote is about features adapted, namely indexing of strings. Is this not true? – Raffzahn Aug 15 '23 at 11:34
  • The whole question is about the ? shortcut for PRINT. I find it odd to mention the ZX here, because it doesn't support the premise of the question. Nothing wrong here, just odd. – tofro Aug 15 '23 at 11:43
  • @tofro he footnote is about many other notable BASIC being influenced by TSW. Guilty for adding background info to help position it's influence. I do believe that answers just giving an address to poke are not worth to be written. – Raffzahn Aug 15 '23 at 11:47
2

I checked some HP TSB manuals from 1969 to 1976 and found no mention of "?" for PRINT. HP TSB was my first experience with programming BASIC and I never used "?" for PRINT back then. I went from HP TSB, to VAX BASIC, to Sinclair BASIC, to Hitachi Level-3 BASIC (Microsoft), and only the latter had "?" for PRINT, as far as I can remember. Answers in the BASIC Programming group suggest "?" for PRINT was introduced in Microsoft Level-2 BASIC, while Microsoft Level-1 BASIC had the "P" abbreviation for PRINT.