[plt-scheme] Re: Text-contents to a function variable

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Wed Jan 13 19:05:45 EST 2010

> On Wed, Jan 13, 2010 at 5:27 PM, Avi <n4alpaca at gmail.com> wrote:
>> ... you
>> have restricted the inputs and outputs, and I do not want that, I  
>> just
>> want a way to plug in a letter that I defined as a number into a
>> function variable that I wrote.

On Jan 13, 2010, at 5:35 PM, Carl Eastlund wrote:

> Avi, if only some letters or words have been defined as numbers, then
> the inputs are restricted to those letters and words.

This is true regardless of how you "define some letters as numbers":  
whether you do it as Scheme variables

(define H 1)
(define AGE 30)

or with a hash table, as Carl described, or with an association-list

(define vars '(("H" 1) ("A" 30)))

or in some other way.  I think what you mean is that the set of  
"letters" that are "defined as numbers" can change during the running  
of the program; that's fine, and it's compatible with any of these  
different data representations.

But it's not necessarily a good idea to equate
(a) the Scheme variables that you, as a programmer, use, with
(b) the "letters" that you want to "define as numbers", as seen by an  
interactive user.
In fact, it's not clear what "the value" of a Scheme variable "is",  
considering that what variables are defined as what can change from  
the time you write your code to the time the user types a variable  
name into the text box, and it can change from one function to  
another.  So you're probably better off keeping YOUR variables  
completely separate from the "letters" that you present to the GUI user.

And you're probably better off starting with simpler programming  
problems, so you get comfortable with the language, before tackling a  
GUI program with variable-value tables.

Stephen Bloch
sbloch at adelphi.edu

Posted on the users mailing list.