Re: First look: Advanced Polymorphism whitepaper

2008-05-02 Thread John M. Dlugosz
Larry Wall larry-at-wall.org |Perl 6| wrote: On Fri, May 02, 2008 at 08:30:25AM -0500, John M. Dlugosz wrote: I agree. If typing is turned on, you want errors if you pass the wrong type. You have to explicitly declare that Bar is an acceptable substitute for Foo. Maybe we already

Re: First look: Advanced Polymorphism whitepaper

2008-05-02 Thread John M. Dlugosz
Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote: Sex, 2008-05-02 às 09:08 -0500, John M. Dlugosz escreveu: A syntax is needed for this express concept: "accept B as a substitute for A", without changing A. Which I'm advocating as class CGI::Simple realises

Re: First look: Advanced Polymorphism whitepaper

2008-05-02 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: Then, since classes are open, the programmer can easily say CGI does CGI::Simple; That would be class CGI is also { does CGI::Simple } and means that CGI::Simple is a role, meant to serve as an interface specification. It's not, it is a

Re: Polymorphism and Representations

2008-05-02 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: Ohh, conceptually we should split the 'r' and 'w' in 'rw'. The r part is for the value going in. The w part is conceptually part of the *return* type of the function. The convenience for the caller lies in the fact that she doesn't have to extract

Re: First look: Advanced Polymorphism whitepaper

2008-05-02 Thread John M. Dlugosz
Ovid publiustemp-perl6language2-at-yahoo.com |Perl 6| wrote: Implemented as: method read ( --> Boolean ) { ... } (How do I specify no args and a Boolean return type?) Take your pick: our Bool method read () { ... } method read (-->Bool) { ... } method read () of Bool { ... }

Re: treatment of "isa" and inheritance

2008-05-02 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: HaloO, John M. Dlugosz wrote: Hmm, I always had the impression of strong headwind. How so? Take e.g. my supertyping proposal. I guess it was regarded as a curiosity rather than an innovative feature. Regards, TSa. Which idea was that

Re: First look: Advanced Polymorphism whitepaper

2008-05-02 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: sub graph ( &func where {.does: Continuous}, Num $from, Num $to ) {...} sub square ( Num $x --> Num ) does Continuous { return $x * $x } graph( &square, -10.0, 10.0 ); # type correct The odd thing to me is that graph cannot be defined a

Re: First look: Advanced Polymorphism whitepaper

2008-05-02 Thread John M. Dlugosz
chromatic chromatic-at-wgz.org |Perl 6| wrote: If I tell the type system that Foo and Bar are equivalent, then they're equivalent even if they have different internal structures and no other relationship in an inheritance sense. I agree. If typing is turned on, you want errors if you pa

Re: First look: Advanced Polymorphism whitepaper

2008-05-02 Thread John M. Dlugosz
Ovid publiustemp-perl6language2-at-yahoo.com |Perl 6| wrote: However, the CGI/CGI::Simple example I posted earlier doesn't fulfill this. CGI::Simple offers a subset of CGI.pm's functionality and it's guaranteed to be identical (it doesn't have HTML generation functionality and the procedural/OO

Re: First look: Advanced Polymorphism whitepaper

2008-05-01 Thread John M. Dlugosz
Jon Lang dataweaver-at-gmail.com |Perl 6| wrote: On Wed, Apr 30, 2008 at 9:58 PM, Brandon S. Allbery KF8NH <[EMAIL PROTECTED]> wrote: On May 1, 2008, at 0:53 , chromatic wrote: correctness sense. Sadly, both trees and dogs bark.) Hm, no. One's a noun, the other's a verb.

Re: First look: Advanced Polymorphism whitepaper

2008-05-01 Thread John M. Dlugosz
chromatic chromatic-at-wgz.org |Perl 6| wrote: This is why roles-as-types is so important: type inferencers can't infer allomorphism because allomorphism relies on explicitly-marked semantic meanings. What is your nomenclature here? "vary in sound without changing its meaning"? What are

Re: OK, ::?CLASS not virtual

