Re: A small question default values in tmplate-functions
import std.stdio; import core.vararg; auto veryStableAPI(bool brave = false)(string parameter, ...) { static if (!brave) { pragma(msg, I'm not brave); } else { pragma(msg, I'm very brave); } } void main(string[] args) { veryStableAPI(test); veryStableAPI!(true)(test); } Sorry but that does not anwer my question. is it legal or is it not ?
A small question default values in tmplate-functions
Hello, Suppose I have the following function auto veryStableAPI(string parameter,VaraiadicParams...)() { // do something very slow and stable; } auto experimentalReplacement(string parameter,VaraidcParams ...)() { // do the same thing very fast and dangerous } is the following auto veryStableAPI(bool brave=false, string parameter,VaraiadicParams...) { static if (!brave) // do something very slow and stable; else // do the same thing very fast and dangerous } valid according to spec ?
Re: dmd compile large project
try dub :D
Re: can't I use __traits(allMembers) recursivly ?
Orange is neat I had a look at but, the docs are abit lacking ... I don't really know how to get it to do what i want Well I have an Enum in a Struct and I need to serialze the struct members and unfold the enum. can orange do that ?
Re: can't I use __traits(allMembers) recursivly ?
I have solved by problem. I just forgot to prepend static to the ifs I used :D
getting Key:Value pairs of an enum at compile time ?
Hello, I have an Enum to represent possible Options for a selectList e.g enum options { blueish=Blue, redish =Red } and I want the List-Entrys to say blueish or redish. the value send to the app should be Blue or Red. I can use __traits(allMembers,Enum) for the identifiers, but how do I get the Values ?
Re: getting Key:Value pairs of an enum at compile time ?
Try getMember: http://dlang.org/traits.html#getMember if i try it, I get __aggr2297 cannot be read at compile time
Re: getting Key:Value pairs of an enum at compile time ?
void main() { foreach(m; EnumMembers!Options) { writeln(m, , cast(string)m); } } Still not there at compile-time ... because I need to index my members
Re: getting Key:Value pairs of an enum at compile time ?
Could you show an exact code that fails? sure! auto EnumToSelect(Enum)(string Name = __traits(identifier,Enum)) if (is(Enum==enum)) { foreach (i,Item;[__traits(allMembers,Enum)]) { else form_string ~= \toption(value='~Item~') ~__traits(getMember,Enum,Item)~\n; } debug import std.stdio; debug writeln(form_string); return form_string; }
Re: getting Key:Value pairs of an enum at compile time ?
Oh my bad wasn't too carefull with deletion auto EnumToSelect(Enum)(string Name = __traits(identifier,Enum)) if (is(Enum==enum)) { foreach (i,Item;[__traits(allMembers,Enum)]) { reslt ~= \toption(value='~__traits(getMember,Enum,Item)~') ~Item~\n; } debug import std.stdio; debug writeln(form_string); return reslt; }
can't I use __traits(allMembers) recursivly ?
When I try to struct _pod_ { string s1; enum e1 { v1,v2 }; } auto printPod(Pod)() if (__traits(isPOD,Pod)) { string result; foreach (member;__traits(allMembers,Pod) ) { auto _member=__traits(getMember,Pod,member); } writeln(result); } void main() {printPod!(_pod_);} I get Error: need 'this' for 's1' of type 'string' Error: type e1 has no value
Re: can't I use __traits(allMembers) recursivly ?
I'm trying to serialize my struct through CT-Refelction
problems with mixins and non-ascii characters
Hi, When I try to define an Enum with an umlaut like ä enum test2 { l, ä } I get Error: basic type expected, not \u00e4 and Error: type only allowed if anonymous enum and no enum type is there any workaround for this ?
Re: problems with mixins and non-ascii characters
On Wednesday, 22 January 2014 at 10:46:30 UTC, bearophile wrote: Uplink_Coder: is there any workaround for this ? For me this is a feature, not a bug. Bye, bearophile I never said bug :D just I thoght UniCode should make this a non-issue ...
Re: problems with mixins and non-ascii characters
Strange this bug seems to manifest itself only in some situations enum ä {ä = ä} does not work in dpaste but suddenly it works on my local enviorment (Windows-Mono-d,dmd 2.064.2) it seems to have something todo with the abscence of a BOM header ...
Re: D for web?
there is vibe.d! look at the dconf2013 for a presentation about it and get it at vibed.org
Re: D for web?
you were faster :D
Re: The D Programming Language page 161.
I guess that new should be length as it represents as an integer variable
sort(charArray) doesn't work
sort doesn't work on an primitive Array ? Is that normal please look @http://www.dpaste.dzfl.pl/961286e1 because I don't know what i'm doing worng Thanks in Advance :D
howto make a function get a types form compilte-time-parameters AND from the arguments ?
(this is my first post so please alert me to any breaches of forum etiquette) Hello, I have a problem with a helper function I'm writeting. T[] makeArray(T,U)(immutable U[] paramArray) { T[] result; foreach (param;paramArray) { result ~= T(param); } return result; } and I would like not to take the compile-time-parameter U but insead infering it form the argumet. is it possible ? and if. how ? Uplink_Coder
Re: howto make a function get types form compile-time-parameters AND from arguments ?
Maybe I shuold be more specific : for now It's: T[] arr = makeArray!(T,U)([some,instances,of,U]); but I would like it to be: auto arr = makeArray!(T)([some,instances,of,U]);
Re: howto make a function get types form compile-time-parameters AND from arguments ?
by changeing T[] makeArray(T,U)(immutable U[] paramArray) into T[] makeArray(T,U)(const U paramArray) if (isAggregateType!(U) || is Array!(U)) everything works perfectly Thanks very much --- Uplink_Coder