-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
feature request: string concatenation of constants #5282
Comments
Check out the discussions here #4706 |
Well, I just hope that can only be applied to JavaScript |
I also want this, if not for all strings, then at least for those I specify explicitly with a metadata. With Haxe's rich type system we are able to wrap really crazy string-based extern APIs in a properly typed interface, and that would benefit very much from string constant concat. Here's a cool example from my hxdefold extern library experiment: abstract Property<T>(String) from String {}
extern class Go {
static function get<T>(prop:Property<T>):T;
}
extern class Vector {
var x:Float;
var y:Float;
}
abstract VectorProperty(Property<Vector>) from String to Property<Vector> {
public var x(get,never):Property<Float>;
inline function get_x():Property<Float> return '$this.x';
}
class Main {
static inline var SizeProperty:VectorProperty = "size";
static function main() {
var vec = Go.get(SizeProperty); // get the whole Vector
var x = Go.get(SizeProperty.x); // get just the x part
}
} What it currently generates is obviously this: Main.main = function() {
Go.get("size");
Go.get("size" + ".x");
}; Obviously, if one would write it directly in a target language, they would just write |
same as math expressions, it make the output look cleaner
js output:
but i would like to get:
The text was updated successfully, but these errors were encountered: