Advertisement
Guest User

Untitled

a guest
May 11th, 2021
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #Need a solution to avoid circular imports
  2. #File ForPoint.rakumod
  3. unit Module ForPoint;
  4. #We cannot import ForLine here : circular problem
  5.  
  6. #suppose we declare subbed Line here ok
  7. #but it is implemented into ForLine module which we may NOT import with use.
  8. #How can we proceed though?
  9. class Line {
  10. ...
  11. };
  12.  
  13. class Point is export {
  14. has Int $.x;
  15. has Int $.y;
  16. has Line @belong;#Here is the problem.
  17.  
  18. method new(Int $x,Int $y) {
  19. # bla bla
  20. }
  21. }
  22.  
  23.  
  24. #File Forline.rakumod
  25. unit Module ForLine;
  26. use ForPoint;
  27.  
  28. class Line is export {
  29. has Point $.a;
  30. has Point $.b;
  31.  
  32. method new(int-list $ia,int-list $ib,:$int-motif? = -1,:$motif? = ''){
  33. my Point ($a,$b,$origin,$destination) = bound_control($ia,$ib);
  34. self.bless( :$a, :$b,:$origin,:$destination,:$int-motif,:$motif);
  35. }
  36. method a {
  37. #bla bla
  38. }
  39. method b {
  40. #bla bla
  41. }
  42. }
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement