Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>Dim</code> have had different meanings attributed to it.</p> <p>I've found references about <code>Dim</code> meaning <strong>"Declare In Memory"</strong>, the more relevant reference is a document on <a href="http://download.oracle.com/docs/cd/B31104_02/books/VBLANG/VBLANGVBLangRef67.html" rel="noreferrer">Dim Statement</a> published Oracle as part of the Siebel VB Language Reference. Of course, you may argue that if you do not declare the variables in memory where do you do it? Maybe <strong>"Declare in Module"</strong> is a good alternative considering how <code>Dim</code> is used.</p> <p>In my opinion, "Declare In Memory" is actually a <em>mnemonic</em>, created to make easier to learn how to use <code>Dim</code>. I see "Declare in Memory" as a better meaning as it describes what it does in current versions of the language, but it is not the proper meaning.</p> <p>In fact, at the origins of Basic <code>Dim</code> was only used to declare arrays. For regular variables no keyword was used, instead their type was inferred from their name. For instance, if the name of the variable ends with <code>$</code> then it is a string (this is something that you could see even in method names up to VB6, for example <code>Mid$</code>). And so, you used <code>Dim</code> only to give <em>dimension</em> to the arrays (notice that <code>ReDim</code> resizes arrays).</p> <hr> <p>Really, <em>Does It Matter</em>? I mean, it is a keyword it has its meaning inside an artificial language. It doesn't have to be a word in English or any other natural language. So it could just mean whatever you want, all that matters is that it works.</p> <p>Anyhow, that is not completely true. As BASIC is part of our culture, and understanding why it came to be as it is - I hope - will help improve our vision of the world.</p> <hr> <p>I sit in from of my computer with a desire to help preserve this little piece of our culture that seems lost, replaced by our guessing of what it was. And so, I have dug MSDN both current and the old CDs from the 1998 version. I have also searched the documention for the old QBasic [Had to use DOSBox] and managed to get some Darthmouth manual, all to find how they talk about <code>Dim</code>. For my disappointment, they don't say what does <code>Dim</code> stand for, and only say how it is used.</p> <p>But before my hope was dim, I managed to find this <a href="http://bbc.nvg.org/doc/BBCUserGuide-1.00.pdf" rel="noreferrer">BBC Microcomputer System Used Guide</a> (that claims to be from 1984, and I don't want to doubt it). The BBC Microcomputer used a variant of BASIC called BBC BASIC and it is described in the document. Even though, it doesn't say what does <code>Dim</code> stand for, it says (on page 104):</p> <blockquote> <p>... you can dimension N$ to have as many entries as you want. For example, DIM N$(1000) would create a string array with space for 1000 different names.</p> </blockquote> <p>As I said, it doesn't say that <code>Dim</code> stands for dimension, but serves as proof to show that associating <code>Dim</code> with <code>Dimension</code> was a common thing at the time of writing that document.</p> <p>Now, I got a rewarding surprise later on (at page 208), the title for the section that describes the DIM keyword (note: that is not listed in the contents) says:</p> <blockquote> <p>DIM dimension of an array</p> </blockquote> <p>So, I didn't get the quote "Dim stands for..." but I guess it is clear that any decent human being that is able to read those document will consider that <code>Dim</code> means dimension.</p> <hr> <p>With renewed hope, I decided to search about how <code>Dim</code> was chosen. Again, I didn't find an account on the subject, still I was able to find a definitive quote:</p> <blockquote> <p>Before you can use an array, you must define it in a DIM (dimension) statement.</p> </blockquote> <p>You can find this as part of the <a href="http://www.truebasic.com/node/1038" rel="noreferrer">True BASIC Online User's Guides</a> at the web page of True BASIC inc, a company founded by <a href="https://en.wikipedia.org/wiki/Thomas_Eugene_Kurtz" rel="noreferrer">Thomas Eugene Kurtz</a>, co-author of BASIC.</p> <hr> <p>So, In reallity, <code>Dim</code> is a shorthand for <strong><code>DIMENSION</code></strong>, and yes. That existed in FORTRAN before, so it is likely that it was picked by influence of FORTRAN as <a href="https://stackoverflow.com/a/1033533/402022">Patrick McDonald said in his answer</a>.</p> <hr> <pre><code>Dim sum as string = "this is not a chinese meal" REM example usage in VB.NET ;) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload