chromatic wrote:
On Tue, 2005-07-19 at 18:47 +0200, "TSa (Thomas Sandlaß)" wrote:
I strongly agree. They should share the same namespace. Since
code objects constitute types they also share this namespace.
This means that any two lines of

class   Foo {...}
role    Foo {...}
sub     Foo {...}
method  Foo {...}
subtype Foo of Any where {...}

in the same scope should be a simple redefinition/redeclaration error.


I don't understand this.  What does a scope have to do with a namespace?

I meant a scope of source code, basically everything delimited by braces.
And that nesting of braces *is* the namespace, or not? Well, at least the
compile time view of it.

The Perl6 namespace is available at runtime as well. But it is beyond me
how much these differ. But for the specification of the language only the
source code aspect is relevant.


Why does a code object constitute a type?

Is this more a 'how do function types work' question or
are you doughting the usefullness of this concept for Perl6?

The sort function e.g. takes a parameter of type Comparator
which is a code type describing instances that accept two parameters
of the type that is to be sorted and return a value of a type
that describes the relative order implemented by the comparator.

Actually the Comparator is usually a parametric type, that is
instanciated with concrete types and thus forming a non-parametric
code type. The invokation of such a type are the instances of the
type. During a sort run many of these instances are created.


I can understand there being separate types, perhaps, for Method,
Submethod, MultiSub, MultiMethod, and so on,

... and subtypes thereof.

but I don't understand the
purpose of sharing a namespace between types and function names,

What should 'mysubtype' in the following signature

  sub blah ( mysubtype &sref )
  {
      my Int $x = sref( "Str", 23, Foo.new );
  }

mean if not a constraint of the type of &sref?
Above it is used as a function that accepts (Str, Int, Object)
and returns Int. Depending on the definition of ::mysubtype
this usage is erroneous or not. I ask myself---or @Larry---how
the same effect could be achieved without the indirection through
a name. Perhaps:

  sub blah( Code[Str, Int, Object --> Int] &sref )  {...}

The same question arises when ::subtype shall be declared:

  subtype mysubtype of Code[Str, Int, Object --> Int];

  subtype mysubtype of Code:(Str, Int, Object) returns Int;


nor of
having funcitons declare/define/denote/de-whatever types.

Here's an attempt of code joke around foo (ignore at will)

class foo
{
   submethod postfix:{'( )'} ( $x ) { say $x }
}

sub foo( &foo ) { say foo }

sub bar ( foo $foo, foo &foo )
{
   $_ = foo.new;
   my foo $f = \foo;
   my foo &f = \foo;
   my foo @f = foo;
   say foo(23);
   say .(42);
}
--
TSa (Thomas Sandlaß)

Reply via email to