develooper Front page | perl.perl6.users | Postings from October 2019

order of execution

Thread Next
From:
Marcel Timmerman
Date:
October 20, 2019 17:12
Subject:
order of execution
Message ID:
952e2961-7090-1d8f-7c4c-c469b00564cc@gmail.com
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

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About