Skip to content

Commit b3e3cee

Browse files
author
Damian Rouson
committed
refac(all): switch PODA this to self
Change passed-object dummy argument (PODA) from C++-like "this" to Python-like "self". More new Fortran programmers with OOP experience are coming from Python than C++ these days.
1 parent 5baf08b commit b3e3cee

File tree

6 files changed

+28
-28
lines changed

6 files changed

+28
-28
lines changed

src/co_object_implementation.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
contains
1111

1212
module procedure mark_as_defined
13-
this%defined=.true.
13+
self%defined=.true.
1414
end procedure
1515

1616
module procedure user_defined
17-
is_defined = this%defined
17+
is_defined = self%defined
1818
end procedure
1919

2020
end submodule

src/co_object_interface.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module co_object_interface
1111
public :: co_object
1212

1313
! Define an abstract parent type to ensure basic functionality expected to be provided by all non-abstract types.
14-
! Each non-abstract type provides the functionality by extending this type and implementing its deferred binding(s). This
14+
! Each non-abstract type provides the functionality by extending self type and implementing its deferred binding(s). This
1515
! type resembles java's Object class in the sense that it is intended to be the ultimate ancester of every other type.
1616
type, abstract :: co_object
1717
private
@@ -25,16 +25,16 @@ module co_object_interface
2525

2626
interface
2727

28-
pure module subroutine mark_as_defined(this)
28+
pure module subroutine mark_as_defined(self)
2929
!! Mark the co_object as user-defined
3030
implicit none
31-
class(co_object), intent(inout) :: this
31+
class(co_object), intent(inout) :: self
3232
end subroutine
3333

34-
pure module function user_defined(this) result(is_defined)
35-
!! Return a boolean result indicating whether this co_object has been initialized since its declaration
34+
pure module function user_defined(self) result(is_defined)
35+
!! Return a boolean result indicating whether self co_object has been initialized since its declaration
3636
implicit none
37-
class(co_object), intent(in) :: this
37+
class(co_object), intent(in) :: self
3838
logical :: is_defined
3939
end function
4040

src/object_implementation.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
contains
1111

1212
module procedure mark_as_defined
13-
this%defined=.true.
13+
self%defined=.true.
1414
end procedure
1515

1616
module procedure user_defined
17-
is_defined = this%defined
17+
is_defined = self%defined
1818
end procedure
1919

2020
end submodule

src/object_interface.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module object_interface
1818
!! summary: Abstract type to ensure all objects extending it implement the required methods
1919
!!
2020
!! Define an abstract parent type to ensure basic functionality expected to be provided by all non-abstract types.
21-
!! Each non-abstract type provides the functionality by extending this type and implementing its deferred binding(s). This
21+
!! Each non-abstract type provides the functionality by extending self type and implementing its deferred binding(s). This
2222
!! type resembles java's Object class in the sense that it is intended to be the ultimate ancestor of every other type.
2323
private
2424
logical :: defined=.false.
@@ -32,16 +32,16 @@ module object_interface
3232

3333
interface
3434

35-
pure module subroutine mark_as_defined(this)
35+
pure module subroutine mark_as_defined(self)
3636
!! Mark the object as user-defined
3737
implicit none
38-
class(object_t), intent(inout) :: this
38+
class(object_t), intent(inout) :: self
3939
end subroutine
4040

41-
pure module function user_defined(this) result(is_defined)
42-
!! Return a boolean result indicating whether this object has been initialized since its declaration
41+
pure module function user_defined(self) result(is_defined)
42+
!! Return a boolean result indicating whether self object has been initialized since its declaration
4343
implicit none
44-
class(object_t), intent(in) :: this
44+
class(object_t), intent(in) :: self
4545
logical :: is_defined
4646
end function
4747

src/oracle_implementation.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
module procedure within_tolerance
88
class(oracle_t), allocatable :: error
99

10-
error = this - reference
10+
error = self - reference
1111
in_tolerance = (error%norm() <= tolerance)
1212

1313
end procedure

src/oracle_interface.f90

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,32 @@ module oracle_interface
1717

1818
abstract interface
1919

20-
function subtract_interface(this, rhs) result(difference)
21-
!! result has components corresponding to subtracting rhs's components fron this object's components
20+
function subtract_interface(self, rhs) result(difference)
21+
!! result has components corresponding to subtracting rhs's components fron self object's components
2222
import oracle_t
2323
implicit none
24-
class(oracle_t), intent(in) :: this, rhs
24+
class(oracle_t), intent(in) :: self, rhs
2525
class(oracle_t), allocatable :: difference
2626
end function
2727

28-
pure function norm_interface(this) result(norm_of_this)
29-
!! result is a norm of the array formed by concatenating the real components of this object
28+
pure function norm_interface(self) result(norm_of_self)
29+
!! result is a norm of the array formed by concatenating the real components of self object
3030
import oracle_t
3131
implicit none
32-
class(oracle_t), intent(in) :: this
33-
real norm_of_this
32+
class(oracle_t), intent(in) :: self
33+
real norm_of_self
3434
end function
3535

3636
end interface
3737

3838
interface
3939

40-
module function within_tolerance(this, reference, tolerance) result(in_tolerance)
41-
!! template method with true result iff the difference in state vectors (this - reference) has a norm within tolerance
40+
module function within_tolerance(self, reference, tolerance) result(in_tolerance)
41+
!! template method with true result iff the difference in state vectors (self - reference) has a norm within tolerance
4242
!! (impure because of internal call to 'subtract' binding)
43-
!! The existence of this procedure eliminates the need to rewrite similar code for every oracle child type.
43+
!! The existence of self procedure eliminates the need to rewrite similar code for every oracle child type.
4444
implicit none
45-
class(oracle_t), intent(in) :: this, reference
45+
class(oracle_t), intent(in) :: self, reference
4646
real, intent(in) :: tolerance
4747
logical in_tolerance
4848
end function

0 commit comments

Comments
 (0)