Ticket #1704 (new deprecation)

Opened 4 years ago

Last modified 3 years ago

Implicit selection of main sub is deprecated.

Reported by: bacek Owned by: plobsing
Priority: normal Milestone: 3.0
Component: imcc Version: trunk
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

After 2.6 current behaviour of selecting main Sub will be changed. Instead of something like "First sub in PIR file if there is no :main Sub" we will use only first Sub marked with ":main" modifier.

Main reason - enable args validation of 0-arity subs. See also  http://irclog.perlgeek.de/parrotsketch/2010-07-13#i_2550626 for discussion.

Eligible in 2.7.

Change History

  Changed 4 years ago by plobsing

  • status changed from new to closed
  • resolution set to done

Completed in cbaad37.

  Changed 4 years ago by fperrad

  • status changed from closed to reopened
  • resolution done deleted

That breaks plumage which is written only in NQP (see  https://github.com/parrot/plumage/blob/master/src/plumage.nqp).

$ parrot plumage.pbc
No main sub found

  Changed 4 years ago by pmichaud

Note that NQP allows pirflags (including :main) to be attached to a sub using the 'is pirflags<...>' trait.

sub MAIN() is pirflags<:main> {

...

}

One can also use 'is pirflags<...>' to add :vtable flags and the like.

That said, the elimination of implicit :main selection is likely to break a fair bit of NQP and PCT programs, because they have been relying somewhat heavily on the implicit main selection. I suppose we can work around this by having PCT/NQP always explicitly marking the first sub as :main.... but that seems problematic also (especially if PCT/NQP is generating code that is intended to be .include'd as part of a much larger PIR source, as is the case for many things in Rakudo.

The ticket claims that implicit :main needs to be eliminated to enable validation of 0-arity subs... but the discussion in #parrotsketch cited above clearly says that the two issues (checking arity and marking :main) are orthogonal issues and should not have been linked. I agree with that assessment, and thus there's no strong reason for removing implicit :main. I think we should continue to allow implicit :main, and simply enable arity checking on all subs. The ability to write a :main (implicit or explicit) with no parameters is all that needs deprecating.

Pm

follow-up: ↓ 5   Changed 4 years ago by jkeenan

  • status changed from reopened to new
  • owner set to plobsing

plobsing (or anyone with more git foo than me):

For the reasons described by fperrad and pmichaud above, please revert this commit as soon as possible. We need to have further discussion before proceeding.

Thank you very much.

kid51

in reply to: ↑ 4 ; follow-up: ↓ 6   Changed 4 years ago by plobsing

Replying to jkeenan:

plobsing (or anyone with more git foo than me): For the reasons described by fperrad and pmichaud above, please revert this commit as soon as possible. We need to have further discussion before proceeding.

This component of the commit is fairly independant, simply included with the other because it was easy, low-hanging fruit. I will reimplement implicit :main immediately.

Thank you very much. kid51

in reply to: ↑ 5   Changed 4 years ago by plobsing

Replying to plobsing:

Replying to jkeenan:

plobsing (or anyone with more git foo than me): For the reasons described by fperrad and pmichaud above, please revert this commit as soon as possible. We need to have further discussion before proceeding.

This component of the commit is fairly independant, simply included with the other because it was easy, low-hanging fruit. I will reimplement implicit :main immediately.

Completed at fdb6fa57549b91ab6024d046909fff7eedfdb75d.

Thank you very much. kid51

  Changed 3 years ago by jkeenan

Reviewing this ticket, I see that a commit was made; a complaint was made; a partial revert was committed.

Are there any issues remaining in this ticket? Is it closable?

Thank you very much.

kid51

Note: See TracTickets for help on using tickets.