Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stubbed attributes in roles don't die at compose time like stubbed methods do in Rakudo #3303

Closed
p6rt opened this issue Jan 2, 2014 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jan 2, 2014

Migrated from rt.perl.org#120916 (status was 'rejected')

Searchable as RT120916$

@p6rt
Copy link
Author

p6rt commented Jan 2, 2014

From @masak

<FROGGS> I could just make a role (Slangy) that stubs attributes...
wait, we don't have that feature :o)
<FROGGS> or do we?
<FROGGS> p​: my role Slangy { has $.grammar = ...; }; class COBOL does Slangy { }
<camelia> rakudo-parrot a77214​: ( no output )
<FROGGS> p​: my role Slangy { has $.grammar = ...; }; class COBOL does
Slangy { }; my $cobol = COBOL.new
<camelia> rakudo-parrot a77214​: OUTPUT«Stub code executed [...]
<FROGGS> cool
<FROGGS> p​: my role Slangy { has $.grammar = ...; }; class COBOL does
Slangy { }; my $cobol = COBOL.new( :grammar )
<camelia> rakudo-parrot a77214​: ( no output )
<FROGGS> very nice
<masak> FROGGS​: though it could be argued that the above should blow
up at composition-time.
<masak> as in, at the final '}' after the 'does Slangy'.
<FROGGS> true, but it is good enough for me
<masak> p​: role R { method foo { ... } }; class C does R {}; BEGIN {
say "alive" }
<camelia> rakudo-parrot a77214​: OUTPUT«===SORRY!===␤Method 'foo' must
be implemented by C because it is required by a role␤»
<masak> FROGGS​: yes, I'm just thinking from the perspective of rakudobugs ;)
* masak submits one

I'm not aware that the spec requires stubbed attributes to blow up at
composition time. So consider this 50% a rakudobug, 50% a spec
(clarification) request. I can submit a separate spec issue too if
anyone feels that'd be a good idea.

Even if we arrive at the conclusion that stubbed attributes in roles
shouldn't work like that, I think that "Stub code executed" is LTA in
this case. Why not something like "Cannot instantiate​: Attribute
$.grammar not initialized" ?

@p6rt
Copy link
Author

p6rt commented Nov 27, 2015

From @TimToady

The purpose of stubbing is to guarantee the public interface is complete, and since the public interface of attributes is entirely via accessors, it suffices to merely stub the accessor, and leave it up to the class whether it should implement that name via an explicit method or an attribute declaration. It should probably be part of the documentation of a role whether it's intended that a particular name be implemented by by an attribute, but really, it's entirely up to the class whether a given part of the interface is represented by an actual attribute or a virtual attribute.

Larry

@p6rt
Copy link
Author

p6rt commented Nov 27, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt p6rt closed this as completed Nov 27, 2015
@p6rt
Copy link
Author

p6rt commented Nov 27, 2015

@TimToady - Status changed from 'open' to 'rejected'

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant