Compatibility with D regexp constructor

2014-10-25 Thread Suliman via Digitalmars-d-learn
Where I can find compatibility with D online regexp constructor?

Two cases for improving error messages

2014-10-25 Thread Shriramana Sharma via Digitalmars-d-learn
Hello. Please see the following and say whether they're OK to submit as bugs for improving the error messages. Thanks. ref int foo(ref int x) { return x ; } void main () { foo(3) ; // Error: function rvalue_argument.foo (ref int x) is not callable using argument types (int) // Comment:

Re: Dynamically Loading a D DLL From a C Program in Linux

2014-10-25 Thread MGW via Digitalmars-d-learn
// MGW 05.01.14 // We model in D object C ++ QByteArray from Qt. // // Windows: dmd st1.d // Linux: dmd st1.d -L-ldl import core.runtime; // Load DLL for Win import std.stdio;// writeln version(linux) { import core.sys.posix.dlfcn;

Re: Two cases for improving error messages

2014-10-25 Thread bearophile via Digitalmars-d-learn
Shriramana Sharma: int i ; ref ir = i ; // Error: variable ref_type.main.ir only parameters or foreach declarations can be ref // Comment: add , return values after parameters } I like this. Bye, bearophile

Type name shadowing

2014-10-25 Thread ixid via Digitalmars-d-learn
T shadow(T = int)(T a) { alias T = string; T b = hi; T c = 1; // Error writeln(typeof(a).stringof); // int writeln(typeof(b).stringof); // string return a; } Are there uses for this shadowing of type names? It seems a little dangerous, for

Pragma mangle and D shared objects

2014-10-25 Thread Etienne Cimon via Digitalmars-d-learn
I haven't been able to find much about pragma mangle. I'd like to do the following: http://forum.dlang.org/thread/hznsrmviciaeirqkj...@forum.dlang.org#post-zhxnqqubyudteycwudzz:40forum.dlang.org The part I find ugly is this: void* vp = dlsym(lib, _D6plugin11getInstanceFZC2bc2Bc\0.ptr); I

Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
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; mixin injections!(A) ... } In injections

Re: Generating code based on UDA

2014-10-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 25 October 2014 at 13:37:56 UTC, Rares Pop wrote: Aiming to generate code based on UDA I wonder if the following is possible: Yes, and copy/pasting that works for me...

Re: Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
Thanks for the quick response. What do you mean by copy/pasting ? On Saturday, 25 October 2014 at 13:40:56 UTC, Adam D. Ruppe wrote: On Saturday, 25 October 2014 at 13:37:56 UTC, Rares Pop wrote: Aiming to generate code based on UDA I wonder if the following is possible: Yes, and

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: Generating code based on UDA

2014-10-25 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 25 October 2014 at 13:45:29 UTC, Rares Pop wrote: What do you mean by copy/pasting ? I literally copied the code in your post (and fixed a missing semicolon) and got it to compile. Passing A as an argument to injections should work. You can also use this and typeof(this)

Re: Two cases for improving error messages

2014-10-25 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Oct 25, 2014 at 05:14:31PM +0530, Shriramana Sharma via Digitalmars-d-learn wrote: Hello. Please see the following and say whether they're OK to submit as bugs for improving the error messages. Thanks. ref int foo(ref int x) { return x ; } void main () { foo(3) ; // Error:

Re: Type name shadowing

