I want Package BLOCK syntax return 1.
I want Package BLOCK syntax return 1.
package Point { # foo }
I want This is interpreted as the following.
{ package Point;# foo
1;
}
In current Perl, module need to return 1 at the end of script. But this is a little strange specification. If package BLOCK syntax return 1;, we don't need to write 1; at the end of module.
Is this difficult?
The class doesn't need to return 1, the file/module does. These are separate tasks and though they are commonly seen together are fully unrelated.
You return a true value at the end of the file so the require knows that everything happened. It has nothing to do with being a module or a package. We talk about this in Intermediate Perl.
>The class doesn't need to return 1, the file/module does.
I know this. My point is that file/module need to return 1;. But this is a little strange specification from other language perspective. so if package BLOCK syntax return 1;, this is resolved.
brian
>You return a true value at the end of the file so the require knows that everything happened.
I know this. My point is that module file need to return 1;. But this is a little strange specification from other language perspective.
Many people forget to write 1;. but 1; is always needed in module file. if package BLOCK syntax return 1;, this is resolved.
https://metacpan.org/pod/true
I guess you assume that every package is going into a separate file, and therefore a module to load. But if you define several packages into the same file unit, you are going to require Perl to conclude each block with useless return statements. While I cannot see a problem with that (from a practical point of view), I don't see a reason for having it too.
Brad
true is very interesting.
fluca1978
>I guess you assume that every package is going into a separate file.
No, package Foo { ...; 1;} package Bar { ...; 1;} have no problem.
>While I cannot see a problem with that (from a practical point of view), I don't see a reason for having it too.
My point is that 1; is strange specification and people tend to forget to write 1;. so I want to hide this strange specification in some way.
Brad
I use true module in mop::minus. This seem to be good.
https://github.com/yuki-kimoto/mop-minus-proposal