Navigation Menu

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

Semicolon form of MAIN declaration #3594

Closed
p6rt opened this issue Nov 27, 2014 · 4 comments
Closed

Semicolon form of MAIN declaration #3594

p6rt opened this issue Nov 27, 2014 · 4 comments
Labels
NYI Features not yet implemented

Comments

@p6rt
Copy link

p6rt commented Nov 27, 2014

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

Searchable as RT123309$

@p6rt
Copy link
Author

p6rt commented Nov 27, 2014

From @masak

Quoth S06​:

As with module and class declarations, a sub declaration
ending in semicolon is allowed at the outermost file scope if it is the
first such declaration, in which case the rest of the file is the body​:

  sub MAIN ($directory, :$verbose, *%other, *@​filenames);
  for @​filenames { ... }

This form is allowed only for simple subs named C<MAIN> that are intended
to be run from the command line.
A C<proto> or C<multi> definition may not be written in semicolon form,
nor may C<MAIN> subs within a module or class be written in semicolon
form. (A C<MAIN> routine
is allowed in a module or class, but is not usually invoked unless
the file is run directly (see a above). This corresponds to the
"unless caller" idiom of Perl 5.) In general, you may have only one
semicolon-style declaration that controls the whole file.

<masak> m​: sub MAIN();␤say "OH HAI"
<camelia> rakudo-moar 1e4fe4​: OUTPUT«===SORRY!=== Error while
compiling /tmp/A5naXHrUhH␤Missing block␤at /tmp/A5naXHrUhH​:1␤------>
sub MAIN()⏏; [...]
* masak submits NYI rakudobug
<Mouq> masak​: What's that supposed to do?
<masak> Mouq​: whole-file MAIN only sub.
<Mouq> Ooo
<masak> S06​:3408
<synopsebot> Link​: http://perlcabal.org/syn/S06.html#line_3408
<Mouq> Could be useful for one-liners too...

@p6rt
Copy link
Author

p6rt commented Feb 2, 2015

From @Mouq

Feature added in Rakudo commit

commit 073586b65db6e05c1207aea0f985d905c0328ad7
Author​: Mouq <alexmoquin@​gmail.com>
Date​: Mon Feb 2 02​:26​:10 2015 -0500

  Allow `sub MAIN($params); …` declarations — RT #​123309

Tests added in Roast commit

commit 093f03fe68ce301f5c8aa85ae7b3e4a6b279383c
Author​: Mouq <alexmoquin@​gmail.com>
Date​: Mon Feb 2 03​:25​:40 2015 -0500

  Add and correct tests for `sub MAIN;` form

Marking as resolved :)

On Thu Nov 27 06​:09​:50 2014, masak wrote​:

Quoth S06​:

As with module and class declarations, a sub declaration
ending in semicolon is allowed at the outermost file scope if it is the
first such declaration, in which case the rest of the file is the body​:

sub MAIN \($directory, :$verbose, \*%other, \*@&#8203;filenames\);
for @&#8203;filenames \{ \.\.\. \}

This form is allowed only for simple subs named C<MAIN> that are intended
to be run from the command line.
A C<proto> or C<multi> definition may not be written in semicolon form,
nor may C<MAIN> subs within a module or class be written in semicolon
form. (A C<MAIN> routine
is allowed in a module or class, but is not usually invoked unless
the file is run directly (see a above). This corresponds to the
"unless caller" idiom of Perl 5.) In general, you may have only one
semicolon-style declaration that controls the whole file.

<masak> m​: sub MAIN();␤say "OH HAI"
<camelia> rakudo-moar 1e4fe4​: OUTPUT«===SORRY!=== Error while
compiling /tmp/A5naXHrUhH␤Missing block␤at /tmp/A5naXHrUhH​:1␤------>
sub MAIN()⏏; [...]
* masak submits NYI rakudobug
<Mouq> masak​: What's that supposed to do?
<masak> Mouq​: whole-file MAIN only sub.
<Mouq> Ooo
<masak> S06​:3408
<synopsebot> Link​: http://perlcabal.org/syn/S06.html#line_3408
<Mouq> Could be useful for one-liners too...

@p6rt
Copy link
Author

p6rt commented Feb 2, 2015

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

@p6rt
Copy link
Author

p6rt commented Feb 2, 2015

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

@p6rt p6rt closed this as completed Feb 2, 2015
@p6rt p6rt added the NYI Features not yet implemented label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NYI Features not yet implemented
Projects
None yet
Development

No branches or pull requests

1 participant