a overloaded Operator Len() (unary operator overload) as per description in doc.
It gave a Error, in which it was stated, that this is on the TODO list.
In the light of the recent discussion on WString (making it dynamic, e.t.c.), I find
it somewhat strange, that TODO's on the "base type" are not addressed first.
In order to prove my suspicions, I've simplified massively. First, doing a #undef of
Len, in order to use my own implementations (every one of the 3 is working fine,
if, and only if, the other 2 are 'commented out') a clear indication, that over-
loading in and of itself, is not possible with Len() ...
(IIRC, there was a similar issue with Sqr(), that was fixed, recently.)
Code: Select all
' Len_Overload-test1.bas -- (c) 2019-05-18/23, MrSwiss
' compile: -s console
' testing ...
'Function Len OverLoad( _ ' do it the C'ish way ...
' ByVal psz As ZString Ptr _ ' until we get a char = zero/NULL
' ) As ULongInt
' Dim As ULongInt le = 0
' Dim As UByte t
' t = psz[le] : le += 1
' Loop Until t = 0
' ? "psz"
' Return (le - 1)
'Function Len OverLoad( _ ' internal definition
' ByRef s As Const String _ ' signed integer
' ) As Integer
' ? "s LI"
' Return CPtr(Integer Ptr, @s)
Function Len OverLoad( _ ' similar to internal definition
ByRef s As Const String _ ' just unsigned integer
) As UInteger
? "s ULI"
Return CPtr(UInteger Ptr, @s)
' demo code ...
Dim As String st = "test, test, blah, blah, blaaaaaaaaahhhhhhhhhh!"
Dim As ZString Ptr pszt = StrPtr("not so funny: can't overload Len()!")
Print Len(st), st
Print Len(*pszt), *pszt