Re: Generating code based on UDA

2014-10-25 Thread Shammah Chancellor via Digitalmars-d-learn
On 2014-10-25 13:37:54 +, Rares Pop said: Hello everyone, I am trying to understand UDA traits scoping while mixing in code. Aiming to generate code based on UDA I wonder if the following is possible: class A { @Inject Logger logger; @Inject SomeOtherClass dependency;

Re: package reflection

2014-06-22 Thread Shammah Chancellor via Digitalmars-d-learn
On 2014-06-22 14:11:58 +, sigod said: In the video Case Studies In Simplifying Code With Compile-Time Reflection [was pointed out][0] that it is possible to reflect on imported packages. So, I tried: reflection.d: ``` import std.stdio; import test.module1; import test.module2; void

Non-blocking array queue.

2014-03-08 Thread Shammah Chancellor
Hi, I'm interesting in implementing a non-blocking queue. My thought is to use a fixed-size array, and increment back of the queue with a integer. I was thinking I could make this non-blocking via an atomic increment operation before assigning the pushed value onto the queue. So, my

Re: Non-blocking array queue.

2014-03-08 Thread Shammah Chancellor
On 2014-03-08 19:58:01 +, Martin said: On Saturday, 8 March 2014 at 19:02:26 UTC, Shammah Chancellor wrote: Hi, I'm interesting in implementing a non-blocking queue. My thought is to use a fixed-size array, and increment back of the queue with a integer. I was thinking I could make

Re: Non-blocking array queue.

2014-03-08 Thread Shammah Chancellor
On 2014-03-08 21:16:36 +, Martin said: On Saturday, 8 March 2014 at 21:12:42 UTC, Shammah Chancellor wrote: On 2014-03-08 19:58:01 +, Martin said: On Saturday, 8 March 2014 at 19:02:26 UTC, Shammah Chancellor wrote: Hi, I'm interesting in implementing a non-blocking queue. My

Re: Searching for a string in a text buffer with a regular expression

2013-12-06 Thread Shammah Chancellor
On 2013-12-06 08:53:04 +, maxpat78 said: While porting a simple Python script to D, I found the following problem. I need to read in some thousand of little text files and search every one for a match with a given regular expression. Obviously, the program can't (and it should not) be

Re: Monads compared to InputRanges?

2013-12-04 Thread Shammah Chancellor
On 2013-12-04 08:24:02 +, qznc said: On Wednesday, 4 December 2013 at 01:53:39 UTC, Shammah Chancellor wrote: Or is D syntax not generic enough to define monads? I started to port monads to D [0]. You can do it, but it looks ugly. The trick is to implement (Haskell) type classes via

Re: Monads compared to InputRanges?

2013-12-03 Thread Shammah Chancellor
On 2013-12-03 21:51:20 +, Max Klyga said: On 2013-12-03 02:45:44 +, Shammah Chancellor said: I'm not particularly familiar with the syntax being used in the variet of monad examples. I'm trying to figure out how this is different from UFCS on InputRanges. It seems like

Re: Monads compared to InputRanges?

2013-12-03 Thread Shammah Chancellor
On 2013-12-03 23:49:47 +, Max Klyga said: On 2013-12-03 23:02:13 +, Shammah Chancellor said: On 2013-12-03 21:51:20 +, Max Klyga said: On 2013-12-03 02:45:44 +, Shammah Chancellor said: I'm not particularly familiar with the syntax being used in the variet of monad

Monads compared to InputRanges?

2013-12-02 Thread Shammah Chancellor
I'm not particularly familiar with the syntax being used in the variet of monad examples. I'm trying to figure out how this is different from UFCS on InputRanges. It seems like std.algorithm implements something which accomplished the same thing, but much easier to understand? Can

Re: TypeInfo.compare is not implemented

2013-11-30 Thread Shammah Chancellor
On 2013-11-30 13:39:15 +, Leandro Motta Barros said: Hello, I my FewDee game prototyping library (https://bitbucket.org/lmb/fewdee) I ignored most of the usual reccomendations like be careful with the GC, it's slow and associative arrays are buggy in D, so avoid them. I just used

Re: casting as char at CT fail

2013-11-28 Thread Shammah Chancellor
On 2013-11-28 03:40:25 +, Kenji Hara said: On Tuesday, 26 November 2013 at 23:31:16 UTC, bioinfornatics wrote: Hi, this time i have so many question about CT … iws and ibuclaw help me for this. I stuck currently about a cast at CT - http://www.dpaste.dzfl.pl/1a28a22c it seem this should

Re: D code beautifier

2013-11-28 Thread Shammah Chancellor
On 2013-11-28 22:28:54 +, seany said: does such a thing exist? like html code beautifiers? Most IDE's support this. Try Xamarin Studio with MonoD. http://mono-d.alexanderbothe.com

Re: casting as char at CT fail

2013-11-27 Thread Shammah Chancellor
On 2013-11-27 06:06:49 +, bioinfornatics said: On Wednesday, 27 November 2013 at 01:22:07 UTC, Shammah Chancellor wrote: On 2013-11-26 23:31:14 +, bioinfornatics said: Hi, this time i have so many question about CT … iws and ibuclaw help me for this. I stuck currently about a cast

Re: template operator overload

2013-11-27 Thread Shammah Chancellor
On 2013-11-27 16:07:50 +, Namespace said: Just out of curiosity: Is it possible to call an overloaded operator with a template type? import std.stdio; struct A { void opIndex(T)(size_t index) { } } void main() { A a; a.opIndex!int(0);

Re: std.concurrency and immutable

2013-11-26 Thread Shammah Chancellor
On 2013-11-25 20:55:15 +, Antoche said: On Monday, 25 November 2013 at 11:48:06 UTC, Shammah Chancellor wrote: On 2013-11-25 06:03:27 +, Antoche said: The following code compiles but doesn't work as expected: import std.stdio; import std.concurrency; class A { this() immutable

Re: recursive template at ctfe

2013-11-26 Thread Shammah Chancellor
On 2013-11-26 21:00:56 +, bioinfornatics said: On Tuesday, 26 November 2013 at 20:50:13 UTC, bioinfornatics wrote: On Tuesday, 26 November 2013 at 20:29:00 UTC, bearophile wrote: bioinfornatics: I wrote some template to compute at compile time how many bits is need for a number x.

Re: recursive template at ctfe

2013-11-26 Thread Shammah Chancellor
On 2013-11-26 21:31:55 +, bioinfornatics said: On Tuesday, 26 November 2013 at 21:18:29 UTC, Shammah Chancellor wrote: On 2013-11-26 21:00:56 +, bioinfornatics said: On Tuesday, 26 November 2013 at 20:50:13 UTC, bioinfornatics wrote: On Tuesday, 26 November 2013 at 20:29:00 UTC

Re: casting as char at CT fail

2013-11-26 Thread Shammah Chancellor
On 2013-11-26 23:31:14 +, bioinfornatics said: Hi, this time i have so many question about CT … iws and ibuclaw help me for this. I stuck currently about a cast at CT - http://www.dpaste.dzfl.pl/1a28a22c it seem this should works but not… So if you confirm maybe a report is needed thanks

Re: std.concurrency and immutable

2013-11-25 Thread Shammah Chancellor
On 2013-11-25 06:03:27 +, Antoche said: The following code compiles but doesn't work as expected: import std.stdio; import std.concurrency; class A { this() immutable {} } void main() { auto tid = spawn( fooBar, thisTid );

Re: Cleverness of the compiler

2013-11-25 Thread Shammah Chancellor
On 2013-11-25 10:34:39 +, Namespace said: On Monday, 25 November 2013 at 03:13:48 UTC, Shammah Chancellor wrote: On 2013-11-25 00:08:50 +, Namespace said: I love this feature, but I'm unsure how it works. Can someone explain me, how the compiler deduce that he should read 4 bytes

Re: std.concurrency and immutable

2013-11-25 Thread Shammah Chancellor
On 2013-11-25 14:08:53 +, Dicebot said: Sending immutable classes currently does not work because of https://d.puremagic.com/issues/show_bug.cgi?id=7069 (and has never worked despite being intended). Can you send immutable struct references?

Re: Enum of functions?

2013-11-25 Thread Shammah Chancellor
On 2013-11-25 23:32:25 +, Chris Williams said: Is there any way to do something like this? import std.stdio; enum Foo : void function() { WOMBAT = () {writeln(Wombat);} } void doStuff(Foo f) { f(); } int main() { doStuff( Foo.WOMBAT ); return 0;

Re: Composing features at compile time

2013-11-24 Thread Shammah Chancellor
Based on what your actual problem is -- it seems like you need to refactor your code a little. Also, you should trust that the compiler optimizes correctly. eg. if( valueMeta.isValid pointersSupported) should be optimized out when pointerSupported == false and the comparison of it

Re: Cleverness of the compiler

2013-11-24 Thread Shammah Chancellor
On 2013-11-25 00:08:50 +, Namespace said: I love this feature, but I'm unsure how it works. Can someone explain me, how the compiler deduce that he should read 4 bytes for each index (the 'at' function)? The type is void*, not int*. It doesn't work. That code is buggy. It's overwriting

Re: std.json

2013-11-13 Thread Shammah Chancellor
On 2012-05-17 14:08:26 +, Vincent said: On Sunday, 25 March 2012 at 17:50:45 UTC, Andrea Fontana wrote: Hope it's clear... Nope, it's something like chess and have nothing common with simplicity of the real JSON usage! This is example from C#: var p =

Reflecting on a module

2013-11-06 Thread Shammah Chancellor
How does one reflect on all the classes in a module? I would like to read their attributes and generate an enum from attributes on said classes.