I agree to the most of your writing. Just a couple of notes. > > my Array[Str] $a = ["a", "b", "c"]; > > my Str @a = ["a", "b", "c"]; > > > First, there's co/contra variance of sub-typing. The first paragraph of > wikipedia page is > https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science) > > <https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)> > introduces this issue well imo. There's no way to avoid this issue it if you > want to use a language that supports both sub-types (like a Cat is an Animal) > and lists. In regard to co/contra variance Perl 6 actually delays the tougher > WTFs that will come with time. You have more WTFs to look forward to. :)
Frankly saying, not sure how much co/contrvariance is applicable here. To my view the whole problem of understanding is understanding the difference of essentially $a = [...] vs @a.append([...]) which are happening under the hood. In the case of my module variance kicks me at the point where I'm trying to mimic Perl6 type checking. I can't know about what exact type of assignment is used and thus can only guess how to make things the right way. Though what just crossed my mind is that I actually know attribute's sigil and thus can make assumption about what approach to use. > > > Otherwise the difference between the two assignments is quite > > counterintuitive and, to my view, it contradicts to DWIM. > > "intuitive" is a subjective concept. Here you unconsciously hit me with my own weapon... I often contradicting the use of 'intuitive' because it's too subjective. And only to get into this trap on my own! > > Similar case is with Array ~~ List against List ~~ Array. If for any reason > > one needs to test if a value could be assigned to a container prior to the > > actual assignment it would really be hard to grasp for the first time why > > my @a = <a b c> works whereas my Array $a = <a b c> fails. > > I think your confusion here is to do with (our materials and error messages > related to) container semantics. > > Does https://opensource.com/article/18/8/containers-perl-6 > <https://opensource.com/article/18/8/containers-perl-6> help? There is not much new to me in the article. Though knowing a concept and having it imprinted into fingertips are somewhat different things. Would take months of learning... > > I'm happy to dialog here about any of this stuff help clear up your mental > models (and mine). So I am. Thanks for sharing the thoughts! Best regards, Vadim Belman