22/09/2025
StringZilla
https://ashvardanian.com/posts/stringwars-on-gpus/
https://www.reddit.com/r/programming/comments/1nm3ath/processing_strings_109x_faster_than_nvidia_on_h100/
Processing Strings 109x Faster than Nvidia on H100
Up to 100x faster strings for C, C++, CUDA, Python, Rust, Swift, JS, & Go,
leveraging NEON, AVX2, AVX-512, SVE, GPGPU, & SWAR to accelerate search, hashing,
sorting, edit distances, sketches, and memory ops


https://github.com/unum-cloud/usearch/
https://unum-cloud.github.io/usearch/
Fast Open-Source Search & Clustering engine × for Vectors & Arbitrary Objects ×
in C++, C, Python, JavaScript, Rust, Java, Objective-C, Swift, C#, GoLang, and Wolfram
---
jlf:
Same author as for StringZilla.
Maybe not directly related to strings.


--------------------------------------------------------------------------------
15/12/2018
[bugs:#1404] Some method args don't honor REQUEST("STRING")

Erich:
neither Bag nor Stem have a makeString() method, so all of those three examples should fail, but they pass instead.

.Stream~new(.Stem~new)
1~append(.Bag~new)
1~caselessEquals(.Bag~new)

Rick:
Stem doesn't have a makeString method, but it overrides request() and sends the request on to the default value. That one is working correctly.

I'm a bit leery about fixing this. There are basically two mechanisms at play here:
1) a method requires a string argument.
   This mechanism uses request('STRING') on the argument and raises an error if a string value is not obtained.
2) a method, or command, builtin function, or operator requires a string value always.
   In this case, request('STRING') is tried first, a NOSTRING condition is raised and then the objects STRING value is used.

Originally it was envisioned that all "classic" Rexx situations would use 2) and methods would use 1).
However, a lot of the classic Rexx features, such as all of the operators, are implemented as methods
of the string class, so these methods, at least, need to use 2) because they fall into the other category.

It appears that most of the methods in the string class got implemented using mechanism 2).
We can't convert everything to 1) because the operator methods still need to use 2).
I'm not sure I'm comfortable having mixed modes here.
Perhaps it would be better to just defined that the string methods always use 2)
when a string argument is used and do a trawl through the code to make sure they are all consistent.


--------------------------------------------------------------------------------
Developer list 17/02/2017

Q from Erich)
In 5.0, Array's string() method gives a different result than Array's makeString() method. I believe this is the only class with such a behavior.

Is this to be regarded as a bug?

say (1, 2)~string -- an Array
say (1, 2)~makeString -- 1 nl 2

A from Rick)
They do not need to be the same and there is some history behind why array is special.

As originally designed, the makeString method was meant to be used for automatic coercion to string values where request('STRING') is used, while a manual request should have been handled by providing a different method such as toString (which array also has). The string method is meant as an absolute fallback that does not do a lot of processing, used for things like error messages and trace. For example, you would not want an array makeString method called during processing of an error triggered by an out of memory condition.

This was a bit bungled when makeString was originally added to array such that request('STRING') was still returning the result of the string method rather than the constructed string value and also resulted in array makeString being the only one that takes arguments. Typically a make<classname> method should not have arguments because it is really intended just for interaction with the request mechanism. This is why the array class also has a toString method today.

Anyway, yes it is correct that they are different since the methods are intended for different purposes.


--------------------------------------------------------------------------------
RexxCore.h

    #define isOfClass(t,r) (r)->isObjectType(The##t##Behaviour)

    /* The next macro is specifically for REQUESTing a STRING, since there are    */
    /* four primitive classes that are equivalents for strings.  It will trap on  */
    /* OREF_NULL. */
    inline RexxString *REQUEST_STRING(RexxObject *object)
    {
      return (isOfClass(String, object) ? (RexxString *)object : (object)->requestString());
    }


--------------------------------------------------------------------------------
ObjectClass.hpp

     inline bool   isObjectType(RexxBehaviour *b) { return b == behaviour; }
     inline bool   isObjectType(size_t t) { return getObjectTypeNumber() == t; }

