problem about shadowing-Collection of common programming errors


  • S.L. Barth

  • Matt Ball
    javascript shadowing
    I’ve been using jQuery and YUI side-by-side with no issues until recently. Occasionally, inside of a callback for, say, a YUI button, $ will be shadowed by some other function (click for big version):and for the life of me, I cannot figure out why this is happening. Yes, I know I could be safe and use jQuery or window.$ everywhere instead of just $, but that’s just a workaround and not an actual fix.At runtime, how can I find where this $ impostor is coming from? – e.g. find where it’s declared,

  • Dog
    erlang shadowing
    I have a simple car process implemented in Erlang:-module(cars). -compile(export_all).-record(state, {count=1}).make_car() ->spawn_link(fun() -> car_proc(#state{}) end).car_proc(S) ->receive{idle, X} ->io:format(“idling for ~p second(s)~n”, [X]),timer:sleep(X*1000);{move, {X,Y}} ->io:format(“move; x=~p, y=~p~n”, [X,Y]);{stop, Reason} ->X = S#state.count,io:format(“stopped with count ~p because ~p~n”, [X+1, Reason])end,X = S#state.count,car_proc(S#state{count=X+1}).I can make it

  • Kevin Burke
    javascript shadowing
    In the following code snippet I declare a global variable and then check for its presence inside a function.<script> x = 5; $(function() {var x = x || 3;console.log(x); // prints 3 }); </script>This behaves differently: <script> x = 5; $(function() {var y = x || 3;console.log(y); // prints 5 }); </script>I expect that in the first example, the variable declaration in the inner scope will detect that x already exists in the global scope, and take its value. Why does the fi

  • BeachRunnerFred
    javascript variables shadowing
    Consider the following piece of code: <html><head></head> <body><script type=”text/javascript”>var outside_scope = “outside scope”;function f1() {alert(outside_scope) ;}f1();</script> </body> </html>The output for this code is that the alert box displays the message “outside scope”. But, if I slightly modify the code as: <html><head></head> <body><script type=”text/javascript”>var outside_scope = “outside scope”;functi

Web site is in building