2008-05-01 Thread John M. Dlugosz
Jon Lang dataweaver-at-gmail.com |Perl 6| wrote: John M. Dlugosz wrote: And you can use CLASS in a role also, confidant that it will be looked up according to the normal rules when the class is composed using that role, just like any other symbol that is not found when the role is defined

OK, ::?CLASS not virtual

2008-04-30 Thread John M. Dlugosz
Larry Wall larry-at-wall.org |Perl 6| wrote: I don't like using ::?CLASS for something that is not a compile-time constant. ... we don't use ::?SELF anymore, but "self", because that can vary in meaning dynamically OK, for some meaning of "constant". After all ::?LINE is different every time

Re: First look: Advanced Polymorphism whitepaper

2008-04-30 Thread John M. Dlugosz
Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote: Qua, 2008-04-30 às 08:56 -0700, Ovid escreveu: I had initially thought this, but think about the case where someone wants to rewrite something to be compliant to another interface. If I pass a CGI::Simple object to a method expecting a CGI obj

Re: treatment of "isa" and inheritance

2008-04-30 Thread John M. Dlugosz
Larry Wall larry-at-wall.org |Perl 6| wrote: On a more fundamental level, I wonder what the social ramifications are. First, to what extent is this something that will interfere with people who don't want to learn higher-order typing in order to get their job done, but will be forced to because

Re: Polymorphism and Representations

2008-04-30 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: Finally combine that with the wish to allow literals of class A. Let's assume the grammar is patched to parse integer literals as As. Then with the above 7.inc gives an error because 7 is not mutable. So as I outlined before I want to care for the

Re: treatment of "isa" and inheritance

2008-04-30 Thread John M. Dlugosz
Ovid publiustemp-perl6language2-at-yahoo.com |Perl 6| wrote: So, isn't "isa" and the "£" merely things which can be added by programmers by changing the grammar? That was one of the design goals of the language. The capability needs to exist as part of the overall type system, with primitiv

Re: treatment of "isa" and inheritance

2008-04-30 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: HaloO, John M. Dlugosz wrote: "isa" as a synonym for "is" that turns on warnings is documented at the end of my paper under "Concepts discussed in this paper that are not on the Synopses". I totally agree!

Re: Pragma for type matching alternative implementations

2008-04-30 Thread John M. Dlugosz
Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote: Very interesting reading... :) It actually made me think that it would be possible to implement it as a pragma. class A { has $.a }; class B { has $.b }; sub foo { A $a } { ... } [sic, should be () around parameters] { foo(B.n

Re: treatment of "isa" and inheritance

2008-04-30 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: HaloO John, interesting to note that you are now nailing down things that I'm advocating for quite a while. Are you sure that Perlkind is following? E.g. $Larry hasn't written 'isa' into S12 yet. Regards, TSa. I am listening. I'm synthesizing an

Re: treatment of "isa" and inheritance

2008-04-30 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: HaloO, just to deepen your understanding of co- and contravariance you should digest The important point to get from it is that dispatch-relevant parameters are also covariant. Regards, TSa. T

treatment of "isa" and inheritance

2008-04-29 Thread John M. Dlugosz
In response to questions on my whitepaper, I made this companion to bring people up to speed on the issue. "Think you know what “polymorphism” means? Well, the Object-Oriented textbooks have been keeping a dirty little secret from you. Pol

Re: Polymorphism and Representations (Was: Re: First look: Advanced Polymorphism whitepaper)

2008-04-29 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: multi infix:<=> (Any $lhs, A $rhs) { $lhs.STORE($rhs.clone); # or .cow if that's not automatic } $lhs.VAR.STORE. My readings have been that = just copies the ref. Unless it's a "value type" or "immutable" which just means

Re: Polymorphism and Representations (Was: Re: First look: Advanced Polymorphism whitepaper)

2008-04-29 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: HaloO, Daniel Ruoso wrote: Not really... 'does' is a composition operation, 'realises' would be just a type annotation that doesn't change the actual composition. OK, but that is not in the spec yet. To me that is like the proposed 'like' opera

Re: Polymorphism and Representations

2008-04-29 Thread John M. Dlugosz
Hmm, I'm not seeing the message from Daniel, just this reply. I like the idea of having a class method primitive to provide some functionality. But type matching is more complex, as you can list multiple types juxtaposed. sub foo (A B £ C ::T $param) and the actual match means does A, do

Re: First look: Advanced Polymorphism whitepaper

2008-04-28 Thread John M. Dlugosz
Jon Lang dataweaver-at-gmail.com |Perl 6| wrote: John M. Dlugosz wrote: I think I see another whitepaper in my immediate future. I look forward to it. I'll put a link to it on <http://www.dlugosz.com/Perl6/>, perhaps even before I'm finished with it. --John

Re: First look: Advanced Polymorphism whitepaper

2008-04-28 Thread John M. Dlugosz
Jon Lang dataweaver-at-gmail.com |Perl 6| wrote: Perhaps it would be clearer if you could illustrate the difference between sub bendit (£ IBend ::T $p -->T) { T $q = get_something; my T $result= $p.merge($q); return $result; } and sub bendit (IBend ::T $p -->T)

Re: First look: Advanced Polymorphism whitepaper

2008-04-28 Thread John M. Dlugosz
chromatic chromatic-at-wgz.org |Perl 6| wrote: That was always my goal for roles in the first place. I'll be a little sad if Perl 6 requires an explicit notation to behave correctly here -- that is, if the default check is for subtyping, not polymorphic equivalence. -- c Perhaps the def

Re: First look: Advanced Polymorphism whitepaper

2008-04-28 Thread John M. Dlugosz
Jon Lang dataweaver-at-gmail.com |Perl 6| wrote: Ah; that clears things up considerably. If I understand you correctly, John is using '£' to mean "use Duck Typing here". _That_, I can definitely see uses for. As well, spelling it as 'like' instead of '£' is _much_ more readable. With this in

Re: First look: Advanced Polymorphism whitepaper

2008-04-28 Thread John M. Dlugosz
Andy_Bach-at-wiwb.uscourts.gov |Perl 6| wrote: Just an even simpler question: sub bendit (£ IBend ::T $p -->T) { T $q = get_something; Does the "T ..." usage then scope the var so no 'my/our' is needed? a --- Andy Bach Systems Mangler Internet: [EMAIL PROTECTED] Voice

Re: First look: Advanced Polymorphism whitepaper

2008-04-28 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: HaloO, Jon Lang wrote: I'm having some difficulty understanding the business with £. I _think_ that you're saying that £ sort of acts as a prefix operator that changes the meaning of the type with which it is associated; and the only time that a

Re: First look: Advanced Polymorphism whitepaper

2008-04-28 Thread John M. Dlugosz
Jon Lang dataweaver-at-gmail.com |Perl 6| wrote: I'm having some difficulty understanding the business with £. I _think_ that you're saying that £ sort of acts as a prefix operator that changes the meaning of the type with which it is associated; and the only time that a change in meaning occurs

Re: First look: Advanced Polymorphism whitepaper

2008-04-28 Thread John M. Dlugosz
Ovid publiustemp-perl6language2-at-yahoo.com |Perl 6| wrote: This might not be too big a deal, but the formatting of the code is a bit odd. It's not monospaced and the indentation and brace placement seem very arbitrary. Since these items are always "code smells" to me of a bad programmer[1], s

First look: Advanced Polymorphism whitepaper

2008-04-27 Thread John M. Dlugosz
Here is a first look at the ideas I've worked up concerning the Perl 6 type system. It's an overview of the issues and usage of higher-order types in comparison with traditional subtyping subclasses. http://www.dlugosz.com/Perl6/ --John

Re: given vs for

2008-04-25 Thread John M. Dlugosz
Larry Wall larry-at-wall.org |Perl 6| wrote: However, &foo doesn't mean what it means in Perl 5. It's just the function as a noun rather than a verb. Larry A gerund.

Re: given vs for

2008-04-25 Thread John M. Dlugosz
Dave Whipp dave-at-whipp.name |Perl 6| wrote: Does perl6 still have some implicit mechanism to say "call sub using current arglist"? (No, I'm not arguing to support any of this: just asking the questions) Yes. You can use 'callsame' and it knows the current argument list. You can get a

Infinite (WAS Re: Decrement of Numbers in Strings)

2008-04-25 Thread John M. Dlugosz
Larry Wall larry-at-wall.org |Perl 6| wrote: Inf is just a special value that you can use in a signature, so multiple dispatch already can handle that. My muse took a liking to that. The Inf values are not treated much in the synopses. It never says that Inf is something that MMD can se

Re: given vs for

2008-04-25 Thread John M. Dlugosz
Dave Whipp dave-at-whipp.name |Perl 6| wrote: Mark J. Reed wrote: So eseentially, given (@foo) means the same as Perl5 for ([EMAIL PROTECTED]) Just wondering: should "given @foo {...}" alias to $_, or @_? $_. It will contain the whole list as one item, like what Perl 5 does with [E

Re: given vs for

2008-04-25 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: HaloO, John M. Dlugosz wrote: for @foo {...} is actually short for: for @foo <-> $_ {...} Ups, I missed that one. Do we also have the fill-me idiom for @foo <- $_ {...} No. There is no concept of output parameters.

Re: Decrement of Numbers in Strings (Was: [svn:perl6-synopsis] r14460 - doc/trunk/design/syn)

2008-04-25 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: sub incr (Any $x is rw) { if $x.VAR.WHAT ~~ Str {...} # "-100" -> "-101" else {...} # "-100" -> "-99" } This doesn't work because $x.VAR accesses the inner container and that has constraint Any which effec

Re: given vs for

2008-04-25 Thread John M. Dlugosz
Trey Harris trey-at-lopsa.org |Perl 6| wrote: In 5.10, given seems to copy its argument, whereas for aliases it. (I haven't looked at the code; maybe it's COW-ing it.) If you add a C to the end of the below program, and then change C to C and run the program with values of $foo less than 5

Re: given vs for

2008-04-25 Thread John M. Dlugosz
Moritz Lenz moritz-at-casella.verplant.org |Perl 6| wrote: Paul Fenwick perltraining.com.au> writes: for ($foo) { when ($_ < 500) { ++$_ } when ($_ > 1000) { --$_ } default { say "Just right $_" } } Ahh... that's exactly what I was looking for. T

Re: Decrement of Numbers in Strings (Was: [svn:perl6-synopsis] r14460 - doc/trunk/design/syn)

2008-04-24 Thread John M. Dlugosz
smuj smuj-at-iol.ie |Perl 6| wrote: Do we still get to keep the current semantics if we specificially declare a string? e.g. my Str $x = "-100"; $x++; say $x; # prints -101 my $y = "-100"; $y++; say $y; # prints -99 Cheers, smuj I'd vote for that. As well as a hand full of adjectives.

Re: Decrement of Numbers in Strings (Was: [svn:perl6-synopsis] r14460 - doc/trunk/design/syn)

2008-04-24 Thread John M. Dlugosz
Larry Wall larry-at-wall.org |Perl 6| wrote: The initializer needs to go =inside= the signature. I think you meant to write (my int8 ($x, $y)) «=« 127; It should already parse that way. scope_declarator is a noun, and nouns may be used on the left side of an infix operator. When

Re: Decrement of Numbers in Strings (Was: [svn:perl6-synopsis] r14460 - doc/trunk/design/syn)

2008-04-24 Thread John M. Dlugosz
Larry Wall larry-at-wall.org |Perl 6| wrote: Neither, probably. You'd get an undef of type Num. Which might or might not convert to NaN or 0 under various circumstances. The orthodox documentation has Failure being undef that throws an exception if you try and get a value from it. Nothing

Re: Decrement of Numbers in Strings (Was: [svn:perl6-synopsis] r14460 - doc/trunk/design/syn)

2008-04-24 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: Hmm? I meant Num ∩ Str. This intersection type is a subtype of Str and Num without type coercion and it beats both in specificity when it comes to dispatch. There are methods in Str that are not in Num, and vice versa. A variable declared as Num

Re: Decrement of Numbers in Strings (Was: [svn:perl6-synopsis] r14460 - doc/trunk/design/syn)

2008-04-24 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: ... Is it defined that non-numeric strings map to NaN or to zero? Zero. But I think in Perl 6 we're leaning more toward preserving information than Perl 5 did. This information being the length of the string I presume. People have been

Re: Decrement of Numbers in Strings (Was: [svn:perl6-synopsis] r14460 - doc/trunk/design/syn)

2008-04-24 Thread John M. Dlugosz
Ph. Marek philipp.marek-at-bmlv.gv.at |Perl 6| wrote: I think that's a can of work, and I'd be +1 on TSa: If the programmer really wants to decrement "10" to "09" she has to cast that to Str: ("10" as Str)--. So we have "10".HOW === Str but "10".WHAT === Num Str. It's behaving as Num

Re: Class names are virtual

2008-04-22 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: For functions, types don't need to be treated specially from other arguments as in C++. Could you give an example of what you mean in C++ and how Perl differs from that? In C++, types are not first-class objects. You can't pass a type as a

Re: Class names are virtual

2008-04-22 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: HaloO, John M. Dlugosz wrote: They are mixed! Perl treats types as first-class objects. For functions, types don't need to be treated specially from other arguments as in C++. Looks like we need a third party ruling on that. Note tha

Re: Class names are virtual

2008-04-22 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: The point I want to make is that we cannot think of P::C and M::C as unrelated! There are the following typical uses of C in D: 1) as the type of the attribute $.a 2) as return type of m 3) as type of the local variable $b Within the body

Roles!

2008-04-22 Thread John M. Dlugosz
I finished the first draft of a technical description for compositing roles. It runs to 7 pages. Please see §16 in specdoc. -whew!- --John http://www.dlugosz.com/files/specdoc.odt and .pdf

2 questions on S12

2008-04-21 Thread John M. Dlugosz
Question 1: What is meant by: has $attribute # lexical alias for $!attribute. Here is more concrete example. There is none in S12. class C { has $a; method foo () { my $y = $a; # is the correct? } In that scope, is $a really a shortcut for $self!a ? If so,

Re: Context and return types question

2008-04-21 Thread John M. Dlugosz
Brandon S. Allbery KF8NH allbery-at-ece.cmu.edu |Perl 6| wrote: my ($x, :$named) = foo; # or something like that That looks to me like a form of positional extraction. (Of course, my hit rate on p6 stuff has been remarkably low of late...) It's not just positional, but allows fo

Re: Class names are virtual

2008-04-21 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: Second, I don't like the concept of a virtual method that returns a type. That horribly mixes type level and value level. From the They are mixed! Perl treats types as first-class objects. For functions, types don't need to be treated specia

Re: method hiding (or not) in derived classes

2008-04-21 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: "Candidate set" would be a better term. It is a subset of all long names of a multi in a lexical scope. List, not set, because it is ordered. nextsame/nextwith/etc. are described as invoking the next candidate on the list. Therefore, there is

Re: Context and return types question

2008-04-21 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: I guess with strong you mean as lossless as possible? I think the type is just :( $: :named$ ) if you want to extract the invocant with a $ prefix. Otherwise it would be :( $, :named$ ) and you extract the item positionally with prefix @ or .[].

Re: use of ::?CLASS

2008-04-21 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: You are right and I didn't address this, sorry. Actually the only solution I see is dropping the ::? twigil altogether and specify that CLASS is lexically declared by the compiler. Otherwise we have to make a special case exception out of ::? vari

Re: progress report

2008-04-20 Thread John M. Dlugosz
whiteringmoon-at-gmail.com |Perl 6| wrote: I stumbled onto this group as I was looking for language statisics and I tried understanding what I am looking at. What is Perl? I don't mean to sound stupid in asking this. But could you explain what it is that I am looking at here? WR See

Class names are virtual

2008-04-20 Thread John M. Dlugosz
Larry, you've wanted to have class names used within a class be virtual. With various degrees of conviction across the synopses, you've wanted classes defined within a class to be overridable, or all classes referenced by a class to be overridable, speculating on whether this is do-able. I'v

progress report

2008-04-20 Thread John M. Dlugosz
I've identified a few more issues while refactoring the text across all the synopses, but I'm just noting everything in my document. Not enough discussion going on to post them all. My main creative effort is in studying type systems, and musing over what it would be like to have Perl 6's typ

Critisizms on postcircumfix:<( )>

2008-04-19 Thread John M. Dlugosz
I think the idea of "The expected semantics of &.() is that of a type coercion..." confuses the notion of function call and conversion. If anything other than a Code object has one, it is acting as a functor, or function-like object. The meaning of Dog(args) is seemingly a class method anyway,

method hiding (or not) in derived classes

2008-04-19 Thread John M. Dlugosz
Perl 6 has a concept of a "candidate list". The candidate list are those that could handle the call, typically inherited methods and multi variations. It seems that multi variations, at least with respect to the semicolon parameters, compare the actual type and drop out of the list if any don

Re: S12 delegation ("handles" trait)

2008-04-18 Thread John M. Dlugosz
Dave Whipp dave-at-whipp.name |Perl 6| wrote: > > Since the method name (but nothing else) is known at class > construction time, the following .wag method is autogenerated for you: > >method wag (|$args) { $!tail.wag(|$args) } ... Another thing that might be nice (maybe not a perl 6.0.0 f

Re: Context and return types question

2008-04-18 Thread John M. Dlugosz
quot; type) to be strongly typed? --John Larry Wall larry-at-wall.org |Perl 6| wrote: On Fri, Apr 18, 2008 at 05:34:25AM -0500, John M. Dlugosz wrote: If a function returns different things if called in list context or item context, how do you define the "of" type (outer retu

Re: Context and return types question

2008-04-18 Thread John M. Dlugosz
If a function returns different things if called in list context or item context, how do you define the "of" type (outer return type) to make the function strongly typed? How about sub foo (--> Seq^Item) {...}? Interesting idea, but that doesn't tell the compiler that the return is keyed t

Re: Does STD.pm handle this?

2008-04-18 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: sub foo ($x) {...} $x = &foo.new(3); I don't understand your point. Are you thinking of .callwith or postcircumfix<( )> methods on the Code object? No, I think of foo not as a Code object but as a class that does Code. Invoking foo mea

Re: use of ::?CLASS

2008-04-18 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: Sorry, I see no contradiction. Method doit *is* a parametric type. That is you need a type argument to make a code type. And then you need args to make an invocation. Now the question is who provides the type argument and when. An explicit instanc

Context and return types question

2008-04-18 Thread John M. Dlugosz
If a function returns different things if called in list context or item context, how do you define the "of" type (outer return type) to make the function strongly typed?

Generics, Take 2

2008-04-18 Thread John M. Dlugosz
The current intent in the Synopses is that using the :: sigil in a declaration makes it a generic type parameter and declares that name there. As a minimal fix to make that work, refine it to say that use of :: as a sigil in a declaration on a name that contains only a single identifier (no ::

use of ::?CLASS

2008-04-17 Thread John M. Dlugosz
OK, what is the proper use of ::?CLASS ? Say in a role you want to take an argument of the same class as the final class, or explicitly declare $self. S12 gives an example: method doit (::?CLASS $self: $a, $b, $c) { ... } but this CONTRADICTS the idea that using the :: sigil in a declaration

Re: Generic Parameter Proposal

2008-04-17 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: Which is no problem if ::T defines it in the lexical scope. Any outer definition is hidden. I guess re-using ::T in the same scope again for capturing a new type is an error. Just like redeclaring a value variable. BTW is You appear to be saying t

Re: Does STD.pm handle this?

2008-04-17 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: I guess not. But ::Newname ::= OldTypeName; should work. The type system is a runtime overlay to the value system. This is reflected in the source by putting types and values into different syntactic slots. You cannot mix these! But Newname

Re: Returning Arrays?

2008-04-17 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: HaloO, John M. Dlugosz wrote: Variance? Yeah, the standard set of co-, contra-, in- and bivariance ;) Assume A <: B being subtypes. Then how should Foo[A] and Foo[B] relate? Foo[A] <: Foo[B] # covariance Foo[B] &l

Re: Chained Comparisons ?

2008-04-17 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: Why the complicated sig? Note that the left sequential definition enforces that ($a + $b) + $c dispatches to a version of + with the return type of the lhs addition. That is you need lots of overloaded versions of listfix +. Nonetheless I would li

Does STD.pm handle this?

2008-04-17 Thread John M. Dlugosz
sub GetType (-->Type) { ... } my ::RunTimeType := GetType; This is clearly permitted by the prose, that " ::x may be bound to any object that does the Abstraction role, such as a typename, package, module, class, role, grammar, or any other protoobject with .HOW hooks." But the syntax might t

Desk check this code please

2008-04-16 Thread John M. Dlugosz
Is this code syntactically and conceptually correct? method postfix:<++> (-->::?CLASS) is export { my ::?CLASS $temp = self; self =. successor; return $temp; } method prefix:<++> (-->::?CLASS) is export is rw { self =.successor; return self; } In particular, are pre/postf

Generic Parameter Proposal

2008-04-16 Thread John M. Dlugosz
First, consider the stated examples for Generic type parameters, from the passage which defines the terminology in S02: sub max (Num ::X @array) { push @array, X.new(); } sub compare (Any ::T $x, T $y) { return $x eqv $y; }

Re: Chained Comparisons ?

2008-04-16 Thread John M. Dlugosz
Larry Wall larry-at-wall.org |Perl 6| wrote: Well, that's more or less how Icon does it, but we're not going to expose anything like that to the user. If we assume that comparisons take two immutable objects, we can leave it to the compiler to compute the actual value once, and then feed it to b

Re: Chained Comparisons ?

2008-04-16 Thread John M. Dlugosz
Patrick R. Michaud pmichaud-at-pobox.com |Perl 6| wrote: It applies to any operator that has 'chain' associativity -- see S06, "Subroutine traits". If I want to make my own chained operator, perhaps the curvy ≼, ≽, etc. or make my operator ≧ a synonym for >=, how would I tell the compiler t

Re: Returning Arrays?

2008-04-16 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: HaloO, John M. Dlugosz wrote: I seem to recall seeing sigils in a signature without names, but now I can't remember where. E.g. in S06 und section "The want function". Regards, TSa. Somewhere else, I think it discussed unname

Re: Returning Arrays?

2008-04-16 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: HaloO, John M. Dlugosz wrote: How do you declare a function that returns an array? Something like sub foo (blah) is Array of X { ... } I meant "of", not "is". In general the of keyword instanciates parametric

Re: static types, checking, conversions

2008-04-16 Thread John M. Dlugosz
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote: I found two dissertations and a couple of papers about typing JavaScript. The quintessential is that optional typing is defined as having *no* impact on the dynamic behavior of the program. In that respect type annotations are like comments. I do

Returning Arrays?

2008-04-16 Thread John M. Dlugosz
How do you declare a function that returns an array? Something like sub foo (blah) is Array of X { ... } seems right, but it has two problems. First is a real problem, and is a mistake seen a lot in C# and the .NET framework. A concrete type is used when it should be an interface. What

Re: static types, checking, conversions

2008-04-16 Thread John M. Dlugosz
Thom Boyer thom-at-boyers.org |Perl 6| wrote: Mark J. Reed wrote: It would behoove @Larry to examine the optional type constraints system proposed for Javascript:TNG (see link from firefox.com developers page). I therefore assume that they have done so, but others would benefit by doing likewis

Chained Comparisons ?

2008-04-16 Thread John M. Dlugosz
I know how comparisons are chained in Perl 6. There is a very short section on it in S03. So, are the operators infix:{'<'} etc. written in the normal way to take two arguments? Then the language transforms A op B op C into A op B AND B op C on an innate level. Does that apply to any user-de

What does this mean in S03?

2008-04-15 Thread John M. Dlugosz
"Strings, arrays, lists, sequences, captures, and tree nodes can all be pattern matched by regexes or by signatures more or less interchangably." How can captures me matched by regexes? Does this mean that there is really an isomorphism between Signatures and Regexes?

shape trait and Hash

2008-04-15 Thread John M. Dlugosz
In S02 it is writ, "The key type of a hash may be specified as a shape trait--see S09." However, S09 is rather brief on hashes, and although it shows using a type inside the curlies, it never talks about shape traits or anything else. Am I do understand that it pretty much does all the same stu

static types, checking, conversions

2008-04-14 Thread John M. Dlugosz
I posted my thoughts as a sort of white paper here: http://www.dlugosz.com/files/static-type.pdf This needs to be fleshed out. Decisions need to be made. Anyone want to discuss it with me? --John

Re: Idea: infer types of constants

2008-04-14 Thread John M. Dlugosz
Mark J. Reed markjreed-at-mail.com |Perl 6| wrote: On Mon, Apr 14, 2008 at 2:32 PM, Jonathan Worthington my Dog $fifi .= new(); # works in Rakudo too ;-) And even in Pugs! :) Doesn't help with literals, though, e.g. my Float $approx_pi = 3.14; So the idea of marking the use of

Re: Idea: infir types of constants

2008-04-14 Thread John M. Dlugosz
To me the foo looks like a template sub and I wonder how it is instanciated with different types. Since type parameters are provided with [] it should be foo[Int], foo[Str] and the like. I wonder further if that could also be written foo of Str like with Array of Int etc. my foo of Int &intfo

Re: cross operator and empty list

2008-04-14 Thread John M. Dlugosz
Doug McNutt douglist-at-macnauchtan.com |Perl 6| wrote: At 09:58 -0700 4/14/08, Larry Wall wrote: By the way, you don't need to put parens around the arguments to X. It takes a list on either side. We made it tall so that it would stand out visually anyway: $a,$b,$c X $x,$y,$z H

context vs context

2008-04-13 Thread John M. Dlugosz
The term "context" is used for two different purposes. I don't like that. The context can refer to "list context", "item context" etc. The context can also refer to the dynamic calling chain, which are Context objects navigated by the context function.

the nature of 'temp'

2008-04-13 Thread John M. Dlugosz
Does 'temp' operate on the value or on the container? The text starts, "The temp macro temporarily replaces the value of an existing variable..." and the description seems consistent with that. temp $*foo = 'foo'; The restore feature is generated by calling VAR($*foo).TEMP, and the method

Help understanding syntax in S06 "Pairs as lvalues"

2008-04-13 Thread John M. Dlugosz
:(:who($name), :why($reason)) := (why => $because, who => "me"); What do the symbols $name and $reason refer to? Are they names already in scope? "Alternately, the my declarator can also force treatment of its argument as a signature." That would be my (:who($name), :why($reason)) := (why =

Re: Clarify "Design by Contract"

2008-04-13 Thread John M. Dlugosz
Moritz Lenz moritz-at-casella.verplant.org |Perl 6| wrote: This is described in depth in "Object oriented software construction" by Bertrand Meyer. OK, reading about it in Wiki, I see what it's supposed to do. PRE - derived classes may weaken but not strengthen. So if it fails, but the p

Re: Idea: infir types of constants

2008-04-13 Thread John M. Dlugosz
I'm thinking that if strong typing is enabled, mixing untyped and typed things will cause warnings or errors that need not be there. I'm thinking that 'constant' is more special than other variables, and that the formal description of strong typing and static types should say that the compiler

A TEMP block?

2008-04-13 Thread John M. Dlugosz
S06 "Temporization", along with 'temp' variables, defines a TEMP block. Do we really need such a thing? It appears to be a LEAVE block with another level of indirection. Hmm, that is, the body of the TEMP block executes at its normal place at run-time, unlike the episodic blocks it resembles;

Idea: infir types of constants

2008-04-12 Thread John M. Dlugosz
Just surfing, I noticed something about the "D" programming language: " The types of constants need not be specified explicitly as the compiler infers their types from the right-hand sides of assignments. const fact_7 = Factorial!(7); " Now in

'returns' vs 'of'

2008-04-12 Thread John M. Dlugosz
I don't like the assignments of 'returns' and 'of'. I think it is easily confused. I've written foo (Int $x) returns Int in examples and nobody noticed. As formal documentation, that scans right as the outer perceived return value type. But no, it's supposed to be foo (Int $x) of Int inst

<    1   2   3   4   >