Re: CTFE fmod ?

2015-11-20 Thread userABCabc123 via Digitalmars-d-learn
On Friday, 20 November 2015 at 13:44:11 UTC, rumbu wrote: On Friday, 20 November 2015 at 11:16:13 UTC, userABCabc123 wrote: [...] [...] Not thoroughly tested and only works for doubles, but this must do the trick. [...] Thx, it works, easy to adapt to float.

template this and traits getOverloads issue.

2015-11-20 Thread BBasile via Digitalmars-d-learn
Background: === http://stackoverflow.com/questions/33764540/warning-about-overriden-methods-when-using-a-mixin Why this horrible trick has to be used: === cast this as (T) in a function template that's been mixed in an ancestor is not always usable,

Re: template this and traits getOverloads issue.

2015-11-20 Thread Alex Parrill via Digitalmars-d-learn
Alternatively, you can use a static method and pass in the instance. Note that `new B` will print A's members twice, because A's constructor is always called and `__traits(allMembers, B)` includes A's members. --- import std.stdio; mixin template Bug() { import std.traits; static

Re: CTFE fmod ?

2015-11-20 Thread rumbu via Digitalmars-d-learn
On Friday, 20 November 2015 at 11:16:13 UTC, userABCabc123 wrote: Does someone have a good CTFE fmod() function ? The problem is that std.math.fmod() is itself not available at CT, neither do floor() or similar functions necessary to get the quotient when the input value is two times

Re: template this and traits getOverloads issue.

2015-11-20 Thread BBasile via Digitalmars-d-learn
On Friday, 20 November 2015 at 14:18:00 UTC, Alex Parrill wrote: If the mixin has to be used on class and on struct, I cant use an interface. In this case override will create an error and go back to the solution on SO: statically check if things are already there. Templates are not

Re: template this and traits getOverloads issue.

2015-11-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 20 November 2015 at 14:18:00 UTC, Alex Parrill wrote: But you don't need a template for this case; mixin templates have access to `this`: Indeed, this is a good answer too. The difference between this and the template thing I did is that yours is virtual so calling it through an

Re: template this and traits getOverloads issue.

2015-11-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 20 November 2015 at 14:01:13 UTC, BBasile wrote: everything that can be done to avoid the compilations errors will also prevent "bar" to be written in the output (because a B will never be analyzed). The "only" fix I see is like in the stack overflow answer: statically check if the

Re: template this and traits getOverloads issue.

2015-11-20 Thread Alex Parrill via Digitalmars-d-learn
On Friday, 20 November 2015 at 14:01:13 UTC, BBasile wrote: Background: === http://stackoverflow.com/questions/33764540/warning-about-overriden-methods-when-using-a-mixin Why this horrible trick has to be used: === cast this as (T) in a function

Re: Thread in detached state?

2015-11-20 Thread Ish via Digitalmars-d-learn
On Thursday, 19 November 2015 at 22:07:19 UTC, ZombineDev wrote: On Friday, 13 November 2015 at 15:35:11 UTC, Ish wrote: [...] If you're more familiar with pthreads, you can just use them from core.sys.posix.pthread [1]. After all this what core.thread uses on Posix [2]. In general you can

Re: template this and traits getOverloads issue.

2015-11-20 Thread BBasile via Digitalmars-d-learn
On Friday, 20 November 2015 at 14:39:29 UTC, Alex Parrill wrote: Alternatively, you can use a static method and pass in the instance. Initially this solution looked awesome but when `bug()` is static, `` returns some functions, not some delegates, which is a problem: this implies that I have

CTFE fmod ?

