Re: Setting the GtkD Include Path in dexed?
On Tuesday, 12 March 2019 at 21:54:36 UTC, JN wrote: On Tuesday, 12 March 2019 at 17:39:06 UTC, Ron Tarrant wrote: Another way of asking this, I suppose, would be: How do I pass command line arguments to dmd from within dexed? How about Project -> Project editor -> Categories -> Other -> dmdOtherOptions ? I missed that one. I'll give it a try. Thanks.
Re: Setting the GtkD Include Path in dexed?
On Tuesday, 12 March 2019 at 17:39:06 UTC, Ron Tarrant wrote: Another way of asking this, I suppose, would be: How do I pass command line arguments to dmd from within dexed? How about Project -> Project editor -> Categories -> Other -> dmdOtherOptions ?
Re: Setting the GtkD Include Path in dexed?
Another way of asking this, I suppose, would be: How do I pass command line arguments to dmd from within dexed?
Re: am I using version right?
On Tuesday, 12 March 2019 at 17:07:11 UTC, DFTW wrote: In that code, the static assert() will run if and only if neither version condition is true, i.e, the OS is neither Windows nor linux. Correct? yes, that's right.
am I using version right?
version(Windows) { writeln("Hello from Windows system!"); } else version(linux) { writeln("hello from linux!"); } else static assert(0, "unknow system!"); In that code, the static assert() will run if and only if neither version condition is true, i.e, the OS is neither Windows nor linux. Correct? My question is due version-else, I'm unsure if version-else works the way it does with regular if and the static assert() will not run at compile-time, regardless whether version is true
Re: inout auto ref escaping a reference to parameter, only errors with vibe Json type, or if inout is there.
On Monday, 11 March 2019 at 22:29:05 UTC, aliak wrote: [...] Here's a much reduces test case: struct W(T) {} struct S { int* data; } template match1(alias handler) { auto ref match1(T)(inout auto ref W!T w) { return handler(); } } template match2(alias handler) { auto match2(T)(auto ref W!T w) { return match1!handler(w); } } void main() { W!int() .match2!(() => S()); }
Re: Why a template with Nullable does not compile?
On Tuesday, 12 March 2019 at 15:26:05 UTC, Victor Porton wrote: template FieldInfo(T, Nullable!T default_) { } On Tuesday, 12 March 2019 at 09:05:36 UTC, Nicholas Wilson wrote: It seems to be getting confused between the two types of Nullable, namely: Nullable(T), and Nullable(T, T defaultVal) I don't understand why exactly it is getting confused. How can it decide that "Nullable!T default_" is a two-arguments template when it is so not "Nullable!(T, default_)"? Please explain the EXACT cause of the error. My question why it is getting confused was not answered.
Re: Why a template with Nullable does not compile?
On Tue, Mar 12, 2019 at 04:23:29PM +, Victor Porton via Digitalmars-d-learn wrote: [...] > I know what is eponymous template. But how it behaves when the > eponymous member inside itself is also a template? How to instantiate > it? (provide please an example how to instantiate) You need to provide two sets of template arguments. Usually, the only time we nest eponymous templates this way is when we're writing a function that needs to take two variadic sets of template parameters. In that case, we only need to write one set of template parameters and let IFTI fill in the second set of parameters for us. For example: template map(funcs...) { template map(Ranges...) { auto map(Ranges rr) { ... } } } auto r = map!(func1, func2)(r1, r2); The first part `map!(func1, func2)` resolves to an instantiation of the outer template, which is an inner template, then the compiler uses IFTI to deduce the second set of arguments as !(typeof(r1), typeof(r2)) in order to instantiate the inner template. If you want to instantiate it by hand, you could do something like this: alias Outer = map!(func1, func2); // instantiate outer template alias inner = Outer!(int[], int[]); // instantiate inner template inner([ 1, 2, 3], [ 4, 5, 6 ]); T -- People say I'm indecisive, but I'm not sure about that. -- YHL, CONLANG
Re: Why a template with Nullable does not compile?
On Tuesday, 12 March 2019 at 16:20:11 UTC, H. S. Teoh wrote: On Tue, Mar 12, 2019 at 03:26:05PM +, Victor Porton via Digitalmars-d-learn wrote: [...] On Tuesday, 12 March 2019 at 09:05:36 UTC, Nicholas Wilson wrote: [...] > template FieldInfo(T) { > template FieldInfo(Nullable!(T) default_) > { > enum FieldInfo = 0; > } > } > > seems to work, but I can't seem to instantiate one of it. Why you use the same name "FieldInfo" for both the template and its subtemplate? Does it make some sense? This is a D idiom called the "eponymous template". Whenever the template contains a member of the same name as the template, it's an eponymous template, and you can refer directly to the member by the template name, rather than using templateName.memberName. For example, a template function is usually written like this: ReturnType myFunc(TemplateArgs...)(RuntimeArgs args...) { ... // implementation here } This is actually shorthand for the eponymous template: template myFunc(TemplateArgs...) { ReturnType myFunc(RuntimeArgs args...) { ... // implementation here } } Similarly, when you write: enum isInputRange(T) = hasMember!(T, empty) && ... that's actually shorthand for: template isInputRange(T) { enum isInputRange = hasMember!(T, empty) && ... } The eponymonus template idiom allows you to use a single name to refer to both the template and the member. Without this idiom, you'd have to use the very verbose notation: static if (isInputRange!T.isInputRange) ... or auto retval = myFunc!(A, B, C).myFunc(1, 2, 3); I know what is eponymous template. But how it behaves when the eponymous member inside itself is also a template? How to instantiate it? (provide please an example how to instantiate)
Re: inout auto ref escaping a reference to parameter, only errors with vibe Json type, or if inout is there.
On Monday, 11 March 2019 at 22:29:05 UTC, aliak wrote: Hi, I have an error that says "Error: returning `match1(opt)` escapes a reference to parameter `opt`, perhaps annotate with `return`". [...] Ok, I've found out something else. It only happens when you're returning a type that has an indirection. So instead of the Json type if we returned an S type where S was: struct S { void[2] data; } We get the same error.
Re: Why a template with Nullable does not compile?
On Tue, Mar 12, 2019 at 03:26:05PM +, Victor Porton via Digitalmars-d-learn wrote: [...] > On Tuesday, 12 March 2019 at 09:05:36 UTC, Nicholas Wilson wrote: [...] > > template FieldInfo(T) { > > template FieldInfo(Nullable!(T) default_) > > { > > enum FieldInfo = 0; > > } > > } > > > > seems to work, but I can't seem to instantiate one of it. > > Why you use the same name "FieldInfo" for both the template and its > subtemplate? Does it make some sense? This is a D idiom called the "eponymous template". Whenever the template contains a member of the same name as the template, it's an eponymous template, and you can refer directly to the member by the template name, rather than using templateName.memberName. For example, a template function is usually written like this: ReturnType myFunc(TemplateArgs...)(RuntimeArgs args...) { ... // implementation here } This is actually shorthand for the eponymous template: template myFunc(TemplateArgs...) { ReturnType myFunc(RuntimeArgs args...) { ... // implementation here } } Similarly, when you write: enum isInputRange(T) = hasMember!(T, empty) && ... that's actually shorthand for: template isInputRange(T) { enum isInputRange = hasMember!(T, empty) && ... } The eponymonus template idiom allows you to use a single name to refer to both the template and the member. Without this idiom, you'd have to use the very verbose notation: static if (isInputRange!T.isInputRange) ... or auto retval = myFunc!(A, B, C).myFunc(1, 2, 3); T -- It won't be covered in the book. The source code has to be useful for something, after all. -- Larry Wall
Re: Another Tuesday (Friday?), Another GtkDcoding Blog Post
On Tuesday, 12 March 2019 at 16:08:46 UTC, jmh530 wrote: Tricky. My thinking exactly. (I would have replied with a simple, "Yup," but I did that once before and the forum software made me do a Capcha.)
Re: Another Tuesday (Friday?), Another GtkDcoding Blog Post
On Tuesday, 12 March 2019 at 15:35:03 UTC, Ron Tarrant wrote: [snip] It's a learning resource, so wouldn't that go here? Or am I misinterpreting the intention of the Learn sub-forum? If you a moderator believes it should move, please feel free. It's a learning resource, sure, but you're also announcing a new blog post. Tricky.
Setting the GtkD Include Path in dexed?
I managed to get dexed to compile a single-file dub project, but for completeness sake, I'm also trying to configure it to use dmd (non-dub) to compile GtkD projects using Compilation (menu) > Compile File and Run. To that end, I have two questions... Should I be supplying dexed with the include (read: import) path: /usr/include/dmd/gtkd3/ Or the runtime: /usr/lib/x86_64-linux-gnu/libgtkd-3.so And where in dexed does one set the path so it can find a library such as gtkd?
Re: Another Tuesday (Friday?), Another GtkDcoding Blog Post
On Tuesday, 12 March 2019 at 15:15:00 UTC, jmh530 wrote: I thought the suggestion was one thread in the Announce forum, rather than multiple threads in the Announce forum...rather than one thread in the Learn forum. It's a learning resource, so wouldn't that go here? Or am I misinterpreting the intention of the Learn sub-forum? If you a moderator believes it should move, please feel free.
Re: Why does D language do not support BigDecimal type?
On Tuesday, 12 March 2019 at 09:31:53 UTC, Boqsc wrote: [snip] Please attach quick working examples for every sentence you write or it's just a waste of time. People want to see the results and direct actions first before anything else, it's more efficient communication. We are in the subforum of Dlang learn, after all. [snip] Honestly, I think this is a rather high burden to place on people. They are spending their valuable time to think about your question and answer it with what they think is the best response.
Re: Why a template with Nullable does not compile?
template FieldInfo(T, Nullable!T default_) { } On Tuesday, 12 March 2019 at 09:05:36 UTC, Nicholas Wilson wrote: It seems to be getting confused between the two types of Nullable, namely: Nullable(T), and Nullable(T, T defaultVal) I don't understand why exactly it is getting confused. How can it decide that "Nullable!T default_" is a two-arguments template when it is so not "Nullable!(T, default_)"? Please explain the EXACT cause of the error. template FieldInfo(T) { template FieldInfo(Nullable!(T) default_) { enum FieldInfo = 0; } } seems to work, but I can't seem to instantiate one of it. Why you use the same name "FieldInfo" for both the template and its subtemplate? Does it make some sense?
Re: ggplotd Fixed ratio between x and y axes
On Monday, 11 March 2019 at 23:34:06 UTC, kerdemdemir wrote: How can I configure a fixed ratio between x and y axes in ggplotd ? I easily found what I am looking for in ggplot which ggplotd inspires a lot. http://www.cookbook-r.com/Graphs/Axes_(ggplot2)/ But ggplotd documentation does not have any info about that. Even I go through the source code spend around half a hour I couldn't figure out how to achieve: sp <- ggplot(dat, aes(xval, yval)) + geom_point() sp + coord_fixed(ratio=1/3) Erdem I searched through ggplotd and the documentation and couldn't find it. Unless I'm mistaken, it would be an enhancement to add, and you have already filed a request: https://github.com/BlackEdder/ggplotd/issues/58
Re: Another Tuesday (Friday?), Another GtkDcoding Blog Post
On Tuesday, 12 March 2019 at 14:44:59 UTC, Ron Tarrant wrote: It was suggested that I do all these posts in one thread, so this is the thread where that'll happen. With that said... [snip] I thought the suggestion was one thread in the Announce forum, rather than multiple threads in the Announce forum...rather than one thread in the Learn forum.
Another Tuesday (Friday?), Another GtkDcoding Blog Post
It was suggested that I do all these posts in one thread, so this is the thread where that'll happen. With that said... It's Tuesday! (and that used to be a Theatresports game when Keith Johnstone still ran things) OR... It's Friday! And that (the Tuesday OR Friday part) means it's time for another post on the gtkDcoding blog. Here it is: http://gtkdcoding.com/2019/03/12/0017-change-pointer.html Today's topic: Changing the mouse pointer You'll be thrilled by the heart-shaped point and tickled by the Gumby. Man, this stuff is exciting! Sign up for RSS or follow on Facebook or drop me some email. Anyway. 'Nuff said.
Re: Why does D language do not support BigDecimal type?
On 12/03/2019 10:31, Boqsc via Digitalmars-d-learn wrote: Please attach quick working examples for every sentence you write or it's just a waste of time. People want to see the results and direct actions first before anything else, it's more efficient communication. We are in the subforum of Dlang learn, after all. Do not write "For Example". Then you may help people helping you by giving examples of your own use cases, first. I'm interested in writing a simple game prototype and I imagine that I would like to include some item parts in decimal. (100.00) To keep everything simple I would like to make my code as clean and simple as possible. From this single example, you don't need "fractal" (decimal or binary) numbers at all, just plain ints. Look up "fixed point arithmetics" on wikipedia, the article is rather good. It's easy and clean in comparison, at least if you only need simple operations. (That's how, by the way, monetary/financial software is or at least used to be implemented.) diniz
Re: Easiest way to display images
On Tuesday, 12 March 2019 at 02:21:51 UTC, Murilo wrote: Hi Adam, how do I set the color of the SimpleWindow background? You have to draw a rectangle on the window to make your own background. Set both outlineColor and fillColor to the same thing, then do painter.drawRectangle(Point(0, 0), Size(window.width, window.height));
Re: How are (Static) Libraries with Templates Compiled?
On 2019-03-11 21:59, jmh530 wrote: Ah, so you need the .lib files and the .di files to get it work. You need the .di or .d files regardless if it's a template or not. Because you need to know which declarations are available. In addition to that, for templates the source (and not just the declaration) need to be present as well in the .di/.d files. -- /Jacob Carlborg
Re: Why does D language do not support BigDecimal type?
On Tuesday, 12 March 2019 at 08:48:33 UTC, Cym13 wrote: On Monday, 11 March 2019 at 15:23:34 UTC, BoQsc wrote: There is Money datatype that can be provided by using a third party package: https://code.dlang.org/packages/money But that's only for money, what about math? Why such fundamental as BigDecimal is still not included into the D language itself? There is BigInt. If it is unavoidable to use Floating point, how can I quickly and simply understand the rules of using float to make the least error, or should I just find a third party package for that as well? There is an article on that, but it is not that straight forward: https://dlang.org/articles/d-floating-point.html Basically any thing that I find on Google, that include explaining floating point are badly written and hard to understand for the outsider lacking ability to understand advanced concepts. How much precision is enough in your use case? There's always a limit to how precise you need to be and how precise you can be, be it only because our memory is finite. I've never had a use case for BigDecimal myself, so forgive my ignorance, but wouldn't you get the exact same result by using BigInt? For example, if you need 20 decimals of precisions then any value times 10^20 will be a BigInt on which you can work, it's just a matter of displaying it correctly when outputing the result but it doesn't change the operations you have to perform. Is there anything that can't be done with BigInt really? Please attach quick working examples for every sentence you write or it's just a waste of time. People want to see the results and direct actions first before anything else, it's more efficient communication. We are in the subforum of Dlang learn, after all. Do not write "For Example". I'm interested in writing a simple game prototype and I imagine that I would like to include some item parts in decimal. (100.00) To keep everything simple I would like to make my code as clean and simple as possible. Floating points seems to require additional arithmetics - rounding and are inprecise when comparing. I do not want to deal with it every time. But if there is any standard simple documentation that I could include into my own game documentation to avoid confusion and make everything consisten, I would like to know. For now it seems that the only way to make it all simple is to use some kind of library to handle decimals for me, as I can't find any concise references on how to correctly use and understand floating points.
Re: Why does D language do not support BigDecimal type?
On Monday, 11 March 2019 at 15:23:34 UTC, BoQsc wrote: There is Money datatype that can be provided by using a third party package: https://code.dlang.org/packages/money But that's only for money, what about math? Why such fundamental as BigDecimal is still not included into the D language itself? There is BigInt. If it is unavoidable to use Floating point, how can I quickly and simply understand the rules of using float to make the least error, or should I just find a third party package for that as well? There is an article on that, but it is not that straight forward: https://dlang.org/articles/d-floating-point.html Basically any thing that I find on Google, that include explaining floating point are badly written and hard to understand for the outsider lacking ability to understand advanced concepts. I recommend that you learn floating point math as this will help you not only in programming in D, but in any other language. In any case, if you need super-high precision, you might want to give decimal [1] a try. [1] https://code.dlang.org/packages/decimal
Re: Why does D language do not support BigDecimal type?
On Monday, 11 March 2019 at 15:23:34 UTC, BoQsc wrote: If it is unavoidable to use Floating point, how can I quickly and simply understand the rules of using float to make the least error, or should I just find a third party package for that as well? It's taught in a computational mathematics course. In short, you estimate how errors accumulate over operations in your algorithm, e.g. for a sum operation `x+y` of values with errors you have (x±dx)+(y±dy)±r, for which you calculate the range of values: minimum is x-dx+y-dy-r, maximum is x+dx+y+dy+r, so the error is dx+dy+r, where r is a rounding error, this error gets carried over to subsequent calculations. Similar for other operations. See for example https://en.wikipedia.org/wiki/Round-off_error#Accumulation_of_roundoff_error
Re: Why a template with Nullable does not compile?
On Tuesday, 12 March 2019 at 05:14:21 UTC, Victor Porton wrote: Why does this not compile? import std.typecons; template FieldInfo(T, Nullable!T default_) { } /usr/lib/ldc/x86_64-linux-gnu/include/d/std/typecons.d(2570,17): Error: `alias T = T;` cannot alias itself, use a qualified name to create an overload set /usr/lib/ldc/x86_64-linux-gnu/include/d/std/typecons.d(3291,17): Error: `alias T = T;` cannot alias itself, use a qualified name to create an overload set It seems to be getting confused between the two types of Nullable, namely: Nullable(T), and Nullable(T, T defaultVal) template FieldInfo(T) { template FieldInfo(Nullable!(T) default_) { enum FieldInfo = 0; } } seems to work, but I can't seem to instantiate one of it.
Re: Why does D language do not support BigDecimal type?
On Monday, 11 March 2019 at 15:23:34 UTC, BoQsc wrote: There is Money datatype that can be provided by using a third party package: https://code.dlang.org/packages/money But that's only for money, what about math? Why such fundamental as BigDecimal is still not included into the D language itself? There is BigInt. If it is unavoidable to use Floating point, how can I quickly and simply understand the rules of using float to make the least error, or should I just find a third party package for that as well? There is an article on that, but it is not that straight forward: https://dlang.org/articles/d-floating-point.html Basically any thing that I find on Google, that include explaining floating point are badly written and hard to understand for the outsider lacking ability to understand advanced concepts. How much precision is enough in your use case? There's always a limit to how precise you need to be and how precise you can be, be it only because our memory is finite. I've never had a use case for BigDecimal myself, so forgive my ignorance, but wouldn't you get the exact same result by using BigInt? For example, if you need 20 decimals of precisions then any value times 10^20 will be a BigInt on which you can work, it's just a matter of displaying it correctly when outputing the result but it doesn't change the operations you have to perform. Is there anything that can't be done with BigInt really?