Messing with betterC and string type.

Adam D. Ruppe destructionator at gmail.com
Thu Sep 6 17:37:12 UTC 2018


On Thursday, 6 September 2018 at 17:09:34 UTC, SrMordred wrote:
> Yes, the true problem arrives on the operations like concat "~" 
> that call some internal function to do that with strings.

Only if it is string ~ string. If it is your type, that's where 
opBinary and opBinaryRight come in.

YourString ~ built_in_string = YourString.opBinary(string op : 
"~")(immutable(char)[] rhs);

built_in_string ~ YourString = YourString.opBinaryRight(string op 
: "~")(immutable(char)[] lhs);


so you can make it work.


Though btw I would actually suggest leaving concat 
unimplemented... it is so hard to manage the memory for it 
without the GC. IMO better off just appending to an existing 
thing; do ~= instead of ~.

> iep, this seems a real problem. ;/

yeah we have no implict ctors :(


More information about the Digitalmars-d mailing list