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

Need definition for Object.perl #582

Closed
p6rt opened this issue Jan 6, 2009 · 8 comments
Closed

Need definition for Object.perl #582

p6rt opened this issue Jan 6, 2009 · 8 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jan 6, 2009

Migrated from rt.perl.org#62002 (status was 'resolved')

Searchable as RT62002$

@p6rt
Copy link
Author

p6rt commented Jan 6, 2009

From @masak

Due to the structurally recursive nature of C<.perl>, the fact that
Rakudo r34997 doesn't give newly defined classes a default C<.perl>
method upon definition is very keenly felt e.g. when doing C<.perl> on
a list of instances of the new class.

$ perl6 -e '(class {}).new.perl'Method 'perl' not found for invocant of class ''
[...]
$ perl6 -e 'class A {}; A.new.perl'
Method 'perl' not found for invocant of class 'A'
[...]

Two questions naturally arise​: the first is why this method isn't
inherited from Object? The second is what such a default C<.perl>
should output.

I have a vague feeling that similar tickets have been submitted
before. But this question needs to be put forward until the spec is
clarified (or whatever is the blocker) -- missing methods is one of
the few things that can ruin a scripting session.

@p6rt
Copy link
Author

p6rt commented Jan 6, 2009

From @pmichaud

On Tue, Jan 06, 2009 at 02​:50​:07AM -0800, Carl Mäsak wrote​:

Due to the structurally recursive nature of C<.perl>, the fact that
Rakudo r34997 doesn't give newly defined classes a default C<.perl>
method upon definition is very keenly felt e.g. when doing C<.perl> on
a list of instances of the new class.

$ perl6 -e '(class {}).new.perl'Method 'perl' not found for invocant of class ''
[...]
$ perl6 -e 'class A {}; A.new.perl'
Method 'perl' not found for invocant of class 'A'
[...]

Two questions naturally arise​: the first is why this method isn't
inherited from Object? The second is what such a default C<.perl>
should output.

Rakudo doesn't implement a .perl in Object because of the second
question -- we don't know what that default C<.perl> should output.

But if you'd like to add a temporary ".perl" method to Object
that does something more reasonable (however you define it),
that's certainly ok.

In the meantime I'm marking this ticket as a [Spec] ticket.

Pm

@p6rt
Copy link
Author

p6rt commented Jan 6, 2009

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

@p6rt
Copy link
Author

p6rt commented Jan 6, 2009

From @masak

Pm (>)​:

But if you'd like to add a temporary ".perl" method to Object
that does something more reasonable (however you define it),
that's certainly ok.

<jnthn> masak​: What about a TheClass.new(...) which sets up attributes
to their current values?
<masak> jnthn​: you know, that's actually not half bad. :)
<masak> (why didn't I think of that?)

@p6rt
Copy link
Author

p6rt commented Jan 20, 2009

From @moritz

On Tue Jan 06 07​:47​:30 2009, masak wrote​:

Pm (>)​:

But if you'd like to add a temporary ".perl" method to Object
that does something more reasonable (however you define it),
that's certainly ok.

<jnthn> masak​: What about a TheClass.new(...) which sets up attributes
to their current values?
<masak> jnthn​: you know, that's actually not half bad. :)
<masak> (why didn't I think of that?)

To "steal" some prior art from pugs​:

pugs> class A { has $.b; has @​.c; }; A.new(​:b<3> :c<4 5>).perl
"A.new((\"b\" => \"3\"), (\"c\" => (\"4\", \"5\")))"

For the case of cyclic structures, we could emit things like​:

do {
  my $a = A.new();
  # this only works is $.b is declared as 'is rw'
  $a.b = $a;
}

I don't think it'll work without some kind of special syntax (that
allows setting of private attributes from the outside later on).

But for now the non-cyclic case would be *very* helpful if implemented
somehow.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Jul 12, 2010

From @bbkr

[15​:30] <bbkr> is this ticket still valid?
http://rt.perl.org/rt3/Ticket/Display.html?id=62002 looks like it was
created before Mu object was added to spec.
[15​:31] <moritz_> bbkr​: well, it's now s​:g/Object/Mu/
[15​:31] <moritz_> bbkr​: but all in all we still need a good default
.perl method
[15​:34] <bbkr> moritz_​: thanks. but since both code samples work then
the main problem in ticked - .perl method not available in user defined
class - is solved (despite output it generates)
[15​:34] <bbkr> ticket*
[15​:34] <moritz_> bbkr​: if you say so... then somebody will open a
ticket about Any.perl being useless
[15​:34] <moritz_> I don't mind either way

leaving unchanged then

@p6rt
Copy link
Author

p6rt commented Jun 25, 2012

From @pmichaud

Test added to S02-names-vars/perl.t, closing ticket.

Pm

@p6rt
Copy link
Author

p6rt commented Jun 25, 2012

@pmichaud - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jun 25, 2012
@p6rt p6rt added the spec 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