[Gambas-user] Make String class friendlier
Martin
mbelmonte at belmotek.net
Wed Apr 7 18:05:57 CEST 2021
ok I understand.
So, if I want to extend the class String as Chain, for example, I use
the instruction "Inherits String" but then when I create a Variable I
must define it like "As New Chain" but String is just defined like "As
String".
How I can give to the Chain.class the same behavior than String.class ?
Regards.
Martín.
El 7/4/21 a las 17:24, Benoît Minisini escribió:
> Le 07/04/2021 à 17:11, Martin a écrit :
>> ok, I do not know the scope that something like this can have in the
>> performance of the interpreter, but I leave an example of an
>> independent class that works in the way I say except that it must be
>> defined as "AS New"
>>
>> in some form...
>>
>
> String being not objects allows many performance optimizations on
> memory allocations.
>
> For example:
>
> * Left(), Mid(), Right(), Trim() do not allocate memory.
>
> * A &= B does not use an intermediate allocation most of the time.
>
> * Strings have their own allocator, so that the glic memory allocator
> is avoided most of the time.
>
> This make string management in Gambas fast, often faster than many
> other languages (see the benchmarks on the wiki).
>
> Making String use an object syntax without performance penalty would
> need a big support of the compiler instead of interpreter support, so
> that the object syntax is rewritten into the old one before being
> compiled. It won't be done now!
>
> Regards,
>
More information about the User
mailing list