Re: Invalid string literal in ASM

2018-10-03 Thread dokutoku via Digitalmars-d-learn
On Monday, 1 October 2018 at 10:45:25 UTC, Basile B. wrote: On Monday, 1 October 2018 at 09:24:47 UTC, Basile B. wrote: On Monday, 1 October 2018 at 08:14:07 UTC, dokutoku wrote: I get a compiler error when I try to put non-ASCII characters in a string literal in the inline assembler. Is

Re: Template/mixin ideas?

2018-10-03 Thread Chris Katko via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 11:51:01 UTC, Sebastiaan Koppe wrote: On Wednesday, 3 October 2018 at 11:01:53 UTC, Chris Katko wrote: [...] A combination of static introspection with string mixins does the trick: --- enum colors { reset = "\033[0m", red = "\033[31m" } auto

Re: Interfacing D with C++ functions that take reference values

2018-10-03 Thread kinke via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 23:05:10 UTC, solidstate1991 wrote: I need some C++ stuff, but some of the functions take reference values (Stuff&), and I don't know if this feature is emulated on D side with extern(C++) functions. Of course; you're restricted to D value types though (D class

Interfacing D with C++ functions that take reference values

2018-10-03 Thread solidstate1991 via Digitalmars-d-learn
I need some C++ stuff, but some of the functions take reference values (Stuff&), and I don't know if this feature is emulated on D side with extern(C++) functions. While I don't have to worry about it with functions that are defined in the header, other ones and classes are a different matter.

Re: What does -vtls compiler flag does and ...

2018-10-03 Thread Vladimir Panteleev via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 20:41:15 UTC, welkam wrote: This flag blocks compilation and I want to just remove it but since I dont know what it is used for I hesitate. If my attempts were to be successful in compiling dmd with other compilers I would make pull request but now I have more

Re: What does -vtls compiler flag does and ...

2018-10-03 Thread Stanislav Blinov via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 21:39:12 UTC, welkam wrote: string a = "test"; is a variable that mutates so it should be thread local. Also ASM output shows that these variables are not optimized away so compiler should output something but it doesnt. Or I dont understand thread local

Re: What does -vtls compiler flag does and ...

2018-10-03 Thread welkam via Digitalmars-d-learn
string a = "test"; is a variable that mutates so it should be thread local. Also ASM output shows that these variables are not optimized away so compiler should output something but it doesnt. Or I dont understand thread local storage.

Re: What does -vtls compiler flag does and ...

2018-10-03 Thread Stanislav Blinov via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 21:18:26 UTC, welkam wrote: On Wednesday, 3 October 2018 at 20:58:01 UTC, Stanislav Blinov wrote: No, all *static non-immutable* variables are thread-local by default, not just "all variables". I misspoke but this should write something

Re: What does -vtls compiler flag does and ...

2018-10-03 Thread welkam via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 20:58:01 UTC, Stanislav Blinov wrote: No, all *static non-immutable* variables are thread-local by default, not just "all variables". I misspoke but this should write something https://run.dlang.io/is/3u1wFp If you look at asm output there are "call

Re: How to implement D to HTML pages ?

2018-10-03 Thread aberba via Digitalmars-d-learn
On Monday, 1 October 2018 at 19:29:56 UTC, Aurélien Plazzotta wrote: Hello guys, I would like to implement a forum and a blog within my website (currently including only HTML, CSS and JS, written without CMS), using D and SQL but I really don't know how to proceed. How can I integrate D into

Re: What does -vtls compiler flag does and ...

2018-10-03 Thread Stanislav Blinov via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 20:41:15 UTC, welkam wrote: I was playing around with dmd`s make file trying to see if I can compile dmd with different compilers and different compilation flags. By playing around I found that some dmd files are compiled with -vtls flag unconditionally and that

What does -vtls compiler flag does and ...

2018-10-03 Thread welkam via Digitalmars-d-learn
I was playing around with dmd`s make file trying to see if I can compile dmd with different compilers and different compilation flags. By playing around I found that some dmd files are compiled with -vtls flag unconditionally and that ldc do not support this flag. First I dont know what -vtls

Re: Use std.traits.getSymbolsByUDA to access members of instance.

2018-10-03 Thread Stanislav Blinov via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 03:30:50 UTC, Jonathan wrote: I can use `std.traits.getSymbolsByUDA` to get all the members of a class that have a particular UDA `getSymbolsByUDA(ValueType, UDA)`. But how do I get the values with it? Is there a more convenient way than `__traits(getMember,

Re: Compile time sequences

2018-10-03 Thread drug via Digitalmars-d-learn
On 03.10.2018 20:22, Paul Backus wrote: In my experience doing metaprogramming in D, it's best to make your static if/template constraint tests as narrow and specific as possible. For example, if you want to know whether you can call a function with a particular argument, you don't need to

Re: Compile time sequences

2018-10-03 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 07:57:07 UTC, drug wrote: According to https://dlang.org/articles/ctarguments.html compile time sequences "...allow a programmer to operate on types, symbols and values..." Phobos has `isType`/`isTypeTuple` traits, also `isExpressions` where expression may

Re: Template/mixin ideas?

2018-10-03 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 11:01:53 UTC, Chris Katko wrote: I've got this simple task but I'm trying to perfect it as best I can to learn something in the process. I have Linux terminal ASCII codes for coloring terminal output. string red(string) { /* ... */ } "Hello world".red =>

Template/mixin ideas?

2018-10-03 Thread Chris Katko via Digitalmars-d-learn
I've got this simple task but I'm trying to perfect it as best I can to learn something in the process. I have Linux terminal ASCII codes for coloring terminal output. string red(string) { /* ... */ } "Hello world".red => "\033[31mHello World\033[0m" which translates to "[red]Hello

Re: Template return type?

2018-10-03 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 10:01:02 UTC, Andrea Fontana wrote: On Wednesday, 3 October 2018 at 09:37:29 UTC, JN wrote: int i = returnDefault!int(); obviously works, but the point is I would like to skip the explicit type. See:

Re: Template return type?

2018-10-03 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 09:37:29 UTC, JN wrote: int i = returnDefault!int(); obviously works, but the point is I would like to skip the explicit type. See: https://forum.dlang.org/post/ufhibwmouxpivjylq...@forum.dlang.org

Template return type?

2018-10-03 Thread JN via Digitalmars-d-learn
I was looking over some Rust examples, and found something interesting: https://github.com/serde-rs/serde let deserialized: Point = serde_json::from_str().unwrap(); from_str is defined as: pub fn from_str<'a, T>(s: &'a str) -> Result From what I understand, the function infers the

Re: Performance of GC.collect() for single block of `byte`s

2018-10-03 Thread Rainer Schuetze via Digitalmars-d-learn
On 01/10/2018 15:51, Steven Schveighoffer wrote: On 10/1/18 3:21 AM, Rainer Schuetze wrote: A profiler reveals that most of the time is spent in "sweeping" the memory, i.e. looking for allocations no longer referenced. The existing implementation checks every page which causes a linear

Compile time sequences

2018-10-03 Thread drug via Digitalmars-d-learn
According to https://dlang.org/articles/ctarguments.html compile time sequences "...allow a programmer to operate on types, symbols and values..." Phobos has `isType`/`isTypeTuple` traits, also `isExpressions` where expression may contain both values and symbols, but has no traits like

Re: How to implement D to HTML pages ?

2018-10-03 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 18:27:04 UTC, Aurélien Plazzotta wrote: Thank you both for all the links! I guess DiamondMVC is very powerful but I would rather avoid using such heavy artillery. I'm expecting the learning curve to be very long. I currently use two libraries I wrote to keep

Re: New With Struct and Getting Class Object Pointers

2018-10-03 Thread Vijay Nayar via Digitalmars-d-learn
On Sunday, 30 September 2018 at 11:11:09 UTC, Nicholas Wilson wrote: On Sunday, 30 September 2018 at 09:30:38 UTC, Vijay Nayar wrote: Is there a way to either have a constant reference to a class that can be set to a new value, or is there a way to convert the class variable to a class