This feature, together with operator overloading and casting as allowed me to implement datatypes not supported by FreeBasic that almost behave as native datatypes, e.g. CWSTR (Dynamic unicode null terminated string), CBSTR (BSTR datatype), CVAR (variants), CPropVar (PropVariants), CCUR (Currency), CDEC (Decimal), CInt96 (96 bit integers), CSafeArray (Safe arrays). And then, thanks to having support for these datatypes, clases like CSTack(Stacks), CQueue (Queues), CDicObj (associatetive arrays), CDispInvoke (Automation wrapper), CWmiDIsp (WMI), and many more.
Also, when returning an instance of these classes as the result of a function or method, FreeBsic does the following:
FUNCTION Foo () AS CWSTR
DIM cws AS CWSTR = "Test string"
FUNCTION = cws
END FUNCTION
When using FUNCTION =, it creates a temporary instance of the class and calls the appropriate LET operator (if it is not implemented, it won't work correctly), that will copy the contents, and returns the temporary CWSTR, that will self destroy once it is assigned to the variable that receives the result.
FUNCTION Foo () AS CWSTR
DIM cws AS CWSTR = "Test string"
RETURN cws
END FUNCTION
When using RETURN, it will do the same but calling the appropriate constructor, i.e. if the class has a constructor that accepts a string, you can do:
FUNCTION Foo () AS CWSTR
RETURN "Test string"
END FUNCTION
It is a pity that some features like dynamic unicode strings risk to never be implemented because of platform differences, i.e. Windows uses UTF-16 and Linux UTF-8.