Re: Create mixins from a list of strings
On Saturday, 11 January 2014 at 16:07:30 UTC, Philippe Sigaud wrote: I'm a bit leery of putting D call syntax into semantic actions, because it'll also explode the Pegged grammar size (I'm fairly sure I'd have to pull in a big part of D if I want to get function calls right). That's one feature I wanted at one time, but I'm not sure it's a good idea. Yes, and I would not be able to argue this is the definite way to handle things anyway. It's a try at type checking with little regard to efficiency. I'm just happy it works with Timon Gehr's extremely simple solution. :3 On Saturday, 11 January 2014 at 20:52:15 UTC, Timon Gehr wrote: import std.string, std.algorithm; enum semanticArray = ["derp", "lala"]; mixin(semanticArray.map!(a=>`T `~a~`(T)(T t) { t.name ~= "`~a~`"; return t; }`).join()); Here, have a heart. <3
Re: [Windows & DMD] No callstack when crash with Access violation reading location 0x00000000
Ok, I can reproduce this, and it seems that the crash happens somewhere in no mans land. That means there is no debugging information present and the stack frame isn't valid either. So the debugger and druntimes buildin stacktrace code has no chance. My guess would be that this happens inside druntime or phobos. So to debug this issue you will have to build a debug version of druntime and phobos (just modify the DFLAGS variable inside the .mak files accordingly and build them using the digital mars make). And then link against these debug versions (using the -debuglib switch). I would recommend renaming the debug versions so you can use them whenever needed. I will take a deeper look tomorrow. Kind Regards Benjamin Thaut
Re: [Windows & DMD] No callstack when crash with Access violation reading location 0x00000000
Le 12/01/2014 00:30, Benjamin Thaut a écrit : Am 11.01.2014 22:56, schrieb Xavier Bigand: Le 11/01/2014 22:15, Benjamin Thaut a écrit : Am 11.01.2014 20:50, schrieb Xavier Bigand: Yes I have no stack trace and adding import core.sys.windows.stacktrace change nothing. That is very strange. Can you reduce this? Or is this project on github somewhere? Did you try using a debugger? Kind Regards Benjamin Thaut Yes it's on github : https://github.com/Flamaros/DQuick/tree/Missing_RAII_Warning Ro reproduce the crash : - You can launch the DQuick-VisualD.sln solution file that is in the root folder. - Launch the Text project (in debug mode) - Resize the Window, it crash directly It seems to be related to the GraphicItem class in startPaint methode, particulary this section of code : debug { if (mRebuildDebugMeshes) updateDebugMesh(); mDebugMesh.draw(); if ((implicitWidth != float.nan && implicitHeight != float.nan) && (implicitWidth != mSize.x && implicitHeight != mSize.y)) mDebugImplicitMesh.draw(); } Putting it under comment remove the crash. Thank you for your help. If you use VisualD why don't you go to "Debugging->Execptions" in Visual Studio and activate the "Access Violation" under "Win32 Exceptions" to debug that access violation with the visual studio debugger? Kind Regards Benjamin Thaut I didn't know this menu settings, but activate Access Violation don't change anything.
Re: [Windows & DMD] No callstack when crash with Access violation reading location 0x00000000
Am 11.01.2014 22:56, schrieb Xavier Bigand: Le 11/01/2014 22:15, Benjamin Thaut a écrit : Am 11.01.2014 20:50, schrieb Xavier Bigand: Yes I have no stack trace and adding import core.sys.windows.stacktrace change nothing. That is very strange. Can you reduce this? Or is this project on github somewhere? Did you try using a debugger? Kind Regards Benjamin Thaut Yes it's on github : https://github.com/Flamaros/DQuick/tree/Missing_RAII_Warning Ro reproduce the crash : - You can launch the DQuick-VisualD.sln solution file that is in the root folder. - Launch the Text project (in debug mode) - Resize the Window, it crash directly It seems to be related to the GraphicItem class in startPaint methode, particulary this section of code : debug { if (mRebuildDebugMeshes) updateDebugMesh(); mDebugMesh.draw(); if ((implicitWidth != float.nan && implicitHeight != float.nan) && (implicitWidth != mSize.x && implicitHeight != mSize.y)) mDebugImplicitMesh.draw(); } Putting it under comment remove the crash. Thank you for your help. If you use VisualD why don't you go to "Debugging->Execptions" in Visual Studio and activate the "Access Violation" under "Win32 Exceptions" to debug that access violation with the visual studio debugger? Kind Regards Benjamin Thaut
Re: WeakRefs for a CPP->D wrapper
On Saturday, 11 January 2014 at 20:38:33 UTC, Abdulhaq wrote: On Saturday, 11 January 2014 at 20:17:14 UTC, Tobias Pankrath wrote: class X {}; X x; x is an reference to an instance of X, with other words a pointer without arithmetic but with syntax sugar. &x will take the address of this pointer/reference. If you want the address of the actual instance, you can use cast(void*) for example. Hi Tobias, can casting the address to void* make a difference to its value? No, try this: import std.stdio; class X {} void foo(X x) { writeln(cast(void*) x); } void main() { X x; // null reference by default. writeln(cast(void*) x); foo(x); x = new X; writeln(cast(void*) x); foo(x); }
Re: [Windows & DMD] No callstack when crash with Access violation reading location 0x00000000
Le 11/01/2014 22:15, Benjamin Thaut a écrit : Am 11.01.2014 20:50, schrieb Xavier Bigand: Yes I have no stack trace and adding import core.sys.windows.stacktrace change nothing. That is very strange. Can you reduce this? Or is this project on github somewhere? Did you try using a debugger? Kind Regards Benjamin Thaut Yes it's on github : https://github.com/Flamaros/DQuick/tree/Missing_RAII_Warning Ro reproduce the crash : - You can launch the DQuick-VisualD.sln solution file that is in the root folder. - Launch the Text project (in debug mode) - Resize the Window, it crash directly It seems to be related to the GraphicItem class in startPaint methode, particulary this section of code : debug { if (mRebuildDebugMeshes) updateDebugMesh(); mDebugMesh.draw(); if ((implicitWidth != float.nan && implicitHeight != float.nan) && (implicitWidth != mSize.x && implicitHeight != mSize.y)) mDebugImplicitMesh.draw(); } Putting it under comment remove the crash. Thank you for your help.
Re: [Windows & DMD] No callstack when crash with Access violation reading location 0x00000000
Am 11.01.2014 20:50, schrieb Xavier Bigand: Yes I have no stack trace and adding import core.sys.windows.stacktrace change nothing. That is very strange. Can you reduce this? Or is this project on github somewhere? Did you try using a debugger? Kind Regards Benjamin Thaut
Re: Create mixins from a list of strings
On 01/11/2014 09:35 AM, "Casper Færgemand" " wrote: On Saturday, 11 January 2014 at 07:50:51 UTC, Jakob Ovrum wrote: Your problem is probably better solved without string mixins, but we'd probably need to see some code or more elaboration to accurately suggest a solution. enum semanticArray = ["test"]; mixin(`T ` ~ semanticArray[0] ~ `(T)(T t) { t.name ~= "` ~ semanticArray[0] ~ `"; return t; }`); This will mixin a single templated function named "test", which changes an AST node's name to whatever it was concatenated with "test". I want this to happen automatically for any length of semanticArray. import std.string, std.algorithm; enum semanticArray = ["derp", "lala"]; mixin(semanticArray.map!(a=>`T `~a~`(T)(T t) { t.name ~= "`~a~`"; return t; }`).join());
Re: WeakRefs for a CPP->D wrapper
On Saturday, 11 January 2014 at 20:17:14 UTC, Tobias Pankrath wrote: class X {}; X x; x is an reference to an instance of X, with other words a pointer without arithmetic but with syntax sugar. &x will take the address of this pointer/reference. If you want the address of the actual instance, you can use cast(void*) for example. Hi Tobias, can casting the address to void* make a difference to its value? Here's an example of what I don't understand: import std.stdio; import std.string: format; class Foo { int x; } void printAddress(Foo foo) { writeln("Address of parameter foo is %x".format(&foo)); writeln("Address of parameter foo cast to void* is %x".format(cast(void*) &foo)); } void main() { auto foo = new Foo(); writeln("Address of foo is %x".format(&foo)); writeln("Address of foo cast to void* is %x".format(cast(void*) &foo)); printAddress(foo); } When run I get: Address of foo is 7fff40ac4558 Address of foo cast to void* is 7fff40ac4558 Address of parameter foo is 7fff40ac4538 Address of parameter foo cast to void* is 7fff40ac4538 So why is the address of the parameter foo different to the address of main foo, when they both refer to the same object? thanks
Re: WeakRefs for a CPP->D wrapper
Object[void*] wrappingRegistry; but of course that prevents the wrapped objects from being garbage collected - I need weak ref semantics. I had a go at making it e.g. ulong[ulong] and storing the cast(ulong) address of the D object, but it seems that I don't understand what taking the address of an obj (&obj) actually is doing - it doesn't seem to point to the memory occupied by the object but instead to the address of the variable pointing to the object? class X {}; X x; x is an reference to an instance of X, with other words a pointer without arithmetic but with syntax sugar. &x will take the address of this pointer/reference. If you want the address of the actual instance, you can use cast(void*) for example.
WeakRefs for a CPP->D wrapper
I'm implementing a wrapper program for wrapping generic C++ libraries - it's going very well (subclassing, virtual methods, nested classes, enums working) but I've hit an area that I don't have enough D experience to answer, and am hoping someone can point me in the right direction. My background is lots of professional Java, Python etc., but not so much writing of C++ (plenty of reading but not writing). I need to maintain a mapping between C++ void* addresses and D wrapper Objects. The naive implementation would be Object[void*] wrappingRegistry; but of course that prevents the wrapped objects from being garbage collected - I need weak ref semantics. I had a go at making it e.g. ulong[ulong] and storing the cast(ulong) address of the D object, but it seems that I don't understand what taking the address of an obj (&obj) actually is doing - it doesn't seem to point to the memory occupied by the object but instead to the address of the variable pointing to the object? I've had a good google around and because my understanding is poor in this area (GC innards, shared data, D pointers etc) I can't identify which of the implementations around is best for 2.064/2.065 and moving forwards. My best guess is the WeakRef found in this one: https://github.com/phobos-x/phobosx/blob/master/source/phobosx/signal.d by Robert in his signals2 implementation. Can anyone expain what is going on in WeakRef and InvisibleAddress? thanks for any help you can give me.
Re: [Windows & DMD] No callstack when crash with Access violation reading location 0x00000000
Le 11/01/2014 19:40, Benjamin Thaut a écrit : Am 11.01.2014 19:16, schrieb Xavier Bigand: Le 11/01/2014 18:45, Benjamin Thaut a écrit : Am 11.01.2014 17:24, schrieb Xavier Bigand: I get some troubles to solve a memory bug, just cause I don't have any informations for debuggers and I can't neither use DrMemory. Is it possible to get the callstack when calling a method on a null pointer with specifics DMD flags? Maybe DMD need add null ptr call checks in debug mode? For x64 exeuctables compile with -g. For x86 executables compile with -g and then run cv2pdb on the final executable. cv2pdb is part of VisualD. Kind Regards Benjamin Thaut Yep I am using VisualD with cv2pdb, and I build in debug mode with the flag -g. And it does not print a stack trace? Is it possbile that this access violation happens within a module constructor? Try importing core.sys.windows.stacktrace into every single one of your modules and see if that changes something. Kind Regards Benjamin Thaut Yes I have no stack trace and adding import core.sys.windows.stacktrace change nothing.
Re: Question on static declaration
On Saturday, 11 January 2014 at 17:50:01 UTC, Eric wrote: Apparently the line, static shared static int x; will compile just fine. Is this sort of a bug, or does it mean something different from just static shared int x; ? Also, the line, static static static int x; will also compile. Does this mean x is extra static? -Eric It is a particular example of current nonsense in attribution parsing. This compiles: void main() { pure int i; @disable int di; nothrow int ni; } as well as more sophisticated nonsense. Issue is filed is bugzilla, so it will be fixed sooner or latter, current policy is to ignore it.
Re: Is it possible to call a parent's destructor?
On Saturday, 11 January 2014 at 18:38:22 UTC, Gary Willoughby wrote: Is it possible to call a parent's destructor? If so what's the syntax? Parent destructors are called automatically: import std.stdio; class Foo { ~this() { writeln("Foo.dtor"); } } class Bar : Foo { ~this() { writeln("Bar.dtor"); } } void main() { auto f = new Bar(); } $ ./test500 Bar.dtor Foo.dtor But if you want to do it explicitly, you can with "super.__dtor(); class Bar : Foo { ~this() { writeln("Bar.dtor"); super.__dtor(); } } Notice that it is still called automatically, so it goes twice: Bar.dtor Foo.dtor Foo.dtor
Re: Question on static declaration
On Saturday, 11 January 2014 at 17:50:01 UTC, Eric wrote: Does this mean x is extra static? It is just that repeated storage classes aren't always caught as an error (though they sometimes are!)
Re: [Windows & DMD] No callstack when crash with Access violation reading location 0x00000000
Am 11.01.2014 19:16, schrieb Xavier Bigand: Le 11/01/2014 18:45, Benjamin Thaut a écrit : Am 11.01.2014 17:24, schrieb Xavier Bigand: I get some troubles to solve a memory bug, just cause I don't have any informations for debuggers and I can't neither use DrMemory. Is it possible to get the callstack when calling a method on a null pointer with specifics DMD flags? Maybe DMD need add null ptr call checks in debug mode? For x64 exeuctables compile with -g. For x86 executables compile with -g and then run cv2pdb on the final executable. cv2pdb is part of VisualD. Kind Regards Benjamin Thaut Yep I am using VisualD with cv2pdb, and I build in debug mode with the flag -g. And it does not print a stack trace? Is it possbile that this access violation happens within a module constructor? Try importing core.sys.windows.stacktrace into every single one of your modules and see if that changes something. Kind Regards Benjamin Thaut
Is it possible to call a parent's destructor?
Is it possible to call a parent's destructor? If so what's the syntax?
Re: [Windows & DMD] No callstack when crash with Access violation reading location 0x00000000
Le 11/01/2014 17:24, Xavier Bigand a écrit : I get some troubles to solve a memory bug, just cause I don't have any informations for debuggers and I can't neither use DrMemory. Is it possible to get the callstack when calling a method on a null pointer with specifics DMD flags? Maybe DMD need add null ptr call checks in debug mode? I am using VisualD with cv2pdb. I also tried to put checks manually on the code section which seems to crash (no crash when commented), but I almost don't use ptr and it never enter in my check conditions. It's like a real memory corruption in an other part of code.
Re: [Windows & DMD] No callstack when crash with Access violation reading location 0x00000000
Le 11/01/2014 18:45, Benjamin Thaut a écrit : Am 11.01.2014 17:24, schrieb Xavier Bigand: I get some troubles to solve a memory bug, just cause I don't have any informations for debuggers and I can't neither use DrMemory. Is it possible to get the callstack when calling a method on a null pointer with specifics DMD flags? Maybe DMD need add null ptr call checks in debug mode? For x64 exeuctables compile with -g. For x86 executables compile with -g and then run cv2pdb on the final executable. cv2pdb is part of VisualD. Kind Regards Benjamin Thaut Yep I am using VisualD with cv2pdb, and I build in debug mode with the flag -g.
Re: [Windows & DMD] No callstack when crash with Access violation reading location 0x00000000
Le 11/01/2014 18:20, Namespace a écrit : On Saturday, 11 January 2014 at 16:24:08 UTC, Xavier Bigand wrote: I get some troubles to solve a memory bug, just cause I don't have any informations for debuggers and I can't neither use DrMemory. Is it possible to get the callstack when calling a method on a null pointer with specifics DMD flags? Maybe DMD need add null ptr call checks in debug mode? Try to compile with -gc Doesn't change anything.
Re: [Windows & DMD] No callstack when crash with Access violation reading location 0x00000000
On Saturday, 11 January 2014 at 16:24:08 UTC, Xavier Bigand wrote: I get some troubles to solve a memory bug, just cause I don't have any informations for debuggers and I can't neither use DrMemory. Is it possible to get the callstack when calling a method on a null pointer with specifics DMD flags? Maybe DMD need add null ptr call checks in debug mode? In a perfect world D would have a built-in solution to avoid null references/pointer. :)
Question on static declaration
Apparently the line, static shared static int x; will compile just fine. Is this sort of a bug, or does it mean something different from just static shared int x; ? Also, the line, static static static int x; will also compile. Does this mean x is extra static? -Eric
Re: [Windows & DMD] No callstack when crash with Access violation reading location 0x00000000
Am 11.01.2014 17:24, schrieb Xavier Bigand: I get some troubles to solve a memory bug, just cause I don't have any informations for debuggers and I can't neither use DrMemory. Is it possible to get the callstack when calling a method on a null pointer with specifics DMD flags? Maybe DMD need add null ptr call checks in debug mode? For x64 exeuctables compile with -g. For x86 executables compile with -g and then run cv2pdb on the final executable. cv2pdb is part of VisualD. Kind Regards Benjamin Thaut
Re: [Windows & DMD] No callstack when crash with Access violation reading location 0x00000000
On Saturday, 11 January 2014 at 16:24:08 UTC, Xavier Bigand wrote: I get some troubles to solve a memory bug, just cause I don't have any informations for debuggers and I can't neither use DrMemory. Is it possible to get the callstack when calling a method on a null pointer with specifics DMD flags? Maybe DMD need add null ptr call checks in debug mode? Try to compile with -gc
Re: Create mixins from a list of strings
> Note that closures are not (yet) supported in CTFE, because else > another solution would be a function-returning function: > > auto bar(string s, int i) > { > return > (ParseTree p) { > p.name ~= s ~ to!string(i); > return p; > }; > } Duh, instead of closures, you can use opCall-ed structs: import pegged.grammar; auto foo(string s, int i) { return Foo(s,i); } struct Foo { string s; int i; this(string s, int i) { this.s = s; this.i = i;} ParseTree opCall(ParseTree p) { p.name ~= s ~ to!string(i); return p; } } mixin(grammar(` Test: A <- B { foo("abc",1) } C { foo("def",2) } B <- 'b' C <- 'c' `)); void main() { enum result = Test("bc"); // Compile-time parsing is still possible pragma(msg, result); writeln(result); }
[Windows & DMD] No callstack when crash with Access violation reading location 0x00000000
I get some troubles to solve a memory bug, just cause I don't have any informations for debuggers and I can't neither use DrMemory. Is it possible to get the callstack when calling a method on a null pointer with specifics DMD flags? Maybe DMD need add null ptr call checks in debug mode?
Re: Using the Windows' compiler/linker how to specify a library to link?
On 1/11/2014 10:08 PM, Gary Willoughby wrote: On Saturday, 11 January 2014 at 12:57:38 UTC, Mike Parker wrote: On 1/11/2014 9:01 PM, Gary Willoughby wrote: I'm currently using the 32bit compiler on Windows which uses optlink for linking. I know the compiler command line accepts the -L option to pass arguments to the linker. So what i'm after is the correct way to pass an option to optlink to link a defined library. On Linux i would use: dmd -L-Llocation -L-lmylib source.d but on Windows? dmd -L+location mylib.lib source.d Thanks. So simple but hard to find any docs. True. I could never remember the -L+ bit. Google led me here a while back: http://prowiki.org/wiki4d/wiki.cgi?D__Tutorial/CompilingLinkingD
Re: Create mixins from a list of strings
On Sat, Jan 11, 2014 at 2:34 PM, <"Casper Færgemand\" "@puremagic.com> wrote: > On Saturday, 11 January 2014 at 09:17:34 UTC, Philippe Sigaud wrote: >> >> case "Gramm.Expr": >> return foo(t); >> case "Gramm.FunctionCall": >> return foo(t); >> case "Gramm.Declaration": >> return foo(t); >> default: >> throw new Exception("..."); > > > I can't do this since there will be multiple rules with the same name that > require different treatment. The reason I want to use semantic actions is > that I don't want to push an already heavy grammar into double or triple > size just to name specific rules in a certain way. Semantic actions take up > very little space and fit nicely into the syntax. OK, fair enough. I'm a bit leery of putting D call syntax into semantic actions, because it'll also explode the Pegged grammar size (I'm fairly sure I'd have to pull in a big part of D if I want to get function calls right). That's one feature I wanted at one time, but I'm not sure it's a good idea. OTOH, you can define a templated semantic action: template foo(string s, int i) { T foo(T)(T t) { writeln("Calling foo"); t.name ~= s ~ to!string(i); return t; } } And then invoke it with a parameter: mixin(grammar(` Test: A <- B { foo!("abc",1) } C { foo!("def",2) } B <- 'b' C <- 'c' `)); I did not test it thoroughly, so I'm not sure every template parameter combination is OK. It's probably better not to have curly braces inside the arg list. Pegged also authorize anonymous functions as semantic actions: https://github.com/PhilippeSigaud/Pegged/wiki/Semantic-Actions#anonymous-functions-as-actions Maybe that could be another solution. Something like B { p => foo(arg1, p) } Note that closures are not (yet) supported in CTFE, because else another solution would be a function-returning function: auto bar(string s, int i) { return (ParseTree p) { p.name ~= s ~ to!string(i); return p; }; }
Re: How to launch a Windows compiled exe without showing a console?
Thanks all.
Re: How to launch a Windows compiled exe without showing a console?
On Saturday, 11 January 2014 at 15:13:45 UTC, Gary Willoughby wrote: How to launch a Windows compiled exe without showing a console? I've tried the following two ways and when i execute the resulting *.exe file a console is shown alongside the dialog box. How can i suppress the console? import std.string; import core.sys.windows.windows; void main(string[] args) { MessageBoxA(null, "Hello".toStringz(), "Error", MB_OK | MB_ICONEXCLAMATION); } and import std.string; import core.runtime; import core.sys.windows.windows; extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { Runtime.initialize(); MessageBoxA(null, "Hello".toStringz(), "Error", MB_OK | MB_ICONEXCLAMATION); Runtime.terminate(); return 0; } Compiler flags: dmd -release source.d Tell the linker that application is PE GUI IIRC it was -L/subsystem:windows ?
Re: How to launch a Windows compiled exe without showing a console?
On Saturday, 11 January 2014 at 15:13:45 UTC, Gary Willoughby wrote: box. How can i suppress the console? Add -L/subsystem:windows to the dmd command line, that should do it.
How to launch a Windows compiled exe without showing a console?
How to launch a Windows compiled exe without showing a console? I've tried the following two ways and when i execute the resulting *.exe file a console is shown alongside the dialog box. How can i suppress the console? import std.string; import core.sys.windows.windows; void main(string[] args) { MessageBoxA(null, "Hello".toStringz(), "Error", MB_OK | MB_ICONEXCLAMATION); } and import std.string; import core.runtime; import core.sys.windows.windows; extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { Runtime.initialize(); MessageBoxA(null, "Hello".toStringz(), "Error", MB_OK | MB_ICONEXCLAMATION); Runtime.terminate(); return 0; } Compiler flags: dmd -release source.d
Re: Is it true that dub compiles everything in the source dir whether it's imported or not?
On Saturday, 11 January 2014 at 14:10:20 UTC, Casper Færgemand wrote: On Saturday, 11 January 2014 at 13:46:51 UTC, Gary Willoughby wrote: I've seen this but the problem is not with my project but a dependency. I only include two files from the dependency but when my project is compiled the entire source of the dependency is compiled and produces the error. Is that by any chance also why compiling with Dub is slower than just with Dmd? If so, it would be nice to not do for non-release builds. Yes probably because with DMD you only specify what you need compiling and RDMD actually parses the imports so it only compiles what is needed. As evidence suggests Dub compiles everything, which is slower and results in larger executables.
Re: Is it true that dub compiles everything in the source dir whether it's imported or not?
On Saturday, 11 January 2014 at 13:46:51 UTC, Gary Willoughby wrote: I've seen this but the problem is not with my project but a dependency. I only include two files from the dependency but when my project is compiled the entire source of the dependency is compiled and produces the error. Is that by any chance also why compiling with Dub is slower than just with Dmd? If so, it would be nice to not do for non-release builds.
Re: Is it true that dub compiles everything in the source dir whether it's imported or not?
On Saturday, 11 January 2014 at 13:46:51 UTC, Gary Willoughby wrote: On Saturday, 11 January 2014 at 13:01:26 UTC, Mike Parker wrote: I think adding an "excludedSourceFiles" entry to your package.json is is what you want. See [1]. [1] http://code.dlang.org/package-format I've seen this but the problem is not with my project but a dependency. I only include two files from the dependency but when my project is compiled the entire source of the dependency is compiled and produces the error. Actuall i may be able to handle this as a sub configuration: https://gist.github.com/s-ludwig/7916080
Re: Is it true that dub compiles everything in the source dir whether it's imported or not?
On Saturday, 11 January 2014 at 13:01:26 UTC, Mike Parker wrote: I think adding an "excludedSourceFiles" entry to your package.json is is what you want. See [1]. [1] http://code.dlang.org/package-format I've seen this but the problem is not with my project but a dependency. I only include two files from the dependency but when my project is compiled the entire source of the dependency is compiled and produces the error.
Re: Is it true that dub compiles everything in the source dir whether it's imported or not?
On Saturday, 11 January 2014 at 13:19:10 UTC, Rene Zwanenburg wrote: There's the --rdmd switch to use rdmd for building, so it'll only compile imported files. I'm not sure what it uses as 'main' file though. Yes, that's what i have to use to build correctly as dub creates errors.
Re: Create mixins from a list of strings
On Saturday, 11 January 2014 at 09:17:34 UTC, Philippe Sigaud wrote: case "Gramm.Expr": return foo(t); case "Gramm.FunctionCall": return foo(t); case "Gramm.Declaration": return foo(t); default: throw new Exception("..."); I can't do this since there will be multiple rules with the same name that require different treatment. The reason I want to use semantic actions is that I don't want to push an already heavy grammar into double or triple size just to name specific rules in a certain way. Semantic actions take up very little space and fit nicely into the syntax. or do it with a template, holding function names as aliases: alias actor = dispatcher!(foo, bar, baz); I have no idea what you mean. :D
Re: Is it true that dub compiles everything in the source dir whether it's imported or not?
On Saturday, 11 January 2014 at 12:16:36 UTC, Gary Willoughby wrote: Is it true that dub compiles everything in the source dir whether it's imported or not? Using it to compile a project that seems to be the case but i want to learn if that's true. I draw this conclusion when investigating this problem: http://forum.dlang.org/thread/fvhdqcjfqfojzsyjp...@forum.dlang.org?page=2#post-qavrnsytpszqiofgavgi:40forum.dlang.org If it is true then perhaps dub needs to be re-engineered to only compile imported source files. There's the --rdmd switch to use rdmd for building, so it'll only compile imported files. I'm not sure what it uses as 'main' file though.
stringpool / string interning
I would like to efficiently compare lots of strings. The usual approach is String-interning as Java calls it. After a string is "interned" they can be compared via just a single pointer comparison instead of comparing char by char. I have not found anything like that in Phobos. Somebody already implemented something like this?
Re: Using the Windows' compiler/linker how to specify a library to link?
On Saturday, 11 January 2014 at 12:57:38 UTC, Mike Parker wrote: On 1/11/2014 9:01 PM, Gary Willoughby wrote: I'm currently using the 32bit compiler on Windows which uses optlink for linking. I know the compiler command line accepts the -L option to pass arguments to the linker. So what i'm after is the correct way to pass an option to optlink to link a defined library. On Linux i would use: dmd -L-Llocation -L-lmylib source.d but on Windows? dmd -L+location mylib.lib source.d Thanks. So simple but hard to find any docs.
Re: Is it true that dub compiles everything in the source dir whether it's imported or not?
On 1/11/2014 9:16 PM, Gary Willoughby wrote: Is it true that dub compiles everything in the source dir whether it's imported or not? Using it to compile a project that seems to be the case but i want to learn if that's true. I draw this conclusion when investigating this problem: http://forum.dlang.org/thread/fvhdqcjfqfojzsyjp...@forum.dlang.org?page=2#post-qavrnsytpszqiofgavgi:40forum.dlang.org If it is true then perhaps dub needs to be re-engineered to only compile imported source files. I think adding an "excludedSourceFiles" entry to your package.json is is what you want. See [1]. [1] http://code.dlang.org/package-format
Re: Using the Windows' compiler/linker how to specify a library to link?
On 1/11/2014 9:01 PM, Gary Willoughby wrote: I'm currently using the 32bit compiler on Windows which uses optlink for linking. I know the compiler command line accepts the -L option to pass arguments to the linker. So what i'm after is the correct way to pass an option to optlink to link a defined library. On Linux i would use: dmd -L-Llocation -L-lmylib source.d but on Windows? dmd -L+location mylib.lib source.d
Is it true that dub compiles everything in the source dir whether it's imported or not?
Is it true that dub compiles everything in the source dir whether it's imported or not? Using it to compile a project that seems to be the case but i want to learn if that's true. I draw this conclusion when investigating this problem: http://forum.dlang.org/thread/fvhdqcjfqfojzsyjp...@forum.dlang.org?page=2#post-qavrnsytpszqiofgavgi:40forum.dlang.org If it is true then perhaps dub needs to be re-engineered to only compile imported source files.
Using the Windows' compiler/linker how to specify a library to link?
I'm currently using the 32bit compiler on Windows which uses optlink for linking. I know the compiler command line accepts the -L option to pass arguments to the linker. So what i'm after is the correct way to pass an option to optlink to link a defined library. On Linux i would use: dmd -L-Llocation -L-lmylib source.d but on Windows?
Re: Create mixins from a list of strings
Maybe you could use just one name and put the dispatching code inside it? T actor(T)(T t) { switch (t.name) { case "Gramm.Expr": return foo(t); case "Gramm.FunctionCall": return foo(t); case "Gramm.Declaration": return foo(t); default: throw new Exception("..."); } } or do it with a template, holding function names as aliases: alias actor = dispatcher!(foo, bar, baz);
Re: Create mixins from a list of strings
On Saturday, 11 January 2014 at 07:50:51 UTC, Jakob Ovrum wrote: Your problem is probably better solved without string mixins, but we'd probably need to see some code or more elaboration to accurately suggest a solution. enum semanticArray = ["test"]; mixin(`T ` ~ semanticArray[0] ~ `(T)(T t) { t.name ~= "` ~ semanticArray[0] ~ `"; return t; }`); This will mixin a single templated function named "test", which changes an AST node's name to whatever it was concatenated with "test". I want this to happen automatically for any length of semanticArray.