Luke Palmer wrote:
S12 says:
subtype Str_not2b of Str where /^[isnt|arent|amnot|aint]$/;
My brain parses this as:
subtype Str_not2b[Str where /.../];
Or:
subtype Str_not2b[Str] where /.../;
I guess my mental parsing problems stem from the fact
that it was you who told me about the equivalence of
the brackets and 'of'.
Neither of which really reflect how it is really parsed. It looks like
`subtype` has a special syntax.
Could you enlighten me how it is actually parsed?
I guess from the corresponding form
subtype Str Str_not2b where /^[isnt|arent|amnot|aint]$/;
that subtype is modeled after sub declarations
subtype Str_not2b returns Str where /^[isnt|arent|amnot|aint]$/;
The thing stored under Str_not2b in the lexical namespace
is actually a closure
sub Str_not2b (Str $unconstrained) returns bit {...}
which is then referenced by variables, signatures etc.
I find this to be free of special
syntax and clearer to boot:
type Str_not2b ::= Str where /^[isnt|arent|amnot|aint]$/;
Why don't we just ditch the `subtype` keyword?
Wouldn't the above work as
::Str_not2b ::= Str where /^[isnt|arent|amnot|aint]$/;
so that type is just a short-cut?
--
TSa (Thomas SandlaÃ)