Binding, iirc. You are binding a value directly instead of making a box to assign it to.
On Mon, Sep 17, 2018 at 1:47 AM ToddAndMargo <toddandma...@zoho.com> wrote: > >> On Sun, Sep 16, 2018 at 9:02 PM ToddAndMargo <toddandma...@zoho.com > >> <mailto:toddandma...@zoho.com>> wrote: > >> > >> On 09/16/2018 05:58 PM, Curt Tilmes wrote: > >> > Read this: > >> > > >> > https://perl6advent.wordpress.com/2017/12/02/perl-6-sigils-variables-and-containers/ > >> > > >> > Then go back and read it again. It took me several times, and > >> I'm still > >> > not sure I get it all :) > >> > >> I am spacing on the difference between > >> > >> my $foo = 42; and > >> my $foo := 42; > >> > >> To add insult to injury, I come from Modula2, where > >> `:=` is `=` in Perl. > >> > >> -T > > > On 9/16/18 9:06 PM, Brandon Allbery wrote: > > If you say "my $foo = 42", you are saying that $x is a box, and you are > > putting 42 into it. You can put something else into that box later. > > > > If you say "my $foo := 42", you are saying that $x is 42 itself, not a > > box containing 42. You can think of it as a constant of sorts. Because > > it's not a box, you can't change what's in the nonexistent box later. > > > > From here on it gets trickier, because there are things that can use > > the box instead of what the box contains, notably Hash elements, and > > which can then be changed by changing what's in the box directly instead > > of by changing the Hash element. > > > > Does `:=` have an official name? > > So, kind of like a constant you that can sometimes change. > > What would be the use of such? > > > $ p6 'constant t=1.414; dd t;' > 1.414 > > $ p6 'my $t := 1.414; dd $t;' > 1.414 > > $ p6 'my $t := 1.414; $t += 1; dd $t;' > Cannot assign to an immutable value > in block <unit> at -e line 1 > > $ p6 'my $t := 1.414; $t := 4.14; dd $t;' > 4.14 > > $ p6 'my $t := 1.414; say $t + 9;' > 10.414 > -- brandon s allbery kf8nh allber...@gmail.com