2015-11-20 Thread userABCabc123 via Digitalmars-d-learn
Does someone have a good CTFE fmod() function ? The problem is that std.math.fmod() is itself not available at CT, neither do floor() or similar functions necessary to get the quotient when the input value is two times over/under the bounds. Currently I have this one... --- auto warp(T)(T x,

Re: std.experimental.allocator optlink error

2015-11-20 Thread Ilya Yaroshenko via Digitalmars-d-learn
On Friday, 20 November 2015 at 12:31:37 UTC, Tofu Ninja wrote: On Tuesday, 10 November 2015 at 11:39:56 UTC, Rikki Cattermole wrote: One already exists. I've confirmed it in the build scripts. It only effects Windows. Any fix for this right now? No,

Re: std.experimental.allocator optlink error

2015-11-20 Thread Rikki Cattermole via Digitalmars-d-learn
On 21/11/15 1:31 AM, Tofu Ninja wrote: On Tuesday, 10 November 2015 at 11:39:56 UTC, Rikki Cattermole wrote: One already exists. I've confirmed it in the build scripts. It only effects Windows. Any fix for this right now? Dunno if its been fixed in ~master (doubt it), but all you need to do

Re: std.experimental.allocator optlink error

2015-11-20 Thread Tofu Ninja via Digitalmars-d-learn
On Tuesday, 10 November 2015 at 11:39:56 UTC, Rikki Cattermole wrote: One already exists. I've confirmed it in the build scripts. It only effects Windows. Any fix for this right now?

Re: template this and traits getOverloads issue.

2015-11-20 Thread BBasile via Digitalmars-d-learn
On Friday, 20 November 2015 at 14:49:28 UTC, Adam D. Ruppe wrote: On Friday, 20 November 2015 at 14:01:13 UTC, BBasile wrote: everything that can be done to avoid the compilations errors will also prevent "bar" to be written in the output (because a B will never be analyzed). The "only" fix I

Re: std.experimental.allocator optlink error

2015-11-20 Thread Tofu Ninja via Digitalmars-d-learn
On Friday, 20 November 2015 at 12:49:02 UTC, Rikki Cattermole wrote: Dunno if its been fixed in ~master (doubt it), but all you need to do in your code, is copy it in. Cool, that worked. I've personally marked (well voted anyway) for this bug to be critical. It seems I'm the only one who

Re: template this and traits getOverloads issue.

2015-11-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 20 November 2015 at 15:43:00 UTC, BBasile wrote: One last question: is it possible to nest the calls to functions that take this kind of parameters ? auto this_ = cast(T) this; this_.bug0(); this_.bug1();

Re: scope keyword

2015-11-20 Thread Alex Parrill via Digitalmars-d-learn
On Thursday, 19 November 2015 at 23:16:04 UTC, Spacen Jasset wrote: I thought scope was deprecated, but I see that this is still here: http://dlang.org/attribute.html#scope Is it just the uses on classes and local variables that are discouraged, but the use in a function signature will

Re: GTKD TreeView - Delete TreeView SubItem with Button?

2015-11-20 Thread Michael Robertson via Digitalmars-d-learn
On Friday, 20 November 2015 at 17:09:50 UTC, TheDGuy wrote: Hello, is it possible, to delete a selected TreeView SubItem with a Button-Click? My Code currently looks like this: import gtk.MainWindow; import gtk.Box; import gtk.Main; import gtk.Button; import gdk.Event; import gtk.Widget;

GTKD TreeView - Delete TreeView SubItem with Button?

2015-11-20 Thread TheDGuy via Digitalmars-d-learn
Hello, is it possible, to delete a selected TreeView SubItem with a Button-Click? My Code currently looks like this: import gtk.MainWindow; import gtk.Box; import gtk.Main; import gtk.Button; import gdk.Event; import gtk.Widget; import List, Languages; void main(string[] args){

Re: GTKD TreeView - Delete TreeView SubItem with Button?

2015-11-20 Thread Michael Robertson via Digitalmars-d-learn
On Friday, 20 November 2015 at 19:45:26 UTC, TheDGuy wrote: So like this? public void remove(TreeIter iter) { this.remove(iter); } If i do this, i get a stackoverflow error :( Your List inherits from TreeStore correct? just get rid of your custom

Re: dataframe implementations

2015-11-20 Thread jmh530 via Digitalmars-d-learn
On Thursday, 19 November 2015 at 06:33:06 UTC, Jay Norwood wrote: Maybe the nd slices could be applied if you considered each row to be the same structure, and slice by rows rather than operating on columns. Pandas supports a multi-dimension panel. Maybe this would be the application for

Re: GTKD TreeView - Delete TreeView SubItem with Button?

2015-11-20 Thread Justin Whear via Digitalmars-d-learn
On Fri, 20 Nov 2015 18:57:10 +, TheDGuy wrote: > Thanks for your reply, > > now it gets more clear for me but how am i able to access the TreeView > within the CustomButton-Class? If i declare TreeView and TreeStore > public i get "static variable list cannot be read at compile time"? > >

Re: GTKD TreeView - Delete TreeView SubItem with Button?

2015-11-20 Thread TheDGuy via Digitalmars-d-learn
Ahh, okay. Thank you very much for your help, now everything works fine :)

Re: template this and traits getOverloads issue.

2015-11-20 Thread BBasile via Digitalmars-d-learn
On Friday, 20 November 2015 at 15:03:06 UTC, Adam D. Ruppe wrote: On Friday, 20 November 2015 at 14:18:00 UTC, Alex Parrill wrote: But you don't need a template for this case; mixin templates have access to `this`: Indeed, this is a good answer too. The difference between this and the

Re: GTKD TreeView - Delete TreeView SubItem with Button?

2015-11-20 Thread TheDGuy via Digitalmars-d-learn
Thanks for your reply, now it gets more clear for me but how am i able to access the TreeView within the CustomButton-Class? If i declare TreeView and TreeStore public i get "static variable list cannot be read at compile time"? import gtk.MainWindow; import gtk.Box; import gtk.Main;

Re: GTKD TreeView - Delete TreeView SubItem with Button?

2015-11-20 Thread TheDGuy via Digitalmars-d-learn
Thanks for your reply, is it also possible to do it like this? import gtk.MainWindow; import gtk.Box; import gtk.Main; import gtk.Button; import gdk.Event; import gtk.Widget; import List, Languages; void main(string[] args){ Main.init(args); MainWindow win = new

Compile time strings auto concatenation!?

2015-11-20 Thread Ilya via Digitalmars-d-learn
Can DMD frontend optimize string concatenation ``` enum Double(S) = S ~ S; assert(condition, "Text " ~ Double!"+" ~ ___FUNCTION__); ``` to ``` assert(condition, "Text ++_function_name_"); ``` ?

Re: GTKD TreeView - Delete TreeView SubItem with Button?

2015-11-20 Thread Justin Whear via Digitalmars-d-learn
On Fri, 20 Nov 2015 19:34:01 +, TheDGuy wrote: > Thanks for your reply, > > is it also possible to do it like this? > Yeah, that'll work. > but now i get the error: > > "rowDeleted is not callable using argument types (TreeIter)"? rowDeleted is just to emit the signal that a row has

Re: GTKD TreeView - Delete TreeView SubItem with Button?

2015-11-20 Thread TheDGuy via Digitalmars-d-learn
So like this? public void remove(TreeIter iter) { this.remove(iter); } If i do this, i get a stackoverflow error :(

Re: GTKD TreeView - Delete TreeView SubItem with Button?

2015-11-20 Thread Justin Whear via Digitalmars-d-learn
On Fri, 20 Nov 2015 19:45:25 +, TheDGuy wrote: > So like this? > > public void remove(TreeIter iter) > { > this.remove(iter); > } > > If i do this, i get a stackoverflow error :( That's creating an infinite recursion as the method simply calls itself.

Re: Compile time strings auto concatenation!?

2015-11-20 Thread Justin Whear via Digitalmars-d-learn
On Fri, 20 Nov 2015 20:39:57 +, Ilya wrote: > Can DMD frontend optimize > string concatenation > ``` > enum Double(S) = S ~ S; > > assert(condition, "Text " ~ Double!"+" ~ ___FUNCTION__); > ``` > > to > > ``` > assert(condition, "Text ++_function_name_"); > > ``` > ? Yes this occurs as

Build utf.d with MS-COFF failed

2015-11-20 Thread Pierre via Digitalmars-d-learn
Hello, I can't build my project with MS-COFF option. I'm using DMD 2.069. I got this error : utf.d(1109) : invalid UTF-8 sequence (at index 1) I used these options with visual D: Compiler : DMD D-Version : D2 Output Type: DLL Subsystem : Not set Compilation: Combined

Re: char[] == null

2015-11-20 Thread Maxim Fomin via Digitalmars-d-learn
On Thursday, 19 November 2015 at 15:36:44 UTC, Steven Schveighoffer wrote: On 11/19/15 3:30 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Wednesday, November 18, 2015 22:15:19 anonymous via Digitalmars-d-learn wrote: On 18.11.2015 22:02, rsw0x wrote: slices aren't arrays

Re: Manually allocate delegate?

2015-11-20 Thread userABCabc123 via Digitalmars-d-learn
On Sunday, 12 July 2015 at 09:03:25 UTC, Tofu Ninja wrote: On Sunday, 12 July 2015 at 08:47:37 UTC, ketmar wrote: On Sun, 12 Jul 2015 08:38:00 +, Tofu Ninja wrote: Is it even possible? what do you mean? Sorry, thought the title was enough. The context for a delegate(assuming not a

RAII trouble

2015-11-20 Thread Spacen Jasset via Digitalmars-d-learn
I have the following code in attempt to create an RAII object wrapper, but it seems that it might be impossible. The problem here is that FT_Init_FreeType is a static which is set at some previous time to a function entry point in the FreeType library. I could use a scope block, but would

Re: RAII trouble

2015-11-20 Thread Ali Çehreli via Digitalmars-d-learn
On 11/20/2015 02:56 PM, Spacen Jasset wrote: > FT_Init_FreeType is a static which is set at some previous time to a > function entry point in the FreeType library. > text.d(143,15): Error: static variable FT_Init_FreeType cannot be read > at compile time The compiler seems to think that

Re: RAII trouble

2015-11-20 Thread anonymous via Digitalmars-d-learn
On 20.11.2015 23:56, Spacen Jasset wrote: The ideal would be to have a struct that can be placed inside a function scope, or perhaps as a module global variable. Why does Ft_Init_FreeType have to be read at compile time? text.d(143,15): Error: static variable FT_Init_FreeType cannot be read at

Re: RAII trouble

2015-11-20 Thread Spacen Jasset via Digitalmars-d-learn
On Friday, 20 November 2015 at 23:21:03 UTC, anonymous wrote: [...] FT_Init_FreeType must be read at compile time, because freeType is a module level variable, and initializers for module variables must be static values. The initializer is run through CTFE (Compile Time Function Evaluation).

Re: RAII trouble

2015-11-20 Thread Spacen Jasset via Digitalmars-d-learn
On Friday, 20 November 2015 at 23:35:50 UTC, Spacen Jasset wrote: On Friday, 20 November 2015 at 23:21:03 UTC, anonymous wrote: [...] FT_Init_FreeType must be read at compile time, because freeType is a module level variable, and initializers for module variables must be static values. The

Re: Build utf.d with MS-COFF failed

2015-11-20 Thread Charles via Digitalmars-d-learn
On Friday, 20 November 2015 at 21:27:12 UTC, Pierre wrote: Hello, I can't build my project with MS-COFF option. I'm using DMD 2.069. I got this error : utf.d(1109) : invalid UTF-8 sequence (at index 1) I used these options with visual D: Compiler : DMD D-Version : D2 Output Type

why --shebang for rdmd?

2015-11-20 Thread Shriramana Sharma via Digitalmars-d-learn
Hello. The following code works fine for me: #! /usr/bin/env rdmd import std.stdio; void main() { writeln(2); } So what is the use of the --shebang option of rdmd? http://dlang.org/rdmd.html does not shed much light on this. Thanks. -- Shriramana Sharma, Penguin #395953

Re: D equivalent of Python's try..else

2015-11-20 Thread Ali Çehreli via Digitalmars-d-learn
On 11/20/2015 09:45 PM, Shriramana Sharma wrote: Hello. In Python one has the syntax try..except..else.. where code in the else clause will only be executed if an exception does not occur. (Ref: http://stackoverflow.com/a/22579805/1503120) In D, is there such an idiomatic/canonical construct?

Re: D equivalent of Python's try..else

2015-11-20 Thread rsw0x via Digitalmars-d-learn
On Saturday, 21 November 2015 at 05:45:37 UTC, Shriramana Sharma wrote: Hello. In Python one has the syntax try..except..else.. where code in the else clause will only be executed if an exception does not occur. (Ref: http://stackoverflow.com/a/22579805/1503120) In D, is there such an

Re: D equivalent of Python's try..else

2015-11-20 Thread Shriramana Sharma via Digitalmars-d-learn
rsw0x wrote: > scope(failure) can be used to run code when an exception is > thrown inside the scope, and scope(success) only triggers if the > scope exited successfully > > http://ddili.org/ders/d.en/scope.html Thanks but I know that and it executes only at the point of scope exit. But I want

Re: D equivalent of Python's try..else

2015-11-20 Thread Shriramana Sharma via Digitalmars-d-learn
Shriramana Sharma wrote: > In Python one has the syntax try..except..else.. where code in the > else clause will only be executed if an exception does not occur. (Ref: > http://stackoverflow.com/a/22579805/1503120) Official Python documentation:

D equivalent of Python's try..else

2015-11-20 Thread Shriramana Sharma via Digitalmars-d-learn
Hello. In Python one has the syntax try..except..else.. where code in the else clause will only be executed if an exception does not occur. (Ref: http://stackoverflow.com/a/22579805/1503120) In D, is there such an idiomatic/canonical construct? The D try statement only seems to support finally

`finally` is redundant?

2015-11-20 Thread Shriramana Sharma via Digitalmars-d-learn
The page http://dlang.org/exception-safe.html says: "It's try-finally that becomes redundant." IIUC this is because we have scope(exit). Does this mean that `finally` should eventually be removed from the language? -- Shriramana Sharma, Penguin #395953

Re: D equivalent of Python's try..else

2015-11-20 Thread rsw0x via Digitalmars-d-learn
On Saturday, 21 November 2015 at 05:55:53 UTC, Shriramana Sharma wrote: rsw0x wrote: scope(failure) can be used to run code when an exception is thrown inside the scope, and scope(success) only triggers if the scope exited successfully http://ddili.org/ders/d.en/scope.html Thanks but I