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

custom defined method no longer works (method defined { … }) #6029

Closed
p6rt opened this issue Jan 23, 2017 · 5 comments
Closed

custom defined method no longer works (method defined { … }) #6029

p6rt opened this issue Jan 23, 2017 · 5 comments
Labels
regression Issue did not exist previously

Comments

@p6rt
Copy link

p6rt commented Jan 23, 2017

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

Searchable as RT130629$

@p6rt
Copy link
Author

p6rt commented Jan 23, 2017

From @AlexDaniel

Code​:
class C { method defined { True } }; say ?C

Result (2015.12,2016.02)​:
True

Result (2016.03,HEAD)​:
False

Bisectable points to rakudo/rakudo@24b4b23

The commit message did not indicate that �defined� method should no longer work, so my best guess is that the change is not intentional.

However, if this is not supposed to work, then what about throwing an error when the user attempts to create a �defined� method?

@p6rt
Copy link
Author

p6rt commented Jan 23, 2017

From @smls

A custom `.defined` method actually still works fine​:

  â�� class C { method defined { True } }; say C.defined
  True

But the `?` operator doesn't call `.defined`, it calls `.Bool`​:

  â�� class C { method Bool { True } }; say ?C
  True

Before the cited commit, class `Any` provided a default implementation for `.Bool` that delegated to `.defined`, and your custom class inherited that.

Now, the default implementation of `.Bool` checks `.DEFINITE` (via the `​:D` / `​:U` syntax) instead of `.defined`.

I don't know whether that subtle change was intentional, but it seems reasonable. Overriding `.defined` for a custom class is something that should only be necessary in rare situations, so it's not a great burden to ask users to also override method `.Bool` in those situations.

@p6rt
Copy link
Author

p6rt commented Jan 23, 2017

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

@p6rt
Copy link
Author

p6rt commented Jan 24, 2017

From @zoffixznet

On Mon, 23 Jan 2017 01​:37​:16 -0800, alex.jakimenko@​gmail.com wrote​:

Code​:
class C { method defined { True } }; say ?C

Result (2015.12,2016.02)​:
True

Result (2016.03,HEAD)​:
False

Bisectable points to
rakudo/rakudo@24b4b23

The commit message did not indicate that �defined� method should no
longer work, so my best guess is that the change is not intentional.

However, if this is not supposed to work, then what about throwing an
error when the user attempts to create a �defined� method?

+1 to smsl's and lizmat's response (on mailing list).

Custom `defined` method still works; the Bool method�which is what your operator calls�simply got decoupled from it.

The new behaviour is less surprising​: only what the user actually overrides is affected. And I agree with lizmat that is isn't a bug.

@p6rt
Copy link
Author

p6rt commented Jan 24, 2017

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

@p6rt p6rt closed this as completed Jan 24, 2017
@p6rt p6rt added the regression Issue did not exist previously label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Issue did not exist previously
Projects
None yet
Development

No branches or pull requests

1 participant