I am at loss here. A google for "fluid scoping" finds only two matches, neither of which are on line right now. Can you explain what you mean?

However in a language with side effects, dynamic scope has the effect of treating all variables as globals.

First off, I dont grok "a language with side effects". I understand a "function with side effects" or "a function with no side effects" but I dont quite see how that can be applied to a language. And when I do, it seems logical to me to posit that "a language without side effects" doesn't do anything. Can you explain this idea to me?

Why should dynamic scoping mandate only global variables? Presumably Perl is a language with side effects so how does that square with the observation that we have dynamic scoping of elements of lexical composite variables like hashes and arrays? Or is that still fluid scoping?

use Data::Dumper; $|++; my %hash=(foo=>'bar',); sub bar(){ print "(".((caller(1))[3]||'main').")\n"; print Data::Dumper->Dump([\%hash],['*hash']); } sub foo($) { local $hash{foo}="baz"; bar(); } foo bar, bar; __END__ (main) %hash = ( 'foo' => 'bar' ); (main::foo) %hash = ( 'foo' => 'baz' ); (main) %hash = ( 'foo' => 'bar' );
Im interested to hear more about this.

:-)

Incidentally my understanding is that dynamic scoping was introduced to perl to aleviate the problems of only having globals. Not that some variables had to be global so that they could be dynamically scoped.

--- demerphq
my friends call me, usually because I'm late....


In reply to Re: Re: Re: Re: Why does Perl use dynamic scoping? by demerphq
in thread Why does Perl use dynamic scoping? by blokhead

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.