Skip to content

Preliminary implementation of default values #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 4, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
implement int8
  • Loading branch information
nshaffer committed Jan 3, 2020
commit 486be15949ec2c6be6850437fbe8872a525f06b7
16 changes: 15 additions & 1 deletion src/stdlib_experimental_default.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module stdlib_experimental_default
!! For additional clarity, `default` be called with keyword argument
!! for the fallback value, e.g., `default(x, to=1.0)`.
!!
use iso_fortran_env, only: sp => real32, dp => real64, qp => real128, int16, int32, int64
use iso_fortran_env, only: sp => real32, dp => real64, qp => real128, int8, int16, int32, int64
implicit none


Expand All @@ -23,6 +23,7 @@ module stdlib_experimental_default
module procedure default_sp
module procedure default_dp
module procedure default_qp
module procedure default_int8
module procedure default_int16
module procedure default_int32
module procedure default_int64
Expand Down Expand Up @@ -75,6 +76,19 @@ function default_qp(x, to) result(y)
end function default_qp


function default_int8(x, to) result(y)
integer(int8), intent(in), optional :: x
integer(int8), intent(in) :: to
integer(int8) :: y

if (present(x)) then
y = x
else
y = to
end if
end function default_int8


function default_int16(x, to) result(y)
integer(int16), intent(in), optional :: x
integer(int16), intent(in) :: to
Expand Down