Programs are compiled in memory, it just isn't written out to disk. On Mon, Oct 21, 2019 at 3:33 AM Marcel Timmerman <mt1...@gmail.com> wrote:
> @yary > > Thanks for your answer. I've done it too and saw the same kind of result. > But then I thought I've read it somewhere that programs are not compiled, > only modules. So I must write a module to check it. > > But if anyone knows, it would be faster ;-) > > Regards, > > marcel > On 20-10-2019 22:59, yary wrote: > > Seems like we can answer "Is it also true when compiling?" by putting the > REPL code into a file! > > $ cat order-execution.raku > class Y { method y (Int $y) {note $y}} > my Y $y .= new; > > sub b (Int $i --> Int) { note "about to increment i above $i"; $i + 10 } > > say b(10); > > say $y.?y(b(11)); > > say $y.?undef(b(12)); > > $ perl6 order-execution.raku > about to increment i above 10 > 20 > about to increment i above 11 > 21 > True > about to increment i above 12 > Nil > > $ perl6 --version > *This is Rakudo Star version 2019.03.1 built on MoarVM version 2019.03 > **implementing > Perl 6.d.* > > Yes Rakudo is executing the args for something that it doesn't end up > calling. Seems overly-eager for a language that is properly lazy by design. > I'd be interested in seeing documentation for this order-of-operations if > it exists. > > By the way I had to look up .? - > https://docs.perl6.org/language/operators#index-entry-methodop_.%3F > > methodop .? <https://docs.perl6.org/language/operators#___top> > > Safe call operator. $invocant.?method calls method method on $invocant if > it has a method of such name. Otherwise it returns Nil > <https://docs.perl6.org/type/Nil>. > > Technically, not a real operator; it's syntax special-cased in the > compiler. > > -y > > > On Sun, Oct 20, 2019 at 10:12 AM Marcel Timmerman <mt1...@gmail.com> > wrote: > >> Hello all, >> >> I've a small question where I want to know what is processed first in >> the following line >> >> >> $my-object.?"my-method"(some-complex-argument-calculation()) >> >> >> Will the sub 'some-complex-argument-calculation()' always be run even >> when 'my-method' is not available because the sub must be executed >> before the method is called. >> >> >> In the REPL the sub is called despite a method is not defined. Is it >> also true when compiling? >> >> >> > class Y { method y (Int $y) {note $y}} >> (Y) >> >> > my Y $y .= new >> Y.new >> >> >sub b (Int $i --> Int) { note "$i"; $i + 10 } >> &b >> >> > b(10) >> 10 >> 20 >> >> > $y.?y(b(10)) >> 10 >> 20 >> True >> >> > $y.?undef(b(10)) >> 10 >> Nil >> >> >> Regards >> Marcel >> >