Skip to content
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

README: update examples #32

Merged
merged 1 commit into from
Feb 21, 2020
Merged

README: update examples #32

merged 1 commit into from
Feb 21, 2020

Conversation

band-a-prend
Copy link
Contributor

No description provided.

@szaghi
Copy link
Owner

szaghi commented Feb 21, 2020

@band-a-prend Thanks!

@szaghi szaghi merged commit 9c47122 into szaghi:master Feb 21, 2020
@band-a-prend
Copy link
Contributor Author

I hope I don't misunderstood the documentation in stringifor_string _t.F90 (line 1297)

!< The join-separator is set equals to self if self has a value or it is set to a null string ''. This value can be overridden
!< passing a custom separator.

and actual result is presented in this patch while at line 1307 test is

 !< test_passed(1) = (astring%join(array=strings)//''==strings(1)//strings(2)//strings(3))

@szaghi
Copy link
Owner

szaghi commented Feb 21, 2020

@band-a-prend I do not see the problem, can you give me more details?

Cheers

@band-a-prend
Copy link
Contributor Author

Sorry for delay with answer. I need to recheck some things.

Yes. The test is ok as in the mentioned documentation the astring wasn't initialized.

But now I'm confused with documentation example:

!< test_passed(2) = (astring%join(array=strings, sep='-')//''==strings(1)//'-'//strings(2)//'-'//strings(3))

astring still isn't initialized and empty. And it's alright with documentation:

!< The join-separator is set equals to self if self has a value or it is set to a null string ''. This value can be overridden
!< passing a custom separator.

But it seems that if sep is setup then the result is independent of value of astring at all as here used only strings array and sep:

program string_join

use stringifor
type(string) :: astring
type(string) :: strings(3)

astring = 'Hello World'

strings(1) = 'one'
strings(2) = 'two'
strings(3) = 'three'

print "(A)", astring%join(strings, sep='-')//'' ! print "one-two-three"
print "(A)", "one-two-three: "//astring%chars()

end program string_join

Output:

one-two-three
one-two-three: Hello World

@szaghi
Copy link
Owner

szaghi commented Feb 25, 2020

@band-a-prend

Thank you very much for the clarification, I'll re-check this soon, later today.

@szaghi
Copy link
Owner

szaghi commented Feb 25, 2020

@band-a-prend

I tried to re-read carefully the doc and the tests. For me the documentation of method is incomplete or obscure, but not wrong (or if it is wrong the error is due to my bad English), in particular, when I defined the method, my intentions were:

  • if self has a value use it
  • if self has not a value use a null string
  • if the user passes a sep dummy this overrides (always) the self value if it has or not a value.

As a consequence, your deduction that

But it seems that if sep is setup then the result is independent of value of astring at all as here used only strings array and sep

is correct for me, if sep is passed it is used independently to the value of self.

Probably I have to correct my bad English into the documentation of the method, if you have any suggestion it is more than welcome.

Cheers

@band-a-prend
Copy link
Contributor Author

@szaghi

I mean that I was confused by implementation: i.e. that for joining items of array of strings the additional "dummy" string is required.

Anyway as a suggestion for new implementation (of it possible, maybe it change API) I need to create separate request where

use stringifor
type(string) :: strings(3)

strings(1) = 'one'
strings(2) = 'two'
strings(3) = 'three'

print "(A)", strings%join(sep='-')//'' ! print "one-two-three"
print "(A)", strings%join()//'' ! print "onetwothree"

@szaghi
Copy link
Owner

szaghi commented Feb 25, 2020

@band-a-prend

Ok, I see the ambiguity, but this was a designed choice, using a string as a separator to join other strings. Anyway, it is possible to implement another join method with the API you suggested.

Please, open a an issue for a feature request and tomorrow I can try to implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants