Thomas Sandlaß skribis 2005-04-04 18:50 (+0200):
> In particular what does &infix<=><Scalar of Ref of Ref of Int,Int> do?

Depends. What does it mean? :)

Specifically, what is &infix, what is <=>?

> 'Scalar of Ref of Any' without dispatching to 'Ref of Int'. That means

References and aliasing should have nothing to do with types, except for
checking. That is, even my Scalar $foo := my Int $bar should let $foo
=:= $bar and \$foo == \$bar.

> 1) Is the referene creation done with \, := and implicit in scalar context?

A reference points to a variable the same way a name does. Only the
level at which these exists is different, but that brings along a lot of
different thinking.

A name is visible in the source, a reference is an unmentioned value.

The difference between

    my $foo = \$bar;  #1

and

    my $foo := $bar;  #2

is that in #1, $$foo =:= $bar, and in #2, $foo =:= $bar (assuming =:=
does NOT autoderefence, and this again makes clear why that'd be a bad
idea). In English: in #1, the value of $foo is a reference that points
to the container that is known as $bar, and in #2, $foo itself is the
same thing as $bar, with both names pointing to the same container.

>    Or do \ and := differ? And what's different with ::=?

They differ.

::= is like :=, but at compile time rather than runtime. I'm not sure
what the benefit of this is, but I imagine it speeds things up and saves
a few BEGIN blocks.

> 2) Is derefencing still done with $ chains where you have to know how far
>    to go? Is $$$$$$$foo still valid Perl 6 syntax?

I should hope so!

> Here is another attempt to pose my question with -> depicting an
> indirection.  After the declarations with my we have two chains:

I don't understand how your chains relate to the code you posted before.

> >I certainly hope we still have mutable values by design and
> In my head "mutable value" and "constant variable" sound funny.

Well, in Perl, values and variables have always been exactly the same
thing. That is, $foo is as much a scalar as the thing that is created
for the number 3. The big difference is that "variables" are mutable and
"literal values" are read-only. I would like to avoid the word
"constant" because that, in Perl 5 jargon, is an inlineable subroutine.

We're used to calling scalars that have a name or are explicitly
referenced "variables", and scalars that just are there, like what
subroutines return or what is in source code literally, "values". But in
fact, the value is somewhere INSIDE the scalar.

    $foo = $bar;   # copies $bar's value to $foo's value
    $foo = \$bar;  # creates a reference to $bar's scalar and stores it
                   # in $foo's value
    $foo = 3;      # copies 3's value (the integer three) to $foo's
                   # value
    $foo = \3;     # creates a reference to 3's scalar and stores it in
                   # $foo's value

After $foo = \3, $$foo is immutable because 3 is immutable. However,
after $bar = 3, $bar is mutable because not the variable 3, but only its
value was copied. The read-only flag, which is part of the scalar, is
left out of the copying process.

(Note that for simplicity's sake, I'm talking of value as a single
thing, while in Perl (at least Perl 5), a scalar can have several values
all at once, the best known being dualvars: string and number. A
scalar's value can be string, number, reference, glob or undef. (Should
you really care, then note that undef itself is a special scalar, which,
would you take away its readonly flag, would just as easily hold the
string "forty-two".))

> Once again \$foo != \$bar just means a dispatch to &infix:«!=»<Ref,Ref>
> which might need to be different for PerlRef and PythonRef if the latter
> exists at all. 

I hope variables have the semantics of the language they're used in, and
values are copied to another interpreter's variables as needed.
Otherwise in order to use a library written in, for example, Python, you
would have to know how variables work in that language. Bluntly put,
that'd suck.


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html

Reply via email to