--------------------------------------------------------------------------------
ObjectClass.cpp

    RexxString *RexxObject::requestString()
    /******************************************************************************/
    /* Function:  Handle a string request for a REXX object.  This will go        */
    /*            through the whole search order to do the conversion.            */
    /******************************************************************************/
    {

        /* primitive object?                 */
        if (this->isBaseClass())
        {
            RexxString *string_value;            /* converted object                  */
            /* get the string representation     */
            string_value = this->primitiveMakeString();
            if (string_value == TheNilObject)
            {/* didn't convert?                   */
             /* get the final string value        */
                string_value = this->stringValue();
                /* raise a NOSTRING condition        */
                ActivityManager::currentActivity->raiseCondition(OREF_NOSTRING, OREF_NULL, string_value, this, OREF_NULL);
            }
            return string_value;               /* return the converted form         */
        }
        else
        {                               /* do a real request for this        */
            ProtectedObject string_value;

            this->sendMessage(OREF_REQUEST, OREF_STRINGSYM, string_value);
            // The returned value might be an Integer or NumberString value.  We need to
            // force this to be a real string value.
            string_value = ((RexxObject *)string_value)->primitiveMakeString();
            if (string_value == TheNilObject)
            {/* didn't convert?                   */
             /* get the final string value        */
                this->sendMessage(OREF_STRINGSYM, string_value);
                // we're really dependent upon the program respecting the protocol
                // here and returning a value.  It is possible there is a
                // problem, so how to handle this.  We could just raise an error, but this
                // isn't the most ideal message since the error is raised at the
                // line where the string value is required, but this is a rare
                // situation.  As a fallback, use the default object STRING method,
                // then raise an error if we still don't get anything.  This at least
                // keeps the interpreter from crashing, there's a good chance the
                // program will run.  Frankly, there's something seriously wrong
                // if this error ever gets issued.
                if (((RexxObject *)string_value) == OREF_NULL)
                {
                    string_value = RexxObject::stringValue();
                    if (((RexxObject *)string_value) == OREF_NULL)
                    {
                        reportException(Error_No_result_object_message, OREF_STRINGSYM);
                    }
                }
                // The returned value might be an Integer or NumberString value.  We need to
                // force this to be a real string value.
                string_value = ((RexxObject *)string_value)->primitiveMakeString();
                /* raise a NOSTRING condition        */
                ActivityManager::currentActivity->raiseCondition(OREF_NOSTRING, OREF_NULL, (RexxString *)string_value, this, OREF_NULL);
            }
            return (RexxString *)string_value;   /* return the converted form         */
        }
    }


--------------------------------------------------------------------------------
StringClass.cpp

    RexxString  *RexxString::primitiveMakeString()
    /******************************************************************************/
    /* Function:  Handle a REQUEST('STRING') request for a REXX string object     */
    /******************************************************************************/
    {
        return this;                         /* this is easy                      */
    }


--------------------------------------------------------------------------------
NumberStringClass.cpp

    RexxString *RexxNumberString::primitiveMakeString()
    /******************************************************************************/
    /* Function:  Handle a REQUEST('STRING') request for a REXX numberstring      */
    /******************************************************************************/
    {
        if (this->stringObject != OREF_NULL) /* already converted?                */
        {
            return this->stringObject;         /* all finished                      */
        }
        return this->stringValue();          /* return the string value           */
    }


--------------------------------------------------------------------------------
IntegerClass.cpp

    RexxString *RexxInteger::primitiveMakeString()
    /******************************************************************************/
    /* Function:  Handle a REQUEST('STRING') request for a REXX integer object    */
    /******************************************************************************/
    {
        if (this->stringrep != OREF_NULL)    /* have a string already?            */
        {
            return this->stringrep;            /* return it directly                */
        }
        char        stringBuffer[32];        /* integer formatting buffer         */
                                               /* convert value into string         */
        Numerics::formatWholeNumber(this->value, stringBuffer);

        /* return as a string                */
        RexxString *string = new_string(stringBuffer, strlen(stringBuffer));
        /* cache this away for later         */
        OrefSet(this, this->stringrep, string);
        this->setHasReferences();            // now have references that need marking
        return string;                       /* return the new string             */
    }


--------------------------------------------------------------------------------
MutableBufferClass.cpp

    /**
     * Handle the primitive class makeString optimization.  This
     * is required because MutableBuffer implements a
     * STRING method.
     *
     * @return The string value of the buffer
     */
    RexxString *RexxMutableBuffer::primitiveMakeString()
    {
        // go straight to the string handler
        return this->makeString();
    }

