Re: CTFE, string mixins & code generation

2020-01-24 Thread Marco de Wild via Digitalmars-d-learn
On Friday, 24 January 2020 at 16:21:48 UTC, Jan Hönig wrote: I am looking for a detailed explanation or showcase regarding CTFE and string mixins. I want to play with D a little bit regarding code generation. I would like to have a pseudo-AST, consisting of a few classes, to represent some

Re: Anyway to compare function aliases? Or any ideas?

2019-07-04 Thread Marco de Wild via Digitalmars-d-learn
On Thursday, 4 July 2019 at 15:10:05 UTC, aliak wrote: Any ideas on how to be able to do something like this? struct S(alias _fun) { alias Fun = _fun; } void algorithm(alias f, T)(T s) { static if ( == ) { // trivial return } else { // must perform work, then return } } Can

Re: How to convert array of structs to JSON

2019-06-24 Thread Marco de Wild via Digitalmars-d-learn
On Tuesday, 25 June 2019 at 05:33:57 UTC, mark wrote: I have the following array of structs: struct Person { string name; int age; }; Person people[]; Person p; Person p1 = { "Bob", 12 }; Person p2 = { "Bob", 12 }; people ~= p1; people ~= p2; I've read through the

Re: What is iota function full name

2019-06-21 Thread Marco de Wild via Digitalmars-d-learn
On Friday, 21 June 2019 at 19:18:02 UTC, KnightMare wrote: On Friday, 21 June 2019 at 12:02:10 UTC, Jonathan M Davis wrote: On Friday, June 21, 2019 5:10:03 AM MDT JN via Some folks argued a while back that iota was a terrible name and that it should be changed, but it was decided not to

Re: is there any micro-service library in D?

2019-06-19 Thread Marco de Wild via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 08:29:15 UTC, dangbinghoo wrote: hi there, Does anyone know the micro-service oriented design library or framework in D? thanks! binghoo dang What do you need from such a library? Some suggestions: For networking, there is vibe.d[0] which provides both

Re: Component based programming in D

2019-06-18 Thread Marco de Wild via Digitalmars-d-learn
On Tuesday, 18 June 2019 at 09:17:09 UTC, Bart wrote: I'm new to component based programming. I've read it is an alternative to oop for speed. I don't understand how it is possible to have an alternative to oop and still have oop like behavior(polymorphism) nor how to do this. It seems all the

Re: Proper desctructor for an class containing dynamic array of objects

2019-06-14 Thread Marco de Wild via Digitalmars-d-learn
On Thursday, 13 June 2019 at 16:08:52 UTC, Mike wrote: Hi, my name is Mike and I'm new to D (coming from a Javabackground) and for fun I'm trying to learn D now. I created a simple class class Block { int a, b; this() {} } And now I have a dynamic array of objects of this class in

Re: Where can I find a reference for compiler flags?

2019-06-09 Thread Marco de Wild via Digitalmars-d-learn
On Sunday, 9 June 2019 at 19:12:32 UTC, Mike Brockus wrote: On Wednesday, 5 June 2019 at 09:45:53 UTC, Jacob Carlborg wrote: On 2019-06-05 03:19, Mike Brockus wrote: Where can I find a reference for compiler flags? Here's the reference [1]. You can also run "dmd --help" to print out the

Re: Casting to interface not allowed in @safe code?

2019-05-21 Thread Marco de Wild via Digitalmars-d-learn
On Tuesday, 21 May 2019 at 05:51:30 UTC, Jim wrote: Hi, consider this: interface Base { void setup(); } interface FeatureX { void x(); } class Foo: Base, FeatureX { void setup(){}; void x(){}; } void main() { Base foo = new Foo(); // This would be the result of a factory class

Re: Stack-based @nogc dynamic array

2019-05-17 Thread Marco de Wild via Digitalmars-d-learn
Thank you both for the quick replies. On Thursday, 16 May 2019 at 12:55:34 UTC, Kagamin wrote: Try mach.d https://github.com/pineapplemachine/mach.d it uses explicit range accessors for iteration. Thank you. I've looked into it, and it appears to be quite a big library. I've looked into

Re: Stack-based @nogc dynamic array

2019-05-17 Thread Marco de Wild via Digitalmars-d-learn
On Thursday, 16 May 2019 at 12:45:03 UTC, Adam D. Ruppe wrote: I think you have overcomplicated something quite simple. int[4] buffer; int bufferLength; buffer[bufferLength++] = item_to_append; buffer[bufferLength++] = item_to_append; int[] slice = buffer[0 .. bufferLength]; // you can use

Stack-based @nogc dynamic array

2019-05-16 Thread Marco de Wild via Digitalmars-d-learn
Hey all, I want to create a small collection of items to store intermediate results of a calculation. It runs on a background thread, so it does not need to be the most efficient implementation. However, I want to prevent my background thread introducing a stop-the-world garbage collection.

Re: Dub fetch

2019-05-12 Thread Marco de Wild via Digitalmars-d-learn
On Saturday, 11 May 2019 at 14:27:50 UTC, Russel Winder wrote: Hi, Is there a way of asking which version of package XXX "dub fetch XXX" will actually fetch. I would like to avoid checking the contents of ~/.dub/packages before and after. Use the `--annotate` option: $ dub fetch dlangide

Re: Pass template parameter into q{} string

2019-04-02 Thread Marco de Wild via Digitalmars-d-learn
On Monday, 1 April 2019 at 17:32:29 UTC, Andrey wrote: Hello, enum Key : string { First = "qwerty", Last = "zaqy" } void main() { enum decl(alias values1) = q{ static foreach(value; values1) mixin("bool " ~ value ~ " = false;"); }; enum qqq

Re: Is there a way to replace Exception with as a macro in C?

2019-02-18 Thread Marco de Wild via Digitalmars-d-learn
On Tuesday, 19 February 2019 at 05:50:04 UTC, yisooan wrote: I wonder there is the way as I said in the title. For instance, in C, #define indexInvalidException Exception("The index is invalid") /* Do something with the macro here */ if (false) indexInvalidException; This is allowed. But

Re: Best practices of using const

2019-02-17 Thread Marco de Wild via Digitalmars-d-learn
On Wednesday, 13 February 2019 at 16:40:18 UTC, H. S. Teoh wrote: On Wed, Feb 13, 2019 at 11:32:46AM +, envoid via Digitalmars-d-learn wrote: Unfortunately, that guarantee also excludes a lot of otherwise useful idioms, like objects that cache data -- a const object cannot cache data

Re: Error: no property "someFont" for type int

2015-11-11 Thread Marco de Wild via Digitalmars-d-learn
This is not D. It should be giving you a compiler error. How are you compiling? Or did you type 'using' in the post by mistake? Anyway, what you want is: import style; I indeed made a typo while typing the post (and also on various occasions while writing the program, but compiler errors

Error: no property "someFont" for type int

2015-11-10 Thread Marco de Wild via Digitalmars-d-learn
I'm trying to build a small manga reader application (because why search the internet if you can build it yourself), using DSFML. However, I'm getting a weird compilation error that I can't decrypt. In directory.d: using style; (...) _text = new Text; with(_text) {