Re: Why does .new initialize?

2021-07-20 Thread William Michels via perl6-users
Possibly relevant StackOverflow question: "Why does constraining a Perl 6 named parameter to a definite value make it a required value?" https://stackoverflow.com/questions/48166325/why-does-constraining-a-perl-6-named-parameter-to-a-definite-value-make-it-a-req On Mon, Jul 19, 2021 at 10:00 AM

Re: Why does .new initialize?

2021-07-19 Thread Vadim Belman
Matthew has provided some concrete examples of default initializations. I'd like to scratch the surface of more general problem: encapsulation. In many cases only a class knows it's real internal structure and can use this information to protect the data from misuse by 3rd party code which may

Re: Why does .new initialize?

2021-07-19 Thread Matthew Stuckwisch
In general, the idea of initialized doesn't mean a lot in Raku, at least not at the language level. At any given time, any variable has a value. By default, if you've typed a variable, it's initially set to the type itself (Any is the default type, so the default default value). The only

Re: Why does .new initialize?

2021-07-19 Thread Peter Scott
Yes.  I'm agnostic on this point, but there was a time when some prominent Perl contributors were dogmatic about it and I didn't know how widespread it was. Peter On 7/19/2021 10:06 AM, Vadim Belman wrote: Let me guess. The school prohibits object self-initialization? It has to be done by

Re: Why does .new initialize?

2021-07-19 Thread Vadim Belman
Let me guess. The school prohibits object self-initialization? It has to be done by external code? Best regards, Vadim Belman > On Jul 19, 2021, at 1:00 PM, Peter Scott wrote: > > On 7/19/2021 1:24 AM, Elizabeth Mattijsen wrote: >> If .new wouldn't initialize a type to its basic

Re: Why does .new initialize?

2021-07-19 Thread Peter Scott
On 7/19/2021 1:24 AM, Elizabeth Mattijsen wrote: If .new wouldn't initialize a type to its basic instantiation, what would be the point of .new then? FWIW, the same goes for: dd Int.new; # 0 dd Num.new; # 0e0 dd Complex.new; # <0+0i> dd Str.new; # "" If

Re: Why does .new initialize?

2021-07-19 Thread Elizabeth Mattijsen
> On 19 Jul 2021, at 05:49, Peter Scott wrote: > > I'm curious as to why Rat.new initializes instead of leaving as undefined: > > > $*RAKU > Raku (6.d) > > my Rat $p > (Rat) > > put $p > Use of uninitialized value $p of type Rat in string context. > Methods .^name, .raku, .gist, or .say can be

Why does .new initialize?

2021-07-18 Thread Peter Scott
I'm curious as to why Rat.new initializes instead of leaving as undefined: > $*RAKU Raku (6.d) > my Rat $p (Rat) > put $p Use of uninitialized value $p of type Rat in string context. Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.   in block at line