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

Functional vs. object-oriented string handling #334

Open
awvwgk opened this issue Mar 11, 2021 · 2 comments
Open

Functional vs. object-oriented string handling #334

awvwgk opened this issue Mar 11, 2021 · 2 comments
Labels
topic: strings String processing

Comments

@awvwgk
Copy link
Member

awvwgk commented Mar 11, 2021

To explore the capabilities of string handling I have implemented two kinds of strings to far.

  1. non-extendible, functional string_type (see Implement non-fancy functional string type #320), similar to iso_varying_string
  2. abstract base class string_class (see Enable discussions for stdlib? #330)

Currently both implementation provide only the bare minimum functionality of the intrinsic deferred length character variables.

There are two type of questions to answer here:

  1. should the experimental namespace of stdlib provide overlapping functionality
  2. do we prefer either of the string implementations or do we want to look for something else

Related to #330 implementing an abstract base class for string objects.
For prior discussions of strings see #69.

@awvwgk awvwgk added the topic: utilities containers, strings, files, OS/environment integration, unit testing, assertions, logging, ... label Mar 11, 2021
@ivan-pi
Copy link
Member

ivan-pi commented Mar 12, 2021

What would go into the category something else? (that is apart from a new standardized intrinsic string type)

Personally, I am happy with the functional (non-extendible) string type. Looking at the list of auxiliary methods in StringiFor, I think all of them can be implemented just as easily as functions (and not type-bound methods).

That said, one benefit of the object-oriented string class is that it suffices to import only the type in order to use the type-bound methods.

I would add that in C++ it is generally frowned upon to inherit from std::string (e.g. see Why should one not derive from c++ std string class?). Since we currently don't have any plans to introduce a string inheritance hierarchy with polymorphic behavior, I'm not convinced about the benefits of a string class.

@wclodius2
Copy link
Contributor

FWIW for a "string type" to supplant the intrinsic character I would make the internal representation an integer array so that it is straight forward to extend it to represent UCS/Unicode. The integer type could be either INT8 if a UTF-8 representation is desired, INT16 for a UTF-16 representation, or INT32 for UTF-32. I would expect the UTF-32 representation would be the most straight-forward to implement and best for East Asian ideographs, UTF-8 would be the most efficient for most European and Semetic languages, UTF-16 the most efficient for most of the rest of the world.

@awvwgk awvwgk added topic: strings String processing and removed topic: utilities containers, strings, files, OS/environment integration, unit testing, assertions, logging, ... labels Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: strings String processing
Projects
None yet
Development

No branches or pull requests

3 participants