Re: Best practices of using const

2019-06-22 Thread Bart via Digitalmars-d-learn
On Wednesday, 13 February 2019 at 16:40:18 UTC, H. S. Teoh wrote: So ironically, the iron-clad semantics of D's const system turns out to be also its own downfall. Such things are not ironic. There is always a trade off. You get nothing for free in this universe. Physics tells us this.

Trick for passing void* arrays around with typing

2019-06-21 Thread Bart via Digitalmars-d-learn
foo(cast(void*)[Object1, Object2]); foo(cast(bool delegate(void*))(Tuple!(X,Y) objects)) { }); One can pass arbitrary data as an array(the cast is ugly though) Then the tuple is cast back to void* but one can access objects correctly with typing. This works well when interacting with

Component based programming in D

2019-06-18 Thread Bart via Digitalmars-d-learn
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 great things oop offers(all the design patterns)

Regex driving me nuts

2019-06-17 Thread Bart via Digitalmars-d-learn
Error: static variable `thompsonFactory` cannot be read at compile time, Trying to regex an import file. Also I have a group (...)* and it always fails or matches only one but if I do (...)(...)(...) it matches all 3(fails if more or less of course. ... is the regex). Also when I ignore a

CT/RT annoyance

2019-06-16 Thread Bart via Digitalmars-d-learn
Consider void foo(string A = "")(string B = "") { static if (A != "") do(A); else do(B); } foo!("x"); foo("x"); This is necessary because D's templating and meta programming system is frail. While CTFE should take care of such things, it does not, consider