Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the difference between 'deep' and 'shallow' binding?

 
chad stevens
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.
I would like to know the difference between what is deep binding and shallowing binding. There is also dynamic binding.
CHAD
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have never heard of deep and shallow binding. Where do you have these terms from?
 
Chinmay Bajikar
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have heard of deep and shallow copying...
do u want that?
thanks,
Chinmay........
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way that I understand it is that in some languages you are allowed to have methods imbedded in other methods or method used as a parameter to a method call. In such cases if the "inner method" or function uses the same variable values as the calling method, then you have deep binding, if the outer methods scope does not encompase the inner method then you have shallow binding.
Since Java does not allow this is it not an issue.
However, if you COULD do that and your outer method had a variable that hides a static variable, when you are in your inner method a language with deep binding would use the outer classes understanding of the variable. A language with shallow binding would use the static variable itself.
(This is based on a rather sketchy understanding).
Found a quote from [url=http://xarch.tu-graz.ac.at/autocad/lisp/FAQ-link/msg00644.html[/url]
>There is a tradeoff between shallow and deep binding. Shallow binding
>makes dynamically bound variables faster at the expense of making
>stack switching slower, deep binding makes stack switching faster, but
>slows down lookup of dynamic variables.

[ January 16, 2003: Message edited by: Cindy Glass ]
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Cindy,
you are right. i tried to Google on this topic and found that this binding stuff is mainly related to LISP etc (and little to Perl)...
its confusing. its so confusing.
i am still unclear but i don't want to know exactly as most languages like C , java doesnt have it...and i 'm not seeing myself doing LISP
regards
maulin
 
chad stevens
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow. Cindy that was a hell of a response that did confuse me too, but very informative I must say. It was an phone interview question and they also did ask about shallow copy and deep copy which I imagine are not the same thing.
Thanks to all for the explanation.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well shallow copying is much more simple.
If you copy an array (or whatever) and just copy the references, but both the new array and the original actually point to the SAME objects - then that is a shallow copy.
If you copy the array AND make copies of all of the objects that are being referenced - then that is a deep copy.
 
chad stevens
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cindy, thanks again for the short and to the point definition, I suppose it's the same as in C++. That makes sense, the binding question was another thing, they had asked me on a phone interview and I just said I didn't know. I guess that was the best thing!
 
Igor Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably it's about class loading.
In C/C++ if somethere exists call of some
function, in the linkage the
code of the function (obj) must exists.
In Java it depends of JVM, as I know in Sun JVM
the JVM doesn't load all classes at the begins
(before any executing), so it can be that at the
middle of execution - JVM found that program
use some class, that doesn't exist at all...
Probably deep binding should check that all
classes exists (and probably load they all before
execution.
(really in the Java can't be
full deep binding - loader can check all, but not
dynamic class loading - Class.forName( ))
 
boyet silverio
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
encountered a term called 'binding' in some java-corba reference (whose name i am still trying to remember and look for)
anyway, it sort of refers to the 'binding' of an object reference with a 'name' (which could be a String) in a corba naming service. this service stores object references and when objects are stored, a name must be provided that is unique within the naming service. So when a an app (e.g. java app) wants to get such an object from the naming service, it could just submit the 'name' and it will be given the object (if such a 'name' is 'binding' to an object). I don't know however, how this 'binding' could be made shallower or deeper.
hope this relates somehow.
 
chad stevens
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Boyet.
The only time I came across strings and binding was using JNDI, contexts and lookups. Frankly, I don't know if they do have anything to do with binding, but I will try to look up some stuff. Thanks.
 
Igor Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the Java spec no used word "bind" in the
part about I wrote recently - used word "resolve"
(12.1.2 Link Test: Verify, Prepare, (Optionally) Resolve)
So I don't know means of "binding" in the context.
;-)
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If Java would have had deep binding implemented, the following code snippet would have printed "deep"; of course what it actually does is printing "shallow".

kind regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic