Re: New developments on topic of memset, memcpy and similar
On Saturday, 27 November 2021 at 11:15:45 UTC, Igor wrote: Additionally, here is the twitter thread from the author: https://twitter.com/nadavrot/status/1464364562409422852
Re: How to make the compile time red color warning ?
On Wednesday, 3 June 2020 at 11:48:27 UTC, Виталий Фадеев wrote: Use case: I have class for Windows OS. I not implement class for Linux. I want message about it. When code compiled under Linux. You could use `static assert(false, "Message");` to make it an error.
Re: Can't compile dlangui
On Friday, 7 February 2020 at 12:04:10 UTC, A.Perea wrote: Hi, I'm trying to compile dlangide, and it fails when compiling the dependency dlangui. Trying to compile dlangui independently gives the same error message (see below for full stack trace) [...] On Friday, 7 February 2020 at 12:04:10 UTC, A.Perea wrote: Here is reported issue: https://issues.dlang.org/show_bug.cgi?id=20623
Re: calloc for std.experimental.allocator
On Thursday, 11 January 2018 at 21:09:01 UTC, Nordlöw wrote: Is there no equivalent of `calloc()` for `std.experimental.allocator`, something like Allocator.zeroAllocate(size_t numberOfElements) ? http://dpldocs.info/experimental-docs/std.experimental.allocator.makeArray.4.html
Re: partial application for templates
On Monday, 25 December 2017 at 20:39:52 UTC, Mengu wrote: is partially applying templates possible? template A(X, Y, Z) {} alias B(X, Y) = A!(X, Y, int);
Re: GUI app brings up console
On Wednesday, 6 December 2017 at 21:25:27 UTC, Ivan Trombley wrote: I created a cross-platform app using gtk-d. Everything works fine but when I run it from Windows, a console window is opened. How can I tell Windows that it's a GUI application so that a console is not opened (keeping in mind that this app also needs to be compiled on Linux and Mac)? Assuming that you use dub, add this to your dub.json "lflags-windows" : ["/SUBSYSTEM:windows,6.00", "/ENTRY:mainCRTStartup"]
Linking error: unresolved external symbol internal
I have a static library and an application. When linking final executable I get: lib.lib(texteditor_1d_40c.obj) : error LNK2001: unresolved external symbol internal lib.lib(textbuffer_14_3ce.obj) : error LNK2001: unresolved external symbol internal Happens on Windows 32 and 64 bit. Only with debug build. DMD 2.076.0 Error doesn't happen when I move code from library to the application. Here is reduced test case (where 2 errors happen, 4 files): https://gist.github.com/MrSmith33/29125fa3538bb03637d0aebab6ccff7c Here is smaller case (only 1 error, 2 files): https://gist.github.com/MrSmith33/dc53d8cb6ce642fcb6dbc5863d029cec If this is relevant: 3 places I found in dmd where "internal" symbol is created: * https://github.com/dlang/dmd/blob/4d86fcba2fd2ef86cc85738cd2ac2b059dbb5800/src/ddmd/backend/dt.c#L420 * https://github.com/dlang/dmd/blob/4d86fcba2fd2ef86cc85738cd2ac2b059dbb5800/src/ddmd/tocsym.d#L662 * https://github.com/dlang/dmd/blob/4d86fcba2fd2ef86cc85738cd2ac2b059dbb5800/src/ddmd/tocsym.d#L681
Re: Playing with Entity System, performance and D.
You may find this interesting https://github.com/MrSmith33/datadriven
Re: trying to implement lock-free fixedsize queue
On Thursday, 31 March 2016 at 18:25:46 UTC, jacob wrote: I try to implement chunk (something like lock-free fixedsize queue) ... Check out this implementation https://github.com/MartinNowak/lock-free/blob/master/src/lock_free/rwqueue.d
Re: Yieldable function?
http://dlang.org/phobos/core_thread.html#.Fiber
Re: Opening browser and url.
On Thursday, 25 June 2015 at 14:02:41 UTC, Bauss wrote: In other programming languages you can open a website in the default browser by spawning a process using the url, but it does not seem to work with D using spawnProcess(). Do I have to do API calls to get the default browser and then call spawnProcess() with the url as an argument or is there a standard D way. I tried it like the following spawnProcess(http://www.x.x/;); http://dlang.org/phobos/std_process.html#.browse
Re: Best practices for reading public interfaces
On Saturday, 21 February 2015 at 20:46:09 UTC, Kenny wrote: I like D modules and it's a major point in the list of major points why I like D (there is also the second not so nice wft-list but it's for another post). I'm annoyed with C++ includes and I'm tired to create 2 files every time when I need to add something new to the project... But I must admit that one thing I like in header files is that it is a convenient way to read public interfaces. In D we have interface specification and implementation in a single file and also one approach with unit testing is to put them immediately after functions which makes writing unit tests even more easy task (and I like it very much) but again it makes the gaps between declarations even wider. So, what are the common approaches for reading public interfaces in D programs? Especially it would be great to see the answers of developers who work with more or less big codebases. The few possible solution I'm thinking about at the moment: a) Provide D interfaces for corresponding classes (but probably it's only for more or less complex abstractions and also I won't use it for Vector3D, also very often I use just regular functions). b) Write DDocs and read documentation. The problem here is that I'm going to use D only for my own projects and in the last time I tend to write less documentation, for example I do not write it for the most methods of Vector3D. c) Do nothing special, just write D modules and try to figure out public interfaces reading its code. Maybe it works in practice. Thanks, Artem. You can also fold all the function bodies in your editor, this helps me to read massive sources.
Re: Cannot use the same template arguments on function as the ones on struct
Thanks, everyone.
Re: Cannot use the same template arguments on function as the ones on struct
Thank you!
Cannot use the same template arguments on function as the ones on struct
Here I have templated struct that matches type with CborConfig tempate specialization CborConfig will have more parameters in future and all of them will be accessed via alias members, so I've used variadic (T...) parameter whule matching. --- template CborConfig(_nonSerializedAttribute) { struct CborConfig { alias nonSerializedAttribute = _nonSerializedAttribute; } } /// Default non-serialized attribute type struct NonSerialized{} /// This CborConfig instantiation will be used by default. alias defaultCborConfig = CborConfig!(NonSerialized, NonSerialized); struct AccepterT(Config : CborConfig!(T) = defaultCborConfig, T...) { pragma(msg, T); } // template f379.accepter cannot deduce function from argument types !()() void accepter(Config : CborConfig!(T) = defaultCborConfig, T...)() { pragma(msg, T); } --- ^^^ http://dpaste.dzfl.pl/5f1d5d5d9e19 Instead I need to use template constraint which is less compact. http://dpaste.dzfl.pl/571ae84d783e Why such behavior happens?
Re: dub dustmite
On Friday, 12 December 2014 at 04:25:01 UTC, Vlad Levenfeld wrote: I'm trying to reduce a bug with dub dustmite feature and I must be doing it wrong somehow, my regular dub output looks like this: source/experimental.d(2403): Error: struct experimental.Product!(int[], int[]).Product no size yet for forward reference ulong[2] source/experimental.d(2454): Error: template instance experimental.Product!(int[], int[]) error instantiating source/experimental.d(2462):instantiated from here: by!(int[], int[]) FAIL .dub/build/application-debug-linux.posix-x86_64-dmd_2067-44246AA2375AB6C7D895600135F734E4/ engine_vx executable Error executing command run: dmd failed with exit code 1. and then when I run this command dub dustmite ~/dubdust --compiler-regex=Product no size yet I get Executing dustmite... None = No object.Exception@dustmite.d(243): Initial test fails It seems like a pretty simple case, I'm not sure what's going on. Try using --combined. This will test all packages at the same time if you have dependencies.
Re: How to share modules when using -shared?
On Wednesday, 10 December 2014 at 00:44:41 UTC, Justin Whear wrote: I'm trying to build components that I can dynamically link and keep running into an issue with sharing modules between the host and the pluggable components. Assuming a layout like this: host.d -- loads components at runtime a.d -- a module that builds to `a.so` b.d -- a module that builds to `b.so` common.d If a.d and b.d both import common.d, all is well. If host.d imports common.d as well, I get this at runtime: Fatal Error while loading 'a.so': The module 'common' is already defined in 'host'. Test session with sources here: http://pastebin.com/LxsqHhJm Some of this can be worked around by having host.d use its own extern definitions, but how does this work with interfaces? My tests thus far have resulted in object invariant failures. You can have common in separate .so file, or include it in host.
Re: regular expression engine and ranges
On Tuesday, 2 December 2014 at 19:17:43 UTC, ketmar via Digitalmars-d-learn wrote: Hello. is there any decent regular expression engine which works with input ranges? under decent i mean good D code, [t]nfa and no backtracking. support for captures and greedy/non-greedy modes are must. i found that some popular regex libraries and std.regex are sure that the only data layout regex engine is supposed to work with is plain text array. now, i'm writing a small text editor (yes, another one; please, i know that there are alot of them already! ;-) and internal text layout is anything but plain array. yet i want to use regular expressions for alot of things -- not only for search that piece of text, but for syntax highlighting (i know, i know; don't think about it, everything is much more complicated there), navigation and so on. i was thinking that it will not be that hard, but found that if you want to use existing regexp engine, you *have* to either use plain array and alot of shitcode around it for bookkeeping to please RE, or build that plain array each time you want to use RE. this sux. for now it seems that i have no choice except to write yet another one regular expression engine. and this is the thing i don't want to do. but maybe someone already did that and just don't think that it worth publishing as we have std.regex and so? IIRC, there was a request for ranged regex in phobos somewhere. Is there anything simple that can be easily ported? Btw, do you use ropes for text? What do you use for storing lines, wrapped lines and text style?
Re: help
On Thursday, 20 November 2014 at 16:48:29 UTC, MachineCode wrote: On Thursday, 20 November 2014 at 07:25:45 UTC, Suliman wrote: You need to check if remote file exist of server and only after it download шею is this software name written in russian language? шею means it. on russian keyboard layout
Re: print yyyy-mm-dd
On Thursday, 20 November 2014 at 13:50:49 UTC, Suliman wrote: I can't understand how to get date in format -MM-dd from Clock.currTime auto time = Clock.currTime; And what next? Could anybody give any examples? http://dpaste.dzfl.pl/73c0438f9d1e currTime returns SysTime; You can then cast is to Date. And Date has toISOExtString which converts Date to a string with the format -MM-DD.
Re: Question about eponymous template trick
On Monday, 3 November 2014 at 14:07:55 UTC, Uranuz wrote: I have an example of code like this: template Node(String) { struct Node {} struct Name {} struct Attr {} } void main() { alias MyNode = Node!(string).Node; alias MyName = Node!(string).Name; alias MyAttr = Node!(string).Attr; } This code fails during compilation with message: Compilation output: /d228/f410.d(12): Error: no property 'Node' for type 'Node!string' /d228/f410.d(12): Error: no property 'Node' for type 'Node!string' /d228/f410.d(13): Error: no property 'Name' for type 'Node!string' /d228/f410.d(13): Error: no property 'Name' for type 'Node!string' /d228/f410.d(14): Error: no property 'Attr' for type 'Node!string' /d228/f410.d(14): Error: no property 'Attr' for type 'Node!string' So question is: is this intended behaviour and I'm missing something about eponymous templates? Or is it a bug in compiler? Looks like compiler looks for Node, Name and Attr in Node struct, because of eponymous thing. This code works though: template N(String) { struct Node {} struct Name {} struct Attr {} } void main() { alias MyNode = N!(string).Node; alias MyName = N!(string).Name; alias MyAttr = N!(string).Attr; }
Re: accessing numeric template parameters
On Monday, 3 November 2014 at 14:27:47 UTC, Dominikus Dittes Scherkl wrote: If I have a struct with numeric template parameter, how can I access it within member functions? Like normal member variables? And how about the constructor? struct polynomial(uint base) { private: uint[] N; public: this(uint x) { base = x; } ... void add(Polynomial!base P) { if(N.length P.N.length) N.length = P.N.length; foreach(i; 0..P.N.length) { N[i] = (N[i]+P.N[i]) % base; } } } This doesn't work for me :-/ You cannot assign to it, because it is only avaliable during compilation. Think of it as an immediate value, not variable.
Re: HTML Parsing lib
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 (R) for Win32 Release 8.00.15 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html find_links.obj(find_links) Error 42: Symbol Undefined _D11dhtmlparser11parseStringFAyaZC11dhtmlparser11HTM LElement find_links.obj(find_links) Error 42: Symbol Undefined _D11dhtmlparser12__ModuleInfoZ --- errorlevel 2 Is there any other HTML parsing lib, or maybe someone do know how to get it's work. Look like it's not compatible with current version of DMD 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
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 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html find_links.obj(find_links) Error 42: Symbol Undefined _D11dhtmlparser11parseStringFAyaZC11dhtmlparser11HTM LElement find_links.obj(find_links) Error 42: Symbol Undefined _D11dhtmlparser12__ModuleInfoZ --- errorlevel 2 Is there any other HTML parsing lib, or maybe someone do know how to get it's work. Look like it's not compatible with current version of DMD You need to pass a library to compiler as well (all its files or .lib/.a file) if it is compiled as static library
Re: HTML Parsing lib
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: Making plugin system with shared libraries. Upcast in shared lib
On Tuesday, 21 October 2014 at 13:57:23 UTC, Kagamin wrote: On Monday, 20 October 2014 at 15:07:43 UTC, MrSmith wrote: On Monday, 20 October 2014 at 14:05:29 UTC, Kagamin wrote: Do it the COM way: publish IModule2 interface and declare GetInterface method, which will return a prepared pointer, which you would reinterpret cast to IModule2. Will it work on linux with simple .so libs? I want it to be as simple as possible. Is it any different from what you already have? Dynamic cast is not guaranteed to work across dll boundary. If it does, you're lucky. If it doesn't, use GetInterface - that will work independently from runtime, environment, language, os, hardware etc. What is GetInterface?
Re: Making plugin system with shared libraries. Upcast in shared lib
On Monday, 20 October 2014 at 14:05:29 UTC, Kagamin wrote: Do it the COM way: publish IModule2 interface and declare GetInterface method, which will return a prepared pointer, which you would reinterpret cast to IModule2. Will it work on linux with simple .so libs? I want it to be as simple as possible.
Re: Making plugin system with shared libraries. Upcast in shared lib
On Monday, 20 October 2014 at 15:30:28 UTC, Martin Nowak wrote: On 10/20/2014 12:32 AM, MrSmith wrote: Than any module can search for registered modules and try to cast them to concrete type (upcast). That can't work because the notion of types only exists during compilation. Therefor it's not possible to load new types at runtime and use them in code that was compiled without knowing those types. You should simply use interfaces to achieve your goal. In this case ether shared lib knows actual type. But i've tried it with interfaces, (upcast also), or do you mean something else? 1) I want application to load IModule from .so/.dll 2) Any other module should be able to cast that IModule to actual type (upcast) and test if result is !null. 3) Can i do this using interfaces or without them? I.e. if in first example module2 is interface
Making plugin system with shared libraries. Upcast in shared lib
I'm using Windows. I was making some sort of modular system where you can define modules that are loaded by host application. Here is a simple example https://gist.github.com/MrSmith33/7692328455a19e820a7c Now i want to separate these modules in separate shared libs and link them on the fly. The issue i have is that some modules can define some useful functions and in order to use them you need to upcast to concrete type. This is easy in a single application, but i was unable to do this through dll boundary. So basically all dll's have factory function that returns an instance of IModule. Than any module can search for registered modules and try to cast them to concrete type (upcast). in imodule.d interface IModule { string name(); void init(ModuleManager modman); } in module1.d (dll) class Module1 : IModule { override string name() {return Module1;} override void init(ModuleManager modman) { IModule module2 = modman.findModule(Module2); if (auto m = cast(Module2)module2) { m.someMethod2(); } } } in module2.dll (dll) class Module2 : IModule { override string name() {return Module2;} override void init(ModuleManager modman){} void someMethod2(){} } And what files should i compile with what packages? application IModule main other module1 dll IModule Module1 Module2 - should i import it, compile of import .di file? module2 dll IModule Module2 Is it possible at all? Or it is an issue with Windows shared lib support?
Re: Trying to get Derelict.opengl3.gl3 and derelict.glfw3.glfw3 to work together
On Wednesday, 24 September 2014 at 13:59:41 UTC, csmith wrote: On Wednesday, 24 September 2014 at 11:07:56 UTC, Mike Parker wrote: You're using deprecated OpenGL calls. The gl3 module only declares and loads modern OpenGL. If you really want to use the deprecated stuff, change the gl3 import to this: import derelict.opengl3.gl; And call load/reload on the DerelictGL instance rather than DerelictGL3. All of the modern stuff will still be available. Thanks for this. Was using GLFW's example trying to troubleshoot it. Wasn't really considering them using the outdated functions. I guess I'll look for a different tutorial elsewhere. Also, thanks for making it in the first place! We have opengl tutorials in D https://github.com/d-gamedev-team/opengl-tutorials
Re: Ropes (concatenation trees) for strings in D ?
On Saturday, 16 August 2014 at 02:26:29 UTC, ketmar via Digitalmars-d-learn wrote: On Fri, 15 Aug 2014 19:04:10 -0700 Timothee Cour via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: sounds like my C library based on this article: http://e98cuenc.free.fr/wordprocessor/piecetable.html i'm slowly converting my C code to D (nothing fancy yet, still C-style). it's not a 'real' rope -- it's designed for text editing tasks, and it allocates like crazy now, but it's pretty usable to writing rich text editors and renderers in various GUI toolkits. don't know when i'll finish first working version though, it's all little tedious and i have alot other things to do. but i'll announce it when it will be done. ;-) I've done some progress on making piece table some time ago, but have no time atm. Have a look https://github.com/MrSmith33/textedit-d It supports inserting, removing, undo, redo and slicing. Provides forward range interface. Can you also share your progress?
Re: Using input ranges with std.regex?
On Wednesday, 25 April 2012 at 21:43:11 UTC, Dmitry Olshansky wrote: On 25.04.2012 23:08, H. S. Teoh wrote: Does std.regex support input ranges to match()? Or do I need to convert to string first? For now, yes you have to convert them. Any random access range of code units should do the trick but stringish template constraints might kill that. I plan to extend this eventually. The problematic point is that match internally is delimited by integer offsets (indices). Forward ranges technically can work (the match then will return something like take(..., n);) with a bunch of extra .save calls. Input ranges can't be used at all. Is there any progress on this thing?
Re: delegate issue
On Monday, 2 June 2014 at 06:56:54 UTC, captaindet wrote: hi, i stumbled upon something weird - it looks like a bug to me but maybe it is a feature that is unclear to me. so i know i can declare function and delegate pointers at module level. for function pointers, i can initialize with a lambda. BUT for delegates i get an error - see below i found out that using module static this(){...} provides a workaround, but why is this necessary? also, if there is a good reason after all then the error message should make more sense. /det ps: i know there is a shorthand syntax for this. module demo; int function(int) fn = function int(int){ return 42; }; // ok int delegate(int) dg = delegate int(int){ return 666; }; // demo.d(6): Error: non-constant nested delegate literal expression __dgliteral6 void main(){} You can't assign a delegate at compile time now. But you can do this in static constructor like this: int delegate(int) dg; static this() { dg = delegate int(int){ return 666; }; }
Re: Programming a Game in D? :D
Also opengl tutorials for D https://github.com/d-gamedev-team/opengl-tutorials
Re: Inherit of attributes
On Friday, 25 April 2014 at 07:59:29 UTC, Temtaime wrote: Hi ! http://dpaste.dzfl.pl/2fa3dd2ea834 Why S.init not pure ? Is it expected behavior or bug ? Thanks! Fix http://dpaste.dzfl.pl/03f73cd958f4