-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
string overloads #66
Comments
as written theres a bug with handling string litterals import std;
void cstring(const(char)*){}
void dstring(string){}
void mixedstring(const(char)*){}
void mixedstring(string){}
unittest{
string bar="bar";
cstring("foobar");
string foo="f";
foo~="oo";
dstring(bar);
dstring(foo);
mixedstring(foo);
mixedstring(bar);
mixedstring("foobar");
}
for my solution I copy and pasted my string overloads into package.d |
I believe accepting a string literal via a C string parameter is considered a conversion for purposes of overloading. So it will prefer the D version first. In any case, I would probably accept string overloads as long as they do not use D facilities. That is, it's OK to malloc a string, send it into a function, and then free the string. But I don't want to use GC-allocated C strings. That will happen in draylib. This does mean that it can't just be a blanket overload for all functions, because some functions might store the char* expecting it to last forever. |
given its been in a bad state for several years and youve been talking about doing a major port for a while(and such a thing will just take time), I think you should consider shipping a bandaid even if theres "buyer beware" consideration, for the main usecases it will probaly work or they will be found quickly this mainly effects the dub people cause well... I just point sane people to my project template but that is likely 75% of users and your students wont |
The focus of this is to be a binding to the C project. Yes, there are some D enhancements, but I don't want to go too far. As it is, it's very easy to keep up with the existing release, making a new release takes about an hour based on the updated code from upstream. Adding more overloads could prove to be more maintenance than it's worth. I'm thinking of a few cases focusing on drawing text which obviously would be nicer as you want to build strings using D instead of So the type of approach I would take is -- propose an overload (or set of overloads), if it makes a lot of sense that people would want to use D to construct it, and using it in a temporary fashion would not break lifetime guarantees, then we can add it. I'd even suggest a different name than the original to allow still using literals for I do not want to just accept a list of all functions that mechanically had |
raylib uses c strings blah blah
some generated code:
stringoverloads.d.csv.json.txt
findcharstar.d.txt
The text was updated successfully, but these errors were encountered: