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

Enhance string_type constructor #563

Open
zoziha opened this issue Nov 12, 2021 · 6 comments
Open

Enhance string_type constructor #563

zoziha opened this issue Nov 12, 2021 · 6 comments
Labels
API Discussion on a specific API for a proposal (exploratory) easy Difficulty level is easy and good for starting into this project idea Proposition of an idea and opening an issue to discuss it topic: strings String processing

Comments

@zoziha
Copy link
Contributor

zoziha commented Nov 12, 2021

Motivation

As I said in #562 , we can enhance the constructor of string_type to support conversion of other types (integer, real, logical, complex) to string_type, and support format argument.

The important thing is that this constructor can be elemental, type(string_type) is very good at constructing flexible string arrays, but to_string can only be pure because character(:), allcoatable.

At this stage, string_type only constructs strings from character, integer, and logical types.

Prior Art

Additional Information

No response

@zoziha zoziha added idea Proposition of an idea and opening an issue to discuss it API Discussion on a specific API for a proposal (exploratory) easy Difficulty level is easy and good for starting into this project topic: strings String processing labels Nov 12, 2021
@milancurcic
Copy link
Member

I like the idea. I see that stdlib_strings depends on stdlib_string_type module. In practice, would you duplicate some code from to_string to implement a specific constructor for string_type?

@zoziha zoziha changed the title Enhanced string_type constructor Enhance string_type constructor Nov 13, 2021
@awvwgk
Copy link
Member

awvwgk commented Nov 14, 2021

Do we have an implementation for creating strings from real and complex numbers without using internal IO in Fortran?

@St-Maxwell
Copy link
Member

I have just implemented a Fortran version of Ryu which can effectively convert floating point numbers to decimal strings. After the codes being fully tested, I think they can be adopted by stdlib.

Currently it just generates the shortest representation of a floating number and doesn't support formatting. The original C implementation has Ryu printf which supports precision parameter. And I am trying to translate the C codes into Fortran.

@jvdp1
Copy link
Member

jvdp1 commented Feb 1, 2022

@St-Maxwell: is this related to the stdlib to_string that support various types?
It seems that your implementation does not rely on internal IO (as in stdlib). Therefore, it would be interesting to compare the different performances.

@St-Maxwell
Copy link
Member

@jvdp1 I plan to implement conversion routines for real32 and real64. Case of real128 will fall back to internal IO until we implement Ryu for this kind later.

@Divyansh200102
Copy link

@zoziha is this issue still open and also can you please give an idea of how can i resolve this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Discussion on a specific API for a proposal (exploratory) easy Difficulty level is easy and good for starting into this project idea Proposition of an idea and opening an issue to discuss it topic: strings String processing
Projects
None yet
Development

No branches or pull requests

6 participants