Open jjn1056 opened 1 year ago
I'm enabling the class pragma via the 'Example::Syntax' module , it basically does 'use experimental class'.
Hi John. I'm not sure I understand. Can you also show the code for the Example::Syntax
module?
If you're just using use experimental 'class';
but leaving the package declaration, the code doesn't know that you really have a class. Instead, you have to have a proper class built. Since I can't see your code, I'm unsure what's happening.
Also, this won't work (it might work now, but we're going to make a distinction between subs and methods, so it will break in the future):
sub root :At('$path_end/...') Via('../protected') ($self, $c, $user) {
$c->action->next($user->account);
}
Instead:
method root :At('$path_end/...') Via('../protected') ($c, $user) {
$c->action->next($user->account);
}
I'm also unsure of how the Moose attributes work with the new class
syntax. I've never tried that. Much of the Moose code heavily uses the MOP.
@Ovid
Here's the syntax class
package Example::Syntax;
use strict;
use warnings;
use Import::Into;
use Module::Runtime;
sub importables {
my ($class) = @_;
return (
'utf8',
'strict',
'warnings',
['feature', ':5.38'],
['experimental', 'class', 'try', 'defer'],
);
}
sub import {
my ($class, @args) = @_;
my $caller = caller;
foreach my $import_proto($class->importables) {
my ($module, @args) = (ref($import_proto)||'') eq 'ARRAY' ?
@$import_proto : ($import_proto, ());
Module::Runtime::use_module($module)
->import::into($caller, @args)
}
}
1;
@Ovid I put the entire codebase into git https://github.com/jjn1056/Valiant/blob/main/example/lib/Example/Controller/Account.pm if that helps.
I'm just saying maybe things like this working could be part of a 'definition of done' which might take future iterations. And I'm also suggesting as my personal opinion, that maybe this project should start thinking about compatibility.
So I tried to use core class with a basic Catalyst controller:
But when I try to run I get a compile time error:
I'm enabling the class pragma via the 'Example::Syntax' module , it basically does 'use experimental class'.
I would propose that code like this working should be considered mandatory before moving this out of experimental status.