Re: Metaprogramming, generate argument list.
On Tuesday, 23 August 2016 at 21:14:01 UTC, ciechowoj wrote: This is a bit strange, as the local variables aren't known either and they seem to work. I do not want to get the address, rather an alias to `&variable` expression. D doesn't accept aliases to expressions, only symbols and literals. Spec: https://dlang.org/spec/template.html#TemplateAliasParameter Alias parameters enable templates to be parameterized with almost any kind of D symbol, including user-defined type names, global names, local names, module names, template names, and template instance names. Literals can also be used as arguments to alias parameters.
Re: How to avoid ctRegex (solved)
On Wednesday, 24 August 2016 at 05:29:57 UTC, ag0aep6g wrote: On 08/24/2016 03:07 AM, cy wrote: Then what's ctRegex in there for at all...? Optimization. ctRegex requires that the pattern is available as a compile time constant. It uses that property to "generate optimized native machine code". The plain regex function doesn't have such a requirement. It also works with a pattern that's generated at run time, e.g. from user input. But you can use it with a compile time constant, too. And it works in CTFE then, but it does not "generate optimized native machine code". Yep, that's why ctRegex is 2x faster than the highly-tuned grep, e.g. https://github.com/dlang/phobos/pull/4286
Hosting a vibe.d website
Hello community, I usually host PHP websites for clients using shared hosting services but I'm not familiar with hosting compiled programming language websites. What processes are involved hosting a vibe.d website developed locally on a web server (shared hosting plan). And what hosting services/packages are available for that?
pow exponent type issue
I'm a little confused on why pow behaves so differently when switching from an int to a uint for the exponent. import std.math : pow; import std.stdio : writeln; void main() { float x = 2; int y1 = 1; uint y2 = 1; writeln(pow(x, -y1)); //prints 0.5 writeln(pow(x, -y2)); //prints inf }
Re: Hosting a vibe.d website
On Wednesday, 24 August 2016 at 19:19:33 UTC, Karabuta wrote: Hello community, I usually host PHP websites for clients using shared hosting services but I'm not familiar with hosting compiled programming language websites. What processes are involved hosting a vibe.d website developed locally on a web server (shared hosting plan). And what hosting services/packages are available for that? Heroku is quite popular because it's free in the basic version and comes with zero maintenance or need of administrator skills: http://tour.dlang.io/tour/en/vibed/deploy-on-heroku However you can deploy a vibe.d application on literally any machine and even a VPS server should work quite fine. If you are low on budget, you can usually spot great deals over at the Low End Box Blog [1] (I am not affiliated with them in any way) [1] http://lowendbox.com/
Re: pow exponent type issue
On Wednesday, 24 August 2016 at 19:16:56 UTC, jmh530 wrote: I'm a little confused on why pow behaves so differently when switching from an int to a uint for the exponent. import std.math : pow; import std.stdio : writeln; void main() { float x = 2; int y1 = 1; uint y2 = 1; writeln(pow(x, -y1)); //prints 0.5 writeln(pow(x, -y2)); //prints inf } -y1 is -1. But -y2 is uint.max, i.e. a pretty large positive number. The 'u' in "uint" stands for "unsigned". That is, it doesn't know negative numbers. Dont' use uint when you need negative numbers.
Re: pow exponent type issue
On Wednesday, 24 August 2016 at 19:41:35 UTC, ag0aep6g wrote: -y1 is -1. But -y2 is uint.max, i.e. a pretty large positive number. The 'u' in "uint" stands for "unsigned". That is, it doesn't know negative numbers. Dont' use uint when you need negative numbers. Ahh, doh.
nested enum
How can I create nested enum like structures? instead of Enum.X_Y I would like to access like Enum.X.Y Yet I want it to behave exactly as an enum. I just want to not use _ as .'s are better as they express more clearly what I want.
Re: nested enum
On Wednesday, 24 August 2016 at 23:04:25 UTC, Illuminati wrote: How can I create nested enum like structures? instead of Enum.X_Y I would like to access like Enum.X.Y Yet I want it to behave exactly as an enum. I just want to not use _ as .'s are better as they express more clearly what I want. struct MyEnum { enum X { Y = 10, Z = 20 } } void main() { import std.stdio; int y = MyEnum.X.Y; writeln(y); }
Re: nested enum
And if you need more levels: struct MyEnum { static struct AnotherEnum { enum X { Y = 10, Z = 20 } } } void main() { import std.stdio; int y = MyEnum.AnotherEnum.X.Y; writeln(y); } Dne 25.8.2016 v 03:37 Mike Parker via Digitalmars-d-learn napsal(a): On Wednesday, 24 August 2016 at 23:04:25 UTC, Illuminati wrote: How can I create nested enum like structures? instead of Enum.X_Y I would like to access like Enum.X.Y Yet I want it to behave exactly as an enum. I just want to not use _ as .'s are better as they express more clearly what I want. struct MyEnum { enum X { Y = 10, Z = 20 } } void main() { import std.stdio; int y = MyEnum.X.Y; writeln(y); }