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

.sink of class not getting called, but Mu.sink is #5973

Open
p6rt opened this issue Jan 3, 2017 · 4 comments
Open

.sink of class not getting called, but Mu.sink is #5973

p6rt opened this issue Jan 3, 2017 · 4 comments
Labels
at_larry RFC Request For Comments

Comments

@p6rt
Copy link

p6rt commented Jan 3, 2017

Migrated from rt.perl.org#130493 (status was 'open')

Searchable as RT130493$

@p6rt
Copy link
Author

p6rt commented Jan 3, 2017

From @lizmat

$ 6 'class A { method sink() { say "goodbye" } }; A’
WARNINGS for -e​:
Useless use of constant value A in sink context (line 1)

I would expected this to say “goodbye” rather than being silent and issuing a warning. The fact that a class has a specific .sink method indicates that the developer had a plan for functioning in a sink environment. So it should a. call that method and b. not issue a warning.

Adding an nqp​::say(“sunk”) to Mu.sink reveals that in the above case Mu.sink *does* appear to be called.

@p6rt
Copy link
Author

p6rt commented Jan 3, 2017

From @jnthn

On Tue, 03 Jan 2017 04​:54​:52 -0800, elizabeth wrote​:

$ 6 'class A { method sink() { say "goodbye" } }; A’
WARNINGS for -e​:
Useless use of constant value A in sink context (line 1)

I would expected this to say “goodbye” rather than being silent and
issuing a warning. The fact that a class has a specific .sink method
indicates that the developer had a plan for functioning in a sink
environment. So it should a. call that method and b. not issue a
warning.

I think we consciously decided that use of a type object in sink context would always warn (justification is that it's been known to catch the odd precedence thinko). Note that with an instance​:

$ perl6-m 'class A { method sink() { say "goodbye" } }; A.new'
goodbye

It does exactly what you expect.

/jnthn

@p6rt
Copy link
Author

p6rt commented Jan 3, 2017

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

@p6rt
Copy link
Author

p6rt commented Mar 10, 2018

From @AlexDaniel

I find the behavior surprising. Are there any examples of precedence thinkos that are caught by this?

Added [RFC][@​LARRY] tags, with just a little more information I think we'll be able to close. Maybe.

On 2017-01-03 09​:00​:06, jnthn@​jnthn.net wrote​:

On Tue, 03 Jan 2017 04​:54​:52 -0800, elizabeth wrote​:

$ 6 'class A { method sink() { say "goodbye" } }; A’
WARNINGS for -e​:
Useless use of constant value A in sink context (line 1)

I would expected this to say “goodbye” rather than being silent and
issuing a warning. The fact that a class has a specific .sink method
indicates that the developer had a plan for functioning in a sink
environment. So it should a. call that method and b. not issue a
warning.

I think we consciously decided that use of a type object in sink
context would always warn (justification is that it's been known to
catch the odd precedence thinko). Note that with an instance​:

$ perl6-m 'class A { method sink() { say "goodbye" } }; A.new'
goodbye

It does exactly what you expect.

/jnthn

@p6rt p6rt added at_larry RFC Request For Comments labels Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
at_larry RFC Request For Comments
Projects
None yet
Development

No branches or pull requests

1 participant