Re: r31043 -[S32/Containers] Buf does Stringy, too

2010-06-02 Thread Jason Switzer
On Wed, Jun 2, 2010 at 5:10 AM, pugs-comm...@feather.perl6.nl wrote:

 Author: masak
 Date: 2010-06-02 12:10:22 +0200 (Wed, 02 Jun 2010)
 New Revision: 31043

 Modified:
   docs/Perl6/Spec/S32-setting-library/Containers.pod
 Log:
 [S32/Containers] Buf does Stringy, too

 -class Buf does Positional {...}
 +class Buf does Positional does Stringy {...}


I never really thought about this, but now that I see it here, it made me
realize that how 'does' works seems verbose. I think we should be able to
specify a list instead of a bunch of 'does' statements. For example, the
above example should be written as

class Buf does Positional, Stringy { ... }

The repetitive 'does' statements is about as annoying as how you have to
specify public/private inheritance scoping for each class in C++. Even Java
gets this right:

http://en.wikipedia.org/wiki/Interface_(Java)#Defining_an_interface

Just an idea.

-Jason s1n Switzer


Re: r31043 -[S32/Containers] Buf does Stringy, too

2010-06-02 Thread Aaron Sherman
On Wed, Jun 2, 2010 at 2:59 PM, Jason Switzer jswit...@gmail.com wrote:

 On Wed, Jun 2, 2010 at 5:10 AM, pugs-comm...@feather.perl6.nl wrote:

 
  -class Buf does Positional {...}
  +class Buf does Positional does Stringy {...}
 

 I never really thought about this, but now that I see it here, it made me
 realize that how 'does' works seems verbose. I think we should be able to
 specify a list instead of a bunch of 'does' statements. For example, the
 above example should be written as

 class Buf does Positional, Stringy { ... }


Pro:
* Shorter can be good
* It's pretty clear what's going on.

Con:
* Composition is complicated. Explicit does foo calls that out
* Something like:

  class Buf
does Positional
does Stringy
  { ... }

... looks to me like a laundry list of what I need to be aware of when
considering this class's uses, brace style preferences notwithstanding.

My knee-jerk response would be that this is fine the way it is now, but
perhaps adding your suggestion as an alternative syntax could be considered
for 6.0?

Then again, no one cares what I say ;-)


-- 
Aaron Sherman
Email or GTalk: a...@ajs.com
http://www.ajs.com/~ajs


Re: r31043 -[S32/Containers] Buf does Stringy, too

2010-06-02 Thread Moritz Lenz
Jason Switzer wrote:
 On Wed, Jun 2, 2010 at 5:10 AM, pugs-comm...@feather.perl6.nl wrote:
 
 Author: masak
 Date: 2010-06-02 12:10:22 +0200 (Wed, 02 Jun 2010)
 New Revision: 31043

 Modified:
   docs/Perl6/Spec/S32-setting-library/Containers.pod
 Log:
 [S32/Containers] Buf does Stringy, too

 -class Buf does Positional {...}
 +class Buf does Positional does Stringy {...}

 
 I never really thought about this, but now that I see it here, it made me
 realize that how 'does' works seems verbose. I think we should be able to
 specify a list instead of a bunch of 'does' statements. For example, the
 above example should be written as
 
 class Buf does Positional, Stringy { ... }

This has been discussed on IRC before, and rejected. If I recall
correctly, the two main reasons were:

1) if you change the precedence of 'does' to be looser than infix:,,
expressions like

my @a = 1, $a does True, 3, $b does False;

start to DWYM.

2) trait selection (and thus application) is handled by multi dispatch,
which relies on type annotation in the signature. This gets much harder
if the signature of the trait has to account for more than one role
being mixed in (and might not even be possible to get right with current
signature semantics).

Cheers,
Moritz