2014-10-25 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Oct 25, 2014 at 12:28:39PM +, ixid via Digitalmars-d-learn wrote: T shadow(T = int)(T a) { alias T = string; T b = hi; T c = 1; // Error writeln(typeof(a).stringof); // int writeln(typeof(b).stringof); // string return a; } Are there

Re: Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
On Saturday, 25 October 2014 at 13:53:35 UTC, Adam D. Ruppe wrote: On Saturday, 25 October 2014 at 13:45:29 UTC, Rares Pop wrote: What do you mean by copy/pasting ? I literally copied the code in your post (and fixed a missing semicolon) and got it to compile. Passing A as an argument to

Re: Pragma mangle and D shared objects

2014-10-25 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Oct 25, 2014 at 09:20:33AM -0400, Etienne Cimon via Digitalmars-d-learn wrote: I haven't been able to find much about pragma mangle. I'd like to do the following: http://forum.dlang.org/thread/hznsrmviciaeirqkj...@forum.dlang.org#post-zhxnqqubyudteycwudzz:40forum.dlang.org The

Re: Generating code based on UDA

2014-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/2014 07:45 AM, Rares Pop wrote: On Saturday, 25 October 2014 at 13:53:35 UTC, Adam D. Ruppe wrote: On Saturday, 25 October 2014 at 13:45:29 UTC, Rares Pop wrote: What do you mean by copy/pasting ? I literally copied the code in your post (and fixed a missing semicolon) and got it to

Re: Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
Ali, Many thanks for your help. What is the rationale for mixin(fullName) ?

Re: Pragma mangle and D shared objects

2014-10-25 Thread Etienne Cimon via Digitalmars-d-learn
That looks like exactly the solution I need, very clever. It'll take some time to wrap my head around it :-P

Re: Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
Ali, Many thanks for your help. Indeed it worked. What is the rationale behind the mixin(fullName) ? However, in my project the injections function, the @Inject UDA struct and some other dependencies are defined in a library (libinfuse). In this format the compiler gives the undefined

Re: Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
I've uploaded the code here: https://github.com/fusionbeam/infuse

Re: Two cases for improving error messages

2014-10-25 Thread Shriramana Sharma via Digitalmars-d-learn
On Sat, Oct 25, 2014 at 8:00 PM, H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I agree with submitting both of these as enhancement requests. Please tag them with diagnostic in the keywords field. Done: https://issues.dlang.org/show_bug.cgi?id=13655

Re: Pragma mangle and D shared objects

2014-10-25 Thread Etienne Cimon via Digitalmars-d-learn
On 2014-10-25 11:56, Etienne Cimon wrote: That looks like exactly the solution I need, very clever. It'll take some time to wrap my head around it :-P Just brainstorming here, but I think every dynamic library should hold a utility container (hash map?) that searches for and returns the

Re: Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
On Saturday, 25 October 2014 at 16:01:29 UTC, Rares Pop wrote: I've uploaded the code here: https://github.com/fusionbeam/infuse compiling with ldc2 exhibits the same behaviour. 'Error: undefined identifier B'

Does it make sense to add attribute to operator overload functions ?

2014-10-25 Thread Jkpl via Digitalmars-d-learn
Everything is in the Q. I ask this because those functions are hidden behind symbols and keywords (+=, ~, in, etc.). It's not that obvious for a user who would write a custom type. e.g: --- struct myType { @safe nothrow opIndexAssign(t1 paramValue,t2 paramIndex){} } ---

Re: Does it make sense to add attribute to operator overload functions ?

2014-10-25 Thread John Colvin via Digitalmars-d-learn
On Saturday, 25 October 2014 at 17:14:51 UTC, Jkpl wrote: Everything is in the Q. I ask this because those functions are hidden behind symbols and keywords (+=, ~, in, etc.). It's not that obvious for a user who would write a custom type. e.g: --- struct myType { @safe nothrow

Re: Pragma mangle and D shared objects

2014-10-25 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Oct 25, 2014 at 12:15:19PM -0400, Etienne Cimon via Digitalmars-d-learn wrote: On 2014-10-25 11:56, Etienne Cimon wrote: That looks like exactly the solution I need, very clever. It'll take some time to wrap my head around it :-P It's not that complicated, really. It's basically

Re: Two cases for improving error messages

2014-10-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/25/14 7:44 AM, Shriramana Sharma via Digitalmars-d-learn wrote: Hello. Please see the following and say whether they're OK to submit as bugs for improving the error messages. Thanks. ref int foo(ref int x) { return x ; } void main () { foo(3) ; // Error: function rvalue_argument.foo

Re: Does it make sense to add attribute to operator overload functions ?

2014-10-25 Thread Jkpl via Digitalmars-d-learn
On Saturday, 25 October 2014 at 18:38:12 UTC, John Colvin wrote: On Saturday, 25 October 2014 at 17:14:51 UTC, Jkpl wrote: Everything is in the Q. I ask this because those functions are hidden behind symbols and keywords (+=, ~, in, etc.). It's not that obvious for a user who would write a

HTML Parsing lib

2014-10-25 Thread Suliman via Digitalmars-d-learn
I found only https://github.com/Bystroushaak/DHTMLParser But I can't get it work: C:\Users\Dima\Downloads\DHTMLParser-master\DHTMLParser-masterdmd find_links.d OPTLINK (R) for Win32 Release 8.00.15 Copyright (C) Digital Mars 1989-2013 All rights reserved.

Re: HTML Parsing lib

2014-10-25 Thread MrSmith via Digitalmars-d-learn
On Saturday, 25 October 2014 at 19:46:01 UTC, MrSmith wrote: On Saturday, 25 October 2014 at 19:44:25 UTC, Suliman wrote: I found only https://github.com/Bystroushaak/DHTMLParser But I can't get it work: C:\Users\Dima\Downloads\DHTMLParser-master\DHTMLParser-masterdmd find_links.d OPTLINK

Re: HTML Parsing lib

2014-10-25 Thread MrSmith via Digitalmars-d-learn
On Saturday, 25 October 2014 at 19:44:25 UTC, Suliman wrote: I found only https://github.com/Bystroushaak/DHTMLParser But I can't get it work: C:\Users\Dima\Downloads\DHTMLParser-master\DHTMLParser-masterdmd find_links.d OPTLINK (R) for Win32 Release 8.00.15 Copyright (C) Digital Mars

Re: HTML Parsing lib

2014-10-25 Thread Suliman via Digitalmars-d-learn
You need to pass a library to compiler as well (all its files or .lib/.a file) if it is compiled as static library You can try dmd find_links.d dhtmlparser.d quote_escaper.d C:\Users\Dima\Downloads\DHTMLParser-master\DHTMLParser-masterdmd find_links.d quote_escaper.d OPTLINK (R) for

Re: HTML Parsing lib

2014-10-25 Thread Suliman via Digitalmars-d-learn
On Saturday, 25 October 2014 at 19:51:48 UTC, Suliman wrote: You need to pass a library to compiler as well (all its files or .lib/.a file) if it is compiled as static library You can try dmd find_links.d dhtmlparser.d quote_escaper.d

Re: HTML Parsing lib

2014-10-25 Thread Suliman via Digitalmars-d-learn
How I can build such App with DUB?

Re: HTML Parsing lib

2014-10-25 Thread MrSmith via Digitalmars-d-learn
On Saturday, 25 October 2014 at 19:55:10 UTC, Suliman wrote: How I can build such App with DUB? Unfortunately that library has no dub package. But you can include it in your project. See info here http://code.dlang.org/package-format

Re: Pragma mangle and D shared objects

2014-10-25 Thread John Colvin via Digitalmars-d-learn
On Saturday, 25 October 2014 at 18:40:23 UTC, H. S. Teoh via Digitalmars-d-learn wrote: Actually, the object file (library) itself should already have a list of exported symbols; you could then use core.demangle to extract the function signatures from the mangled symbols and construct a hash

Re: HTML Parsing lib

2014-10-25 Thread Adam D. Ruppe via Digitalmars-d-learn
Another option for html is my dom.d https://github.com/adamdruppe/arsd get dom.d and characterencodings.d in your project directory. compile with dmd yourfile.d dom.d characterencodings.d here's an example: import arsd.dom; void main() { auto document = new Document(); // The example

Re: Generating code based on UDA

2014-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/2014 08:56 AM, Rares Pop wrote: Indeed it worked. What is the rationale behind the mixin(fullName) ? __traits(getAttributes) requires a symbol but fullName is a string. Mixing it in as code fulfills the requirement. However, in my project the injections function, the @Inject UDA

Where is a variable declared in a module allocated?

2014-10-25 Thread MachineCode via Digitalmars-d-learn
Where is a variable declared in a module allocated? is it same as a C's global? for example: module foo; int myvar;

Re: Where is a variable declared in a module allocated?

2014-10-25 Thread John Colvin via Digitalmars-d-learn
On Saturday, 25 October 2014 at 21:52:13 UTC, MachineCode wrote: Where is a variable declared in a module allocated? is it same as a C's global? for example: module foo; int myvar; that is in thread local storage. __shared, shared or immutable cause the variable to be in classic global

Re: Pragma mangle and D shared objects

2014-10-25 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Oct 25, 2014 at 08:05:18PM +, John Colvin via Digitalmars-d-learn wrote: On Saturday, 25 October 2014 at 18:40:23 UTC, H. S. Teoh via Digitalmars-d-learn wrote: Actually, the object file (library) itself should already have a list of exported symbols; you could then use

Re: Pragma mangle and D shared objects

2014-10-25 Thread Etienne Cimon via Digitalmars-d-learn
On 2014-10-25 21:26, H. S. Teoh via Digitalmars-d-learn wrote: Not sure what nm uses, but a lot of posix tools for manipulating object files are based on binutils, which understands the local system's object file format and deal directly with the binary representation. The problem is, I don't

Re: Pragma mangle and D shared objects

2014-10-25 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Oct 25, 2014 at 10:54:53PM -0400, Etienne Cimon via Digitalmars-d-learn wrote: On 2014-10-25 21:26, H. S. Teoh via Digitalmars-d-learn wrote: Not sure what nm uses, but a lot of posix tools for manipulating object files are based on binutils, which understands the local system's

Re: Generating code based on UDA

2014-10-25 Thread Rares Pop via Digitalmars-d-learn
I think it is a bug. Executing linked code from a mixin statement should not reduce the scope of the mixin, IMHO. I will file a bug report. On Saturday, 25 October 2014 at 21:35:44 UTC, Ali Çehreli wrote: On 10/25/2014 08:56 AM, Rares Pop wrote: Indeed it worked. What is the rationale