develooper Front page | perl.perl5.porters | Postings from September 2022

Re: Preview reviews / comments on feature-class branch

Thread Previous | Thread Next
From:
Yuki Kimoto
Date:
September 29, 2022 03:20
Subject:
Re: Preview reviews / comments on feature-class branch
Message ID:
CAExogxM2fY_FY8DY2_3Ua8Ys4Ki0SXStapFw6B_s8xVuDh3=Hg@mail.gmail.com
2022-9-28 18:55 Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> wrote:

> Yuki Kimoto <kimoto.yuki@gmail.com> writes:
>
> > 2022年9月28日(水) 2:12 Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>:
> >
> >> TL;DR - please help review this large work ahead of PR-time, to avoid
> >>   surprises later on and make the process run smoother
> >>   (or explicitly opt-out)
> […]
> > Before proceeding, I would like to discuss how to use the class
> > and method syntax in existing source codes.
>
> What is there to discuss?  Just make sure you don't have functions
> called `class`, `field` or `method` that the new keywords would conflict
> with, add `use feature 'class';` and use it.
>
> Existing code that just uses the classes and objects doesn't need to
> know or care whether they're implemented with the `class` feature, some
> other object system or manually, as long as the public API stays the
> same.
>
> - ilmari
>
>
People have many existing source codes such as the following ones.

  package MyClass;

  sub new {
    ...
  }

  # Many accessors
  sub my_accessor1 {
    # ...
  }
  sub my_accessor2 {
    # ...
  }
  sub my_accessorN {
    # ...
  }

Suppose he wants to use the method keyword. He will rewrite the following
codes.

  class MyClass {
    method new : common {
      ...
    }

    # Many accessors
    method my_accessor1 {
      # ...
    }
    method my_accessor2 {
      # ...
    }
    method my_accessorN {
      # ...
  }

In the currently planned implementation this will not work because of the
redefine of the new method.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About