Perl-Apollo / Corinna

Corinna - Bring Modern OO to the Core of Perl
Artistic License 2.0
157 stars 19 forks source link

Block Behavior Feedback #25

Closed Ovid closed 3 years ago

Ovid commented 3 years ago

Use this issue to discuss Changes to Block Behavior.

HaraldJoerg commented 3 years ago

Some of the proposed changes are orthogonal to an object system. I guess this is not an issue if you're writing new code. However, I'm looking at Corinna with an interest of introducing it in existing code which either has some homegrown object system, or some no-longer-fashionable object system, or no object system yet. So, while I could easily accept behavioral change in context of use v7;, they might increase the cost of using Corinna (Also, I don't mind boilerplate that much. Dist::Zilla or your favorite editor has enough template support to take care of that).

In my opinion, strict and warnings are fine, and signatures make sense if the method keyword comes with them anyway.

I can live with use utf8and use open qw(:std :utf8); but don't consider them very useful. A file can have only one encoding: if use utf8; is used in one single block, the same encoding must be applied for the whole file, or at least for POD =encoding. Non-ASCII characters might appear in author names even more frequently than in code, and POD has no "block scope".

I don't care that much about the "no" modules but I wonder: Is there any benefit (e.g. code paths that can be dropped from the parser, as could happen if it is generally active with use v7;) from forbidding this?

Finally, I'd prefer if autodie is not activated. That module is only good if you don't have any error handling beyond do something or die;. But if you include your own meaningful text in the call to die, or if you throw an error object, then you'll notice that with autodie your diagnostics are no longer available because autodie replaced it with its unfeeling standard text. I'd rather activate autodie whereever it makes an improvement than deactivate it when it is harmful.

haarg commented 3 years ago

I don't think any of this makes sense to do within a class block. None of it is specifically related to the object system. It should instead be controlled by something like use v8; which would also enable the class block.

This is also trying to create yet another set of defaults. There are already two sets to be concerned with. The defaults perl runs with, and the behavior once you have done use v7; or whatever perl version you care about. Adding another is more to remember. And in this case, it's changing behavior that has nothing to do with the object system, just because you are using the object system.

As for the specific defaults mentioned, there are some problems.

use utf8; has to do with the file encoding. While it is lexical, using it lexically is a mistake because it implies that the file has mixed encodings. It should generally only be used at the top level of a file.

use open qw(:std :utf8); is global, so not reasonable. But if we assume it was operating lexically in some way, this implies applying an encoding to the read and write operations rather than the file handles. This is a new language feature which is entirely out of scope for the object system.

autodie has a lot of problems with its current implementation. For it to be a proper in-core feature it would require exception objects in core. This is also massively expanding the scope of concerns for something with no direct connection to the object system. I also think it makes code harder to understand. Modifying the behavior of built in functions means you have to remember if it is enabled in any given context. At least when used directly with use autodie that is stated directly. Enabling it without that explicit reminder makes things more confusing.

leonerd commented 3 years ago

I don't think any of this makes sense to do within a class block. None of it is specifically related to the object system. It should instead be controlled by something like use v8; which would also enable the class block.

This is also trying to create yet another set of defaults. There are already two sets to be concerned with. The defaults perl runs with, and the behavior once you have done use v7; or whatever perl version you care about. Adding another is more to remember. And in this case, it's changing behavior that has nothing to do with the object system, just because you are using the object system.

^-- +1 to what @haarg said.

Ovid commented 3 years ago

I'll close this and remove the Wiki page. I agree with the points raised.