Re: I can has @nogc and throw Exceptions?
On Friday, 13 February 2015 at 19:03:10 UTC, Jonathan Marler wrote: This question comes from wanting to be able to throw an exception in code that is @nogc. https://dlang.org/changelog/2.079.0.html#dip1008 ```d void main() @nogc { throw new Exception("I'm @nogc now"); } ```
Re: Possible dmd 2.078 regression ?
On Friday, 12 January 2018 at 18:51:31 UTC, Basile B. wrote: On Friday, 12 January 2018 at 18:50:10 UTC, Basile B. wrote: On Friday, 12 January 2018 at 17:58:30 UTC, Stefan Koch wrote: On Friday, 12 January 2018 at 14:13:22 UTC, Basile B. wrote: I have a simple program that only compiles if the dependency is not pre-compiled as a static library. It worked fine before. I guess a mangle problem ? Yes and quite old...apparently it's more a 2.074.x regression. i'm digging right now. digger: Commit 1e7b526b40852e9b85df3684430e371034cdf7ec (1/1) is untestable. digger: There are only untestable commits left to bisect. digger: The first bad commit could be any of: digger: 1e7b526b40852e9b85df3684430e371034cdf7ec digger: 6fecaa8232a427fb3ca29c5a5245e08fc43b71b1 digger: f0410bea1ad2b130884964d603b34e729b3e4f69 object.Exception@bisect.d(186): We cannot bisect more! please file a bug on d.puremagic.com/issues/
Re: Is it possible to obtain textual representation of an arbitary code?
On Friday, 26 January 2018 at 11:18:21 UTC, Oleksii Skidan wrote: Hi, I wonder if it's possible to convert D language code into a string at compile time? C/C++ preprocessor has this feature built-in: `#` preprocessing operator allows converting a macro argument into a string constant. See the following code snippet for example: See feature request I suggested here: https://forum.dlang.org/thread/mailman.2377.1516230845.9493.digitalmar...@puremagic.com __ARGS__ : allow access to (stringified) arguments, as C's `#arg` macro
Re: Relocatable objects and internal pointers
On Saturday, 30 January 2016 at 03:13:59 UTC, Matt Elkins wrote: std.typecons.Unique seems to require heap allocation, which makes it a far cry from std::unique_ptr. isn't unique_ptr typically for heap allocation? eg: https://stackoverflow.com/questions/42910711/unique-ptr-heap-and-stack-allocation NOTE: calypso (ldc fork) should allow internal pointers now, see https://github.com/Syniurge/Calypso/issues/70 (cv::Mat.step.p is an internal pointer)
Re: Understanding how dub works
On Wednesday, 13 December 2017 at 00:43:31 UTC, rikki cattermole wrote: You don't need to change this and if you think you do, you're wrong :) Except when you need to: https://github.com/dlang/dub/issues/1305 dub build --compiler=ldmd2 overwrites files in ~/.dub written by dub build #1305
Re: Time from timestamp?
Might I suggest that you simply define an enum for UnixEpoch that's a SysTime. Then you can do whatever you want. ping on this.
Re: The module 'foo' is already defined in 'libmylib.so'
On Saturday, 10 December 2016 at 02:39:33 UTC, timotheecour wrote: Have a look at what `trace -E d_executable args` and `trace -E c++_executable args` print on startup and grep for dlopen calls and the like. do you mean strace? I have trace on OSX but I'm asking for linux. Looking at the code for $checkModuleCollisions in druntime [src/rt/sections_elf_shared.d:859]: ``` * Check for module collisions. A module in a shared library collides * with an existing module if it's ModuleInfo is interposed (search * symbol interposition) by another DSO. Therefor two modules with the * same name do not collide if their DSOs are in separate symbol resolution * chains. ``` Not exactly sure what that means nor how to fix my issue: ``` void some_fun(){ handle=dlopen2("path/liblib.so", RTLD_LAZY | RTLD_LOCAL); // error: The module 'foo' is already defined in 'libmylib.so' } ``` How would I modify the code to avoid this?
Re: The module 'foo' is already defined in 'libmylib.so'
Have a look at what `trace -E d_executable args` and `trace -E c++_executable args` print on startup and grep for dlopen calls and the like. do you mean strace? I have trace on OSX but I'm asking for linux.
Re: how to debug exceptions/asserts thrown in module constructors?
UPDATE: * b Loader.d:123 didn't help either: error: parsing line table prologue at 0x (parsing ended around 0x Breakpoint 1: where = mybinary.temp`D4gtkc6Loader6Linker12_staticDtor3FZv, address = 0x000100315410 (process exited despite breakpoint); dmd's dwarf debug info seems incorrect * b _d_throwc #does nothing * b _d_print_throwable: doesn't show useful context (only shows backtrace after stack unwinding) (lldb) bt * thread #1: tid = 0x6187c1, 0x000100191c30 mybinary.temp _d_print_throwable, stop reason = breakpoint 4.1 * frame #0: 0x000100191c30 mybinary.temp _d_print_throwable frame #1: 0x000100191530 mybinary.temp rt_init + 160 frame #2: 0x000100191a9a mybinary.temp D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv + 14 frame #3: 0x000100191a40 mybinary.temp D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 36 frame #4: 0x0001001919a6 mybinary.temp _d_run_main + 498 frame #5: 0x00011efa mybinary.temp main + 34 frame #6: 0x7fff89ad65ad libdyld.dylib start + 1 * b _D4gtkc6Loader6Linker11loadLibraryFAyaZv isn't very helpful since this function is complex (and could be inlined more generally) and that function is called many times before the exception is thrown ``` public static void loadLibrary(string library) { void* handle = pLoadLibrary(library); //TODO: A more general way to try more than one version. if ( handle is null && library == importLibs[LIBRARY.GSV] ) handle = pLoadLibrary(importLibs[LIBRARY.GSV1]); if ( handle is null ) throw new Exception("Library load failed: " ~ library); loadedLibraries[library] = handle; } ``` but at least we get a better context: (lldb) bt * thread #1: tid = 0x6187c1, 0x000100315878 mybinary.temp D4gtkc6Loader6Linker11loadLibraryFAyaZv, stop reason = breakpoint 3.1 * frame #0: 0x000100315878 mybinary.temp D4gtkc6Loader6Linker11loadLibraryFAyaZv frame #1: 0x000100315699 mybinary.temp D4gtkc6Loader6Linker9getSymbolFAyaAAyaXPv + 237 frame #2: 0x0001003155a4 mybinary.temp D4gtkc6Loader6Linker9getSymbolFAyaAE4gtkc5paths7LIBRARYXPv + 232 frame #3: 0x0001003163bd mybinary.temp D4gtkc6Loader6Linker39__T4linkTPUZE4gtkc12gobjecttypes5GTypeZ4linkFKPUZE4gtkc12gobjecttypes5GTypeAyaAE4gtkc5paths7LIBRARYXv + 69 at .dub/packages/gtk-d-3.3.1/gtk-d/src/gtkc/Loader.d:46 frame #4: 0x00010038c75d mybinary.temp D4gtkc3atk18_sharedStaticCtor4FZv + 77 at .dub/packages/gtk-d-3.3.1/gtk-d/src/gtkc/atk.d:36 frame #5: 0x00010038c67d mybinary.temp _D4gtkc3atk15__modsharedctorFZv + 9 at .dub/packages/gtk-d-3.3.1/gtk-d/src/gtkc/atk.d:32 frame #6: 0x000100199c17 mybinary.temp D2rt5minfo67__T14runModuleFuncsS442rt5minfo11ModuleGroup8runCtorsMFZ9__lambda2Z14runModuleFuncsMFAxPyS6object10ModuleInfoZv + 91 frame #7: 0x000100199785 mybinary.temp D2rt5minfo11ModuleGroup8runCtorsMFZv + 37 frame #8: 0x000100199a91 mybinary.temp D2rt5minfo13rt_moduleCtorUZ14__foreachbody1MFKS2rt19sections_osx_x86_6412SectionGroupZi + 45 frame #9: 0x000100199a60 mybinary.temp rt_moduleCtor + 20 frame #10: 0x0001001914f3 mybinary.temp rt_init + 99 frame #11: 0x000100191a9a mybinary.temp D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv + 14 frame #12: 0x000100191a40 mybinary.temp D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 36 frame #13: 0x0001001919a6 mybinary.temp _d_run_main + 498 frame #14: 0x00011efa mybinary.temp main + 34 frame #15: 0x7fff89ad65ad libdyld.dylib start + 1 Ideally there should be a way (via a runtime or compile time option) to wrap the exception throwing (during rt_moduleCtor) inside a extern(C) function that we can put a breakpoint on (and possibly even call backtrace_symbols on) to reproduce: main.d: import ggplotd.gtk; void main(){ } dub.json: { "targetType": "executable", "sourcePaths":["."], "dependencies": { "ggplotd": ">=1.1.0", }, "subConfigurations": { "ggplotd": "ggplotd-gtk", }, "buildRequirements": ["allowWarnings"], }
Re: deserialization: creating a class instance without calling constructor
On Thursday, 21 May 2015 at 19:06:35 UTC, Jacob Carlborg wrote: On 2015-05-21 11:06, Timothee Cour via Digitalmars-d-learn wrote: Can I create an instance of A without calling a constructor? (see below) Use case: for generic deserialiaztion, when the deserialization library encounters a class without default constructor for example (it knows what the fields should be set to, but doesn't know how to construct the object). class A{ int x=2; this(int x){ this.x=x; } } This came up here: https://github.com/msgpack/msgpack-d/issues/54#issuecomment-104136148 I provide some hacky solution for that in that thread but I suspect it's not safe and something is missing. Here's how I do it in my serialization library Orange [1] [1] https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L166 Thanks!
Re: Serialization library with support for circular references?
On Saturday, 10 November 2012 at 22:09:07 UTC, Andrej Mitrovic wrote: On 11/10/12, nixda b...@or.de wrote: You can try vibe.d bson serialization. http://vibed.org/api/vibe.data.bson/serializeToBson It doesn't handle them either. Anyway I've implemented it for msgpack (took a whole of 30 minutes, it's a great and readable codebase), I just have to write some more extensive unittests to make sure everything works ok.
Re: Serialization library with support for circular references?
On Saturday, 23 May 2015 at 08:01:28 UTC, timotheecour wrote: On Saturday, 10 November 2012 at 22:09:07 UTC, Andrej Mitrovic wrote: On 11/10/12, nixda b...@or.de wrote: You can try vibe.d bson serialization. http://vibed.org/api/vibe.data.bson/serializeToBson It doesn't handle them either. Anyway I've implemented it for msgpack (took a whole of 30 minutes, it's a great and readable codebase), I just have to write some more extensive unittests to make sure everything works ok. Do you have any pointers to it? This issue tracks this feature request: https://github.com/msgpack/msgpack-d/issues/7 Thanks!
Re: 'with(Foo):' not allowed, why?
On Wednesday, 6 August 2014 at 17:03:23 UTC, Timothee Cour via Digitalmars-d-learn wrote: Is there a reason why 'with(Foo):' is not allowed, and we have to use with(Foo){...} ? It would be more in line with how other scope definitions work (extern(C) etc) ping, anyone?
Re: alias with lambda syntax: alias fun2=a=fun(a);
On Thursday, 5 June 2014 at 06:58:50 UTC, Timothee Cour via Digitalmars-d-learn wrote: Is there a way to do this? import std.algorithm; auto fun(T)(T a){return a;} template fun2(T){auto fun2(T a){return fun(a);}}//OK but heavy syntax and cannot be nested inside test() void main(){ //alias fun2=fun!int; //OK but needs to specify template params //none of those work: //alias fun2=a=fun(a); //alias fun2(T)=(T a)=fun(a); //alias fun2(T)=(T a){return fun(a);} auto b=[1].map!fun2; assert(b.equal([1])); } ok I remembered we can use std.typetuple.Alias for that.