Question on variable binding and assignment
- From: "doug" <doug_arro@xxxxxxxxx>
- Date: 9 May 2006 22:47:27 -0700
My Java for dummies book didn't tell me this stuff. Hope that will
explain where I start when I ask
questions like this. I probably don't even understand what I am
asking.
First, let me quote Touretzky: "the process of creating a new variable
and giving it a value is
called binding...but *bound* doesn't necessarily mean *has a value* for
dynamically scoped
variables". So my first question is that is "giving it a value" the
same as assignment or not?
And why?
Please allow me to expand my question a little further. I am amazed to
read statements like
"Lisp programs don't have to use assignments". Sorry that I have to
resort to other languages
instead of CL in my examples even though I am really trying to learn
the concept in CL.
So, for a statically typed language such as Java, the following code:
int x = 1;
would bind symbol x to a storage area in a computer cell and assign it
to 1. Correct?
Then for a dynamically typed language such as Perl, the following code:
x =1
would bind symbol x to a storage area in a computer cell and assign it
to 1. Correct again?
So what is the practical difference here except one has to declare the
type for "x" in Java?
Is that because in Perl, the variable x can later be assigned to, say,
a character string? But
is that all? If we always assign values to a variable, then what is
the practical use of
an "unbound" variable in a dynamically typed programming language? Why
creating such a
concept of "unbound variables" in a programming language in the first
place?
Well, just thinking aloud here. I saw some interesting examples in Oz
where unbound variables
were used to illustrate the concept of dataflow variables in concurrent
programming. But is
an "unbound variable" totally useless in a non-concurrent program?
I appologize for stating my questions in such a disjoint way. One
problem for being an average-
talented student is that at times like this I know I am confused but
don't know exactly where I am
confused. Sigh...
Doug
.
- Follow-Ups:
- Re: Question on variable binding and assignment
- From: Pascal Costanza
- Re: Question on variable binding and assignment
- From: David Sletten
- Re: Question on variable binding and assignment
- Prev by Date: Re: Lisp group on Last.fm
- Next by Date: Re: Question on variable binding and assignment
- Previous by thread: persisting a hashmap
- Next by thread: Re: Question on variable binding and assignment
- Index(es):
Relevant Pages
|