Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Overloading of concatenation and assignment operators for character variables #341

Open
Labels
ideaProposition of an idea and opening an issue to discuss it topic: stringsString processing
@awvwgk

Description

Additionally to the basic character manipulation in stdlib_ascii and the stdlib_string_type we might want to allow for a somewhat looser and less strict string handling.

The idea would be to overload common string operators like // to allow concatenating with implicit conversion to character values.

Originally posted by @urbanjost in #336 (comment):

I find overloading helps make things much more compact, so assuming you have a function like STR, overloading // with that allows you to do things like "MESSAGE='the value is '//10//' and the limit is '//300.4//'.'". Some would probably like to overload + to do that, but I prefer to overload + - / * to convert strings to numbers, and to overload INT(), REAL(), and DBLE() to take character values and assume they are numeric. So that makes for a symmetric set for converting to and from strings and numeric values.

Originally posted by @ivan-pi in #336 (comment):

Both Java and Javascript support the idiom of using the concatenation operator to build a string using

String s = "" + i;

If operator(//) were overload then one could do the same thing in Fortran:

character(len=:), allocatable :: s
s = ''//42 ! or 42//''

Similarly, one could think about overloading the assignment operator for such purposes, at the risk of running into the usual fixed length vs. deferred length character issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ideaProposition of an idea and opening an issue to discuss it topic: stringsString processing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /