Re: Real simple question... for good programmers
__MWE Code:__ ``` module DlangForumsMWE; import std.stdio; import std.algorithm.mutation; int main() { //string[] tokens = userSID.output.split!isWhite; //writeln("tokens = ", tokens); auto tokens = ["SID", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "S-1-5-21-3823976785-3597194045-4221507747-1779", "", "", "", "", "", "", "", ""]; writeln("Before:\n", tokens); writeln(); tokens = tokens.remove!(x => x == ""); writeln("After:\n", tokens); readln(); return 0; } ``` __Outputs:__ ``` Before: ["SID", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "S-1-5-21-3823976785-3597194045-4221507747-1779", "", "", "", "", "", "", "", ""] After: ["SID", "S-1-5-21-3823976785-3597194045-4221507747-1779"] ```
Re: Real simple question... for good programmers
On Saturday, 22 October 2022 at 21:53:05 UTC, WhatMeWorry wrote: string[] tokens = userSID.output.split!isWhite; writeln("tokens = ", tokens); tokens = ["SID", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "S-1-5-21-3823976785-3597194045-4221507747-1779", "", "", "", "", "", "", "", ""] Is there a clever way that I can discard all the extra null strings in the resultant string array? I've been playing with isControl, whitespace, etc. Ready to rip my hair out. Why not `strip`? Works on ranges: https://dlang.org/phobos/std_algorithm_mutation.html#.strip
Removing elements from dynamic arrays?
https://forum.dlang.org/post/eih04u$1463$1...@digitaldaemon.com A version of the code that takes `T which` as a parameter instead of `int index`. ``` // remove an item from an array template drop(T) { T drop( inout T[] arr, T which ) { int i; T result; for (i=0; i < arr.length; i++) { if (arr[i] == which) { result = arr[i]; break; } } debug if ( which >= arr.length) throw new Exception(str.format("Attempt to drop the %s of value %s from an array, but it was not found.", typeid(T), which)); } for (; i < arr.length; i++) { arr[i] = arr[i + 1]; } arr.length = arr.length - 1; return result; } } ``` It has worse case complexity O(2n) = O(n) whereas the other one can run in half as long minimally and sometimes just as long (but still O(n)), but usually one needs to linear search for the entry first.
How do you get passed `LNK: cannot find python39.lib` errors when using PyD for Python to D calling?
``` C:\Users\FruitfulApproach\Desktop\BananaCats\BananaCatsInD\pyd\infrastructure\pyd\make_object.d(1190): Deprecation: returning `` escapes a reference to parameter `this` C:\Users\FruitfulApproach\Desktop\BananaCats\BananaCatsInD\pyd\infrastructure\pyd\make_object.d(1190): perhaps annotate the parameter with `return` travis_fold:end:pyd_compile-24d8b1b1-b462-11ec-a868-3417eb9e56b5 library_dirs: ['C:\\Python39\\libs', 'C:\\Python39\\PCbuild\\amd64'] runtime_library_dirs: [] libraries: ['python39'] travis_fold:start:pyd_link-259ac93e-b462-11ec-ab18-3417eb9e56b5 C:\D\dmd-2.096.1\windows\bin64\dmd.exe -m64 -debug -ofbuild\lib.win-amd64-3.9\hello_world.cp39-win_amd64.pyd build\temp.win-amd64-3.9\Release\infra\temp.obj -L/LIBPATH:\"C:\Python39\libs\" -L/LIBPATH:\"C:\Python39\PCbuild\amd64\" python39.lib build\temp.win-amd64-3.9\Release\infra\python_dll_def.def LINK : fatal error LNK1104: cannot open file 'python39.lib' Error: linker exited with status 1104 travis_fold:end:pyd_link-259ac93e-b462-11ec-ab18-3417eb9e56b5 error: command 'C:\\D\\dmd-2.096.1\\windows\\bin64\\dmd.exe' failed with exit code 1 ``` I'm following the instructions here: https://pyd.readthedocs.io/en/latest/extend.html#basics And here: https://pyd.readthedocs.io/en/latest/dub.html But I haven't tried making a project with dub yet. I just tried running the env vars-setting .bat file (second link) on `setup.py` and also my `main.py` and then running `python setup.py install`, which produces the above error.
Function prototype overloading does not work ?
``` module expr; import dots; import operator; import equation; import var; import var_expr; import zz_const; class Expr { public: void opBinary(string op)(string s) const { static if (op == "+") { Expr right = null; if (s == ".." || s == "..." || s == "") { right = new Dots(); } if (right !is null) return new Op("+", [this, right]); } } override string toString() const { assert(0); } Expr sub(Expr x, Expr y) { if (this == x) return y; return this; } Expr sub(Expr x, ref Var y) { return sub(x, new VarExpr(y)); } Expr sub(ref Var x, Expr y) { return sub(new VarExpr(x), y); } Expr sub(int x, Expr y) { return sub(ZZ(x), y); } Expr sub(Expr x, int y) { return sub(x, ZZ(y)); } Expr sub(ref Var x, ref Var y) { return sub(new VarExpr(x), new VarExpr(y)); } Expr sub(ref Var x, int y) { return sub(new VarExpr(x), ZZ(y)); } Expr sub(int x, ref Var y) { return sub(ZZ(x), new VarExpr(y)); } override bool opEquals(Object o) { return this is o; } } ``` See all the overloads I had to make to sub in order to bypass identity assignment for classes. I.e. Var can't be of type Expr. Anyway, this approach is not working because code calling `Expr.sub(int, Var)` is not seeing the definitions. It says no function matching those args, but clearly there are!
Does D have any number theory libraries?
In particular what I need are the fast implementations of: 1. The Nth prime number. 2. Prime Omega and/or Mobius function. 3. Works with some type of BigInt. 4. Primorial. 5. Divisors of N. 6. Extended GCD algorithm. They don't have to be the state-of-the art, but it would be nice if they didn't simply do the bruteforce algorithm everywhere.
`This` reference not accessible when overloading an operator?
I have an Integer class in integer.d. A RationalNumber class in rational_number.d, and they each import each other (so that could be the issue). However, this is not working: Symbol opBinary(string op : "/")(const Integer z) const { return new RationalNumber(this, z); } Getting: Error: class `rational_number.RationalNumber` member `this` is not accessible Error: template instance `integer.Integer.opBinary!"/"` error instantiating
I'm fucking tired of this shit... Why doesn't Visual D install ?
It says right on the front page of it, that it installs in 2019. I of course have the C++ tools installed already because I was doing C++ dev in Qt and needed to. Where's the Visual D menu? Where are the project types? This fucking sucks. Every time I think oh, I could use D on that, it would be perfect... it NEVER FUCKING WORKS. Fuck this shit.
Re: Is it possible to target all platforms that Qt Quick can target?
I cannot use QML for D or other D Qt libraries. I'm writing something important and need all of Qt Creator and its C++ editing environment. I don't wish to go through the bad experience of using those libraries. I've tried it before. I do D in Visual D, and that would be for the backend only, connected to the GUI code using a dynamic library. I will assume the answer is no, D is not support that yet (targeting all platforms with a dynamic library, all platforms that Qt Quick supports).
Re: Is it possible to target all platforms that Qt Quick can target?
Any ideas on this?
Re: Is it possible to target all platforms that Qt Quick can target?
On Monday, 12 August 2019 at 18:30:24 UTC, Kagamin wrote: You're probably interested in readiness, not possibility? I am interested in both. If I begin coding in D today, it will likely be 8 months until the backend is completed.
Is it possible to target all platforms that Qt Quick can target?
Hi, I'm writing my GUI in C++ & Qt Quick. I know that I could connect to D from the GUI code using a DLL, but can something similar be done on the other PC OS's and the mobile OS's? Thanks.
Re: VisualD phobos link error, only when I implement a few simple classes on top of a hello world program.
I tried re-installing DMD, and now for either 64-bit or x86 build mode, I'm getting the Phobos linker error: -- Build started: Project: BasicSimpleTypeTheoryApp, Configuration: Debug x64 -- Building x64\Debug\BasicSimpleTypeTheoryApp.exe... LINK : fatal error LNK1104: cannot open file 'phobos64.lib' Building x64\Debug\BasicSimpleTypeTheoryApp.exe failed! Details saved as "file://C:\Users\FruitfulApproach\Desktop\_SIMPLE_TYPE_THEORY\BasicSimpleTypeTheoryApp\BasicSimpleTypeTheoryApp\x64\Debug\BasicSimpleTypeTheoryApp.buildlog.html" == Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped == In other words re-installing didn't help.
VisualD phobos link error, only when I implement a few simple classes on top of a hello world program.
What is this phobos crap? I've tried renaming all my modules with an _ (underscore) in case they were colliding with phobos. -- Build started: Project: BasicSimpleTypeTheoryApp, Configuration: Debug Win32 -- Building Win32\Debug\BasicSimpleTypeTheoryApp.exe... LINK : fatal error LNK1104: cannot open file 'phobos32mscoff.lib' Building Win32\Debug\BasicSimpleTypeTheoryApp.exe failed! All I have is two abstract classes essentially with 2 1-line methods, nothing out-of-the ordinary. Thanks.
Re: VisualD phobos link error, only when I implement a few simple classes on top of a hello world program.
On Wednesday, 6 February 2019 at 17:53:05 UTC, Enjoys Math wrote: What is this phobos crap? I've tried renaming all my modules with an _ (underscore) in case they were colliding with phobos. -- Build started: Project: BasicSimpleTypeTheoryApp, Configuration: Debug Win32 -- Building Win32\Debug\BasicSimpleTypeTheoryApp.exe... LINK : fatal error LNK1104: cannot open file 'phobos32mscoff.lib' Building Win32\Debug\BasicSimpleTypeTheoryApp.exe failed! All I have is two abstract classes essentially with 2 1-line methods, nothing out-of-the ordinary. Thanks. Minimal example is now just hello world: module BasicSimpleTypeTheoryApp; import std.stdio; //import _variable; int main() { // auto v = new Variable("v"); writeln("Hello D World!\n"); readln(); return 0; }
Re: Has anyone tried making a QtCreator plugin for D and what is your experience?
On Saturday, 12 January 2019 at 16:09:22 UTC, Laurent Tréguier wrote: On Saturday, 12 January 2019 at 15:16:25 UTC, Laurent Tréguier wrote: QtCreator 4.8.0 introduced support for the LSP last month : https://blog.qt.io/blog/2018/12/06/qt-creator-4-8-0-released I think I'm going to add it to the list of editors to look into and perhaps try to make a plugin for it. Correction: a language server can simply be set up in the LSP plugin's options after the plugin has been enabled, so some amount of D support is achievable already. I see your links. Would you like to work on this together? Social coding is more powerful than solo coding IMO.
Has anyone tried making a QtCreator plugin for D and what is your experience?
I'm 5 years an expert at PyQt5 in conjunction with QtCreator-designed widgets. Where D is lacking is a good GUI editor and GUI library support. I am starting by building a python-based project called QDmt = Qt/D manager It will do for you, in a cross-platform way, the laborious task of compiling the Qt framework from git: https://wiki.qt.io/Building_Qt_5_from_Git And also it will guide you through building Qt Creator itself. We can then use this tool to help us hack the Qt Creator code and make it work for D (assuming a plugin isn't enough). Building Qt is quite essential, as I am unable to get OpenGL support without building it for example. So not only will we get traffic from TDPL people but from others who are only familiar with Qt and had to build it for some reason. This would then be the goto tool for that. Then they will see firsthand how easy it is (at the click of a few buttons) to work with D. This will cause a huge influx of users to dlang.org and a rift in the spacetime continuum!
Re: Coedit almost works for me, except when I go to add peggged
On Friday, 11 January 2019 at 18:36:18 UTC, 0xEAB wrote: On Friday, 11 January 2019 at 18:27:37 UTC, Enjoys Math wrote: Dude, that doesn't work either. lol If you're using DUB, add the dependency manually to your project: "dependencies": {"pegged": "~>0.4.4"} You will have to be more specific. I don't see dub.json anywhere within Coedit IDE.
Re: Coedit almost works for me, except when I go to add peggged
On Friday, 11 January 2019 at 17:38:31 UTC, Neia Neutuladh wrote: On Fri, 11 Jan 2019 17:25:29 +, Enjoys Math wrote: Package peggged not found for registry at https://code.dlang.org/ The package name is pegged, not peggged. Two g's, not three. Dude, that doesn't work either. lol
Re: All these errors running basic Pegged helloworld example.
On Friday, 11 January 2019 at 17:44:33 UTC, Michelle Long wrote: On Sunday, 27 September 2015 at 06:30:37 UTC, Enjoys Math wrote: [...] You need to add most of the pegged files... there are more than 3. Try adding them all first then remove the junk like the examples, docs, etc until it works. Why should I do that? There's a DUB feature in Coedit... it should work!
Re: All these errors running basic Pegged helloworld example.
On Sunday, 27 September 2015 at 07:16:51 UTC, BBasile wrote: On Sunday, 27 September 2015 at 06:30:37 UTC, Enjoys Math wrote: The example is: import pegged.grammar; mixin(grammar(` Arithmetic: Term < Factor (Add / Sub)* Add < "+" Factor Sub < "-" Factor Factor < Primary (Mul / Div)* Mul < "*" Primary Div < "/" Primary Primary < Parens / Neg / Pos / Number / Variable Parens < "(" Term ")" Neg < "-" Primary Pos < "+" Primary Number < ~([0-9]+) Variable <- identifier `)); I'm using Visual D and have C:\MyProjects\D\Pegged (the git clone of pegged) added to the add'l imports field under project properties > compiler. I'm getting errors like these: Error 1 Error 42: Symbol Undefined _D6pegged7dynamic7grammar7grammarFAyaHAyaDFS6pegged3peg9ParseTreeZS6pegged3peg9ParseTreeZS6pegged7dynamic7grammar14DynamicGrammar (pegged.dynamic.grammar.DynamicGrammar pegged.dynamic.grammar.grammar(immutable(char)[], pegged.peg.ParseTree delegate(pegged.peg.ParseTree)[immutable(char)[]])) C:\MyProjects\D\PeggedPractice\ Error 2 Error 42: Symbol Undefined _D6pegged7dynamic7grammar12__ModuleInfoZ C:\MyProjects\D\PeggedPractice\ The # of errors was greatly reduced when I added the 3 pegged source files to my project. What can be going wrong? Thanks! You must also pass the source root with -I: -IC:\MyProjects\D\Pegged (and maybe you miss another source since there are 5: '..\repos\Pegged\pegged\grammar.d' '..\repos\Pegged\pegged\parser.d' '..\repos\Pegged\pegged\peg.d' '..\repos\Pegged\pegged\dynamic\grammar.d' '..\repos\Pegged\pegged\dynamic\peg.d' ) By the way with Coedit you wouldn't have this kind of problems (Pegged is part of metaD). You can even run some test on Pegged without saving the file / without a project (this is called a runnable module). This is just what I've done. At least compile pegged as a static lib, then it's simpler, you just have to pass the -I pegged.lib and your custom sources files. Thanks, I downloaded Coedit, but it's not working with pegged (using the library manager dub button)
Coedit almost works for me, except when I go to add peggged
I open up the Library Manager in Coedit. I click on the DUB icon. I enter in 'pegged' then click the green check. Errors: Package peggged not found for registry at https://code.dlang.org/ (fallback ["registry at http://code.dlang.org/;, "registry at https://code-mirror.dlang.io/;, "registry at https://code-mirror2.dlang.io/;, "registry at https://dub-registry.herokuapp.com/;]): (1): Error: Got JSON of type null_, expected object. (1): Error: Got JSON of type null_, expected object. error, failed to fetch the package Fetching pegged ~master... error, the DUB description cannot be located or it has not the JSON format Fucking fuck, nothing ever works for me... -__-
dub generate visuald shits on me
I do: dub init simple_type_theory cd simple_type_theory dub generate visuald Errors: C:\Users\FruitfulApproach\Desktop\_SIMPLE_TYPE_THEORY\simple_type_theory>dub generate visuald simple_type_theory Building package simple_type_theory in C:\Users\FruitfulApproach\Desktop\_SIMPLE_TYPE_THEORY\simple_type_theory\ Cannot open file `.dub\simple_type_theory.visualdproj' in mode `wb' (No such file or directory)
Re: Why can't or shouldn't I just hash the address of an object? And how.
On Sunday, 30 December 2018 at 05:54:05 UTC, Neia Neutuladh wrote: On Sun, 30 Dec 2018 05:36:41 +, Enjoys Math wrote: Is it: typeof(T).getHash()? This gets the hashcode for the object by calling toHash() on it. Or does that do something other than just get the address? It XORs the address with a bitwise rotation of the address. This reduces collisions since objects are allocated aligned. As for your larger problem, I'd strongly tend toward using a database to hold application state instead of keeping it in memory. Thanks, mon! :D I have decided to use long databaseID's everywhere, so that will fix that issue. I can key an AA easily by a long. I am building the database myself, I already evaluated each graph database out there, and for some reasons or others they don't suit our needs. So I'm doing a very custom database, not one I can re-use or distribute. It's just for commutative diagrams (in math) and my app called ZoomSpace. It is really fun to code this thing. I am making it super efficient by doing the label matching with a Trie (my regexes are very simple).
Why can't or shouldn't I just hash the address of an object? And how.
I am creating a custom graph database for our app. It holds not one huge graph but a collection of independent graphs. I would like to be able to delete them without looping through a range of billions of Graph class references. How can I accomplish this with an AA and hasing? Is it: typeof(T).getHash()? Or does that do something other than just get the address? Is this a bad idea for an App communities main content server?
How do you get a .dub project to build / run / debug in Visual D?
I'm referring mainly to the `dagon` game engine. Doing: dub build :tutorial1 dub run :tutorial1 works on windows 10. I'm not sure how to replicate this build process with Visual Studio 2017 project settings. Dagon is building, but I'm getting errors with a basic Hellow World app in Dagon. I don't think it's currently using dub to build.
Re: Do D's std.signals check for already-connected slot and simply ignore the call?
Answer: they don't connect uniquely, you have to manage that yourself.
Do D's std.signals check for already-connected slot and simply ignore the call?
If they don't, I have to wrap it like so: import std.signals; class Signal(T) { protected: mixin Signal!(T); }; class Changed(T) : Signal!T { protected: void delegate(T)[] slots; public: override void connect(void delegate(T) slot) { foreach (s; slots) { if (s == slot) return; } slots ~= slot; super.connect(slot); } override void disconnect(void delegate(T) slot) { import std.algorithm; foreach (s; slots) { if (s == slot) { slots.remove(s); super.disconnect(slot); break; } } } override void disconnectAll() { super.disconnectAll(); } } ??
Re: Access violation connecting a signal / slot
Solved: I forgot to initialize some member variable along the way, which is a class so needed to be new'd. Thanks.
Access violation connecting a signal / slot
I have a class or struct (have tried both; same error): module track_changes; import std.array; import std.signals; class TrackChanges(T) { private: T[] _stack; int _current = 0; public: mixin Signal!(T); TrackChanges opAssign(TrackChanges x) { this = x(); return this; } T opAssign(T x) { if (x != this.opCall()) { insertInPlace(_stack, ++_current, x); } return x; } T opCall() { return _stack[_current]; } } I've tried these two approaches (tried both; same error): class MyClass : TrackChanges!MyClass { } class MyClass { int b; TrackChanges!MyClass changes; } Both result in an access violation within the `std.signals` library upon calling connect in my main() program.
Re: How do you connect Python with D via socket, I'm still getting connection refused error
On Friday, 4 May 2018 at 13:52:29 UTC, Andy Smith wrote: On Thursday, 3 May 2018 at 23:58:24 UTC, Enjoys Math wrote: Error - [...] Haven't run it, but two things to try... On D side try adding listen after bind. On python side. Don't think you need to call bind the client socket ( this may cause problems). Cheers, A. That got it to work, nvm.
How do you connect Python with D via socket, I'm still getting connection refused error
Error - builtins.ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it Python Side --- from PyQt5.QtWidgets import QApplication, QMainWindow import sys import socket import settings if __name__ == "__main__": app = QApplication([]) window = QMainWindow() window.show() host = socket.gethostname() sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind((host, 0))# have os choose random available port print(host) sock.connect((host, settings.debugPort)) try: # Send data message = 'This is the message. It will be repeated.' print(sys.stderr, 'sending "%s"' % message) sock.sendall(message.encode()) # Look for the response amount_received = 0 amount_expected = len(message) while amount_received < amount_expected: data = sock.recv(16) amount_received += len(data) print(sys.stderr, 'received "%s"' % data) finally: print(sys.stderr, 'closing socket') sock.close() sys.exit(app.exec_()) And the D Side -- module server; import core.thread; import std.socket; import std.experimental.logger; class Server : Thread { private: Socket listener; int backlog; string address; ushort port; SocketSet sockSet; Socket[] clients; bool running; public: this(ushort port, string address="") { super(& run); if (address == "") address = "127.0.0.1"; this.port = port; this.address = address; backlog = int.max; listener = null; running = false; } bool setupSocket() { try { listener = new Socket(AddressFamily.INET, SocketType.STREAM); auto address_list = getAddress(address, port); if (address_list.length) { listener.bind(address_list[0]); sockSet = new SocketSet(); } } catch (Exception e) { log(LogLevel.critical, e.toString()); return false; } return true; } void start() { if (listener is null) { if (! setupSocket()) return; } running = true; if (! isRunning) super.start(); } void stop() { running = false; } private: void run() { char[1024] buffer; while(running) { sockSet.reset(); sockSet.add(listener); foreach (client; clients) sockSet.add(client); if (Socket.select(sockSet, null, null)) { foreach (client; clients) { if (sockSet.isSet(client)) { auto got = client.receive(buffer); client.send(buffer[0 .. got]); } } if (sockSet.isSet(listener)) { auto newSocket = listener.accept(); newSocket.send("Hello!\n"); clients ~= newSocket; } } } } }
Re: What's the latest news for calling D from python 3 using ctypes?
On Wednesday, 28 February 2018 at 17:34:49 UTC, Enjoys Math wrote: == Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped == For some reason, idk why, PyD is a dub source dependency (as opposed to a library). If you add \path\to\pyd to the include directory(?) dub variable (or -I\path\to\pyd to dmd/ldc/gdc) it should hopefully work. Seems like it already is. In VisualD compiler settings / additional import paths it's set to: "..\source" "..\..\..\..\..\Users\FruitfulApproach\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure" Solution: Use C++ instead.
Re: What's the latest news for calling D from python 3 using ctypes?
== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped == For some reason, idk why, PyD is a dub source dependency (as opposed to a library). If you add \path\to\pyd to the include directory(?) dub variable (or -I\path\to\pyd to dmd/ldc/gdc) it should hopefully work. Seems like it already is. In VisualD compiler settings / additional import paths it's set to: "..\source" "..\..\..\..\..\Users\FruitfulApproach\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure"
Re: What's the latest news for calling D from python 3 using ctypes?
On Wednesday, 28 February 2018 at 00:18:17 UTC, Nicholas Wilson wrote: On Tuesday, 27 February 2018 at 23:59:10 UTC, Enjoys Math wrote: I am making a library that will run very speedily in D (or, failing that, C++) and do the backend work of a PyQt5 gui. Was wondering the simplest route to accomplish this, preferably in ctypes calls. Thanks. http://code.dlang.org/packages/pyd With PyD you can wrap the D functions for python instead of calling them through types in python. How would you get VisualD + PyD to work nicely together? See my failed build post above.
Re: What's the latest news for calling D from python 3 using ctypes?
Can't build now: -- Build started: Project: categorytheorybackend, Configuration: debug Win32 -- Building C:\MyProjects\___ENJOYS_MATH\CategoryTheoryFrontend\CategoryTheoryBackend\categorytheorybackend.exe... Error: Error writing file 'obj\debug\dummy\dummy\dummy\dummy\dummy\categorytheorybackend\..\..\..\..\..\Users\FruitfulApproach\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\abstract_.obj' Building C:\MyProjects\___ENJOYS_MATH\CategoryTheoryFrontend\CategoryTheoryBackend\categorytheorybackend.exe failed! Details saved as "file://C:\MyProjects\___ENJOYS_MATH\CategoryTheoryFrontend\CategoryTheoryBackend\.dub\obj\debug\dummy\dummy\dummy\dummy\dummy\categorytheorybackend\categorytheorybackend.buildlog.html" == Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==
Re: What's the latest news for calling D from python 3 using ctypes?
On Wednesday, 28 February 2018 at 01:10:36 UTC, Enjoys Math wrote: Got it. dub init myproject from within my python frontend source dir will create a subdirectory. Then you do dub generate visuald from within the subdir myproject.
Re: What's the latest news for calling D from python 3 using ctypes?
Got it. dub init myproject from within my python frontend source dir will create a subdirectory.
Re: What's the latest news for calling D from python 3 using ctypes?
On Wednesday, 28 February 2018 at 00:18:17 UTC, Nicholas Wilson wrote: On Tuesday, 27 February 2018 at 23:59:10 UTC, Enjoys Math wrote: I am making a library that will run very speedily in D (or, failing that, C++) and do the backend work of a PyQt5 gui. Was wondering the simplest route to accomplish this, preferably in ctypes calls. Thanks. http://code.dlang.org/packages/pyd With PyD you can wrap the D functions for python instead of calling them through types in python. Thank you! That looks like what I need. How do you install pyd with dub so that I can import ? dub fetch pyd dub run pyd doesn't work. Will try other params and get back to this thread.
What's the latest news for calling D from python 3 using ctypes?
I am making a library that will run very speedily in D (or, failing that, C++) and do the backend work of a PyQt5 gui. Was wondering the simplest route to accomplish this, preferably in ctypes calls. Thanks.
Is this an okay representation of a dynamically sized Matrix, to be used for HMM matrices m = (A,B)
Code: module matrix; import std.array; struct Matrix(E) { private: E[][]; this() { } void deleteRow(int i) { E = E[0..i] ~ E[i..$]; } void deleteColumn(int j) { for (int i=0; i < E.length; i++) { E[i] = E[i][0..j] ~ E[i][j..$]; } } void insertRow(int i, E[] row) { if (E.length != 0) assert(E[0].length == row.length); E.insertInPlace(i, row); } void insertColumn(int j, E[] col) { for (int i=0; i < E.length; i++) { E[i].insertInPlace(j, col[i]); } } int numRows() { return E.length; } int numColumns() { if (E.length == 0) return 0; return E[0].length; } } Is there a more efficient way of doing this, knowing that I'll be inserting columns / rows every time we need to create a new hidden state so this matrix will be huge, for a good model. By huge we'll probably use the full capacity of a long[] in D. I've already tried doing this in MQL5 and we exceeded easily the max array capacity.
What is a robust implementation of a file mutex? Mine is sucking...
I share data between two programs. Programs on side A output .bin files full of doubles like around 19KB each. And there can be between 30 - 100 of these bin files. I have a thread for each file on the B side, which first checks the existence of filename__MUTEX.txt. If it exist, then a program on side A is busy with filename.bin. The same goes for programs on A side waiting for program on B side to finish with the file (reading it). A -> B (data flow) I don't think the easiest solution is sockets. Those are a pain for me because I'm new to them. Well anyway, threads on side B are crashing because they can't find the input file occasionally! It would be nice to know that my file mutex method is not the problem.
Strange behavior of cast(int[]) json["my int list"].array
I had it working in an earlier program. Now I have: main.d -- import std.json; import std.file; int main() { JSONValue settings; settings = parseJSON("settings.txt"); auto intList = cast(int[]) settings["int list"].array; writeln(intList); readln(); } for input: settings.txt { "int list" : [1,2,3,4,5] } printing: [1,0,2,0,2,0,2,0,3,0,2, ...] (length = 20) Should I access each member int the array individually?
Re: How do you open a second console? I have multiple streams of info I want printed.
On Monday, 13 November 2017 at 20:24:38 UTC, Jonathan M Davis wrote: On Monday, November 13, 2017 19:58:51 Enjoys Math via Digitalmars-d-learn wrote: Hi, I tried googling and didn't find anything. I have thread doing a time-intensive search and I want its results printed to a second console while the main console displays what I already have writing. Thanks. When something displays to the console, it's by the program writing to stdout or stderr. Then by default, the console displays that output (though it could be redirected to a file or pipe or whatnot). So, the program itself isn't even in control of sending data to the console it's running in, let alone another console. It just sends the data to stdout. Probably the simplest way to get data displaying on a second console is to write the data to a file and then tail -f the file in the other console. - Jonathan M Davis I came up with an alternative solution. Having a command line option to show the second stream: while(true) { auto line = readln(); if (line) { if (line == "quit") return; else if (line == "dbg matrix") yoda.setShowMatrix(true); else if (line == "stop dbg") yoda.setShowMatrix(false); else if (line == "restart") yoda.start(); } Thread.sleep(dur!"msecs"(100)); }
How do you open a second console? I have multiple streams of info I want printed.
Hi, I tried googling and didn't find anything. I have thread doing a time-intensive search and I want its results printed to a second console while the main console displays what I already have writing. Thanks.
Re: Connecting python to D on socket of localhost : target machine actively refuses connection
On Friday, 22 September 2017 at 05:43:24 UTC, Nicholas Wilson wrote: On Friday, 22 September 2017 at 04:37:44 UTC, Enjoys Math wrote: On Friday, 22 September 2017 at 04:25:00 UTC, Enjoys Math wrote: I've tried opening the port for TCP with windows 10 firewall settings. Same result. What tool would best help me debug this? Wireshark or is that too low level? I've used Hercules: http://www.hw-group.com/products/hercules/index_en.html I set up a TCP server with it, and it got the message sent from python. Therefore there is something wrong with the D server. Could it be that you need to call `super();` at the end of your constructor, after your data initialisation? Nope, the run() method gets called.
Re: Connecting python to D on socket of localhost : target machine actively refuses connection
On Friday, 22 September 2017 at 04:25:00 UTC, Enjoys Math wrote: I've tried opening the port for TCP with windows 10 firewall settings. Same result. What tool would best help me debug this? Wireshark or is that too low level? I've used Hercules: http://www.hw-group.com/products/hercules/index_en.html I set up a TCP server with it, and it got the message sent from python. Therefore there is something wrong with the D server.
Re: Connecting python to D on socket of localhost : target machine actively refuses connection
I've tried opening the port for TCP with windows 10 firewall settings. Same result. What tool would best help me debug this? Wireshark or is that too low level?
Connecting python to D on socket of localhost : target machine actively refuses connection
Here's my minimal D code (server.d): module server; import core.thread; import std.socket; import std.experimental.logger; class Server : Thread { private: Socket listener; int backlog; string address; ushort port; SocketSet sockSet; Socket[] clients; bool running; public: this(ushort port, string address="") { super(& run); if (address == "") address = "DESKTOP-T49RGUJ"; this.port = port; this.address = address; backlog = int.max; listener = null; running = false; } bool setupSocket() { try { listener = new Socket(AddressFamily.INET, SocketType.STREAM); listener.bind(new InternetAddress(address, port)); sockSet = new SocketSet(); } catch (Exception e) { log(LogLevel.critical, e.toString()); return false; } return true; } void start() { if (listener is null) { if (! setupSocket()) return; } running = true; if (! isRunning) super.start(); } void stop() { running = false; } private: void run() { char[1024] buffer; while(running) { sockSet.reset(); sockSet.add(listener); foreach (client; clients) sockSet.add(client); if (Socket.select(sockSet, null, null)) { foreach (client; clients) { if (sockSet.isSet(client)) { auto got = client.receive(buffer); client.send(buffer[0 .. got]); } } if (sockSet.isSet(listener)) { auto newSocket = listener.accept(); newSocket.send("Hello!\n"); clients ~= newSocket; } } } } } And here's the simple python client (main.py): from PyQt5.QtWidgets import QApplication, QMainWindow import sys import socket import settings if __name__ == "__main__": app = QApplication([]) window = QMainWindow() window.show() host = socket.gethostname() sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #sock.bind((host, 0))# have os choose random available port print(host) sock.connect((host, settings.debugPort)) try: # Send data message = 'This is the message. It will be repeated.' print(sys.stderr, 'sending "%s"' % message) sock.sendall(message.encode()) # Look for the response amount_received = 0 amount_expected = len(message) while amount_received < amount_expected: data = sock.recv(16) amount_received += len(data) print(sys.stderr, 'received "%s"' % data) finally: print(sys.stderr, 'closing socket') sock.close() sys.exit(app.exec_()) --- The client throws: builtins.ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it Now, true this is python & D, but the client is generic and minimal so bear with me. Thanks. I've also tried 'localhost' on both sides.
Re: What is the canonical way to subclass Thread and make it pauseable?
On Sunday, 17 September 2017 at 19:57:05 UTC, Enjoys Math wrote: How do you write a pauseable Thread? Thanks. This seems to work: module data_rates_thread; import core.thread; import std.datetime; class DataRatesThread : Thread { private: uint loopSleep; bool paused; public: this(uint loopSleep) { super(& run); this.loopSleep = loopSleep; paused = true; } void pause() { paused = true; } void start() { paused = false; super.start(); } private: void run() { import std.stdio; int k = 0; while (! paused) { writeln(k); k ++; if (loopSleep != 0) sleep(dur!"msecs"(loopSleep)); } } } Which is not the best way to pause and resume, but it works for my application.
What is the canonical way to subclass Thread and make it pauseable?
How do you write a pauseable Thread? Thanks.
Re: My friend can't install DMD 2.076.0 after he deleted contents of C:\D
On Sunday, 17 September 2017 at 05:30:51 UTC, Enjoys Math wrote: Series of messages from installer: DMD v2.076.0 is installed on your system Press 'OK' to replace by DMD 2.076.0 An error occurred when removing DMD v2.076.0 Run 'dmd-2.076.0.exe /f to force install And using the command line has no effect - it repeats the above. He got into this situation by accidentally installing Visual Studio and / or Visual D to C:\D where I told him to install D to. At one point I told him to delete everything in C:\D and start over. *That* was a mistake... He's used a trial version of Revo-Uninstaller to remove contents of registry. The issue remains. How can we repair his system so that we can install D on it again? Thanks. I sent him a copy of uninstall.exe from my D install root and Revo then "removed D from the list" so that seemed to work. We ran D installer again and it worked!
My friend can't install DMD 2.076.0 after he deleted contents of C:\D
Series of messages from installer: DMD v2.076.0 is installed on your system Press 'OK' to replace by DMD 2.076.0 An error occurred when removing DMD v2.076.0 Run 'dmd-2.076.0.exe /f to force install And using the command line has no effect - it repeats the above. He got into this situation by accidentally installing Visual Studio and / or Visual D to C:\D where I told him to install D to. At one point I told him to delete everything in C:\D and start over. *That* was a mistake... He's used a trial version of Revo-Uninstaller to remove contents of registry. The issue remains. How can we repair his system so that we can install D on it again? Thanks.
Re: How do I create a fileWatcher with an onFileChange event using spawn?
On Monday, 28 August 2017 at 06:27:20 UTC, Jacob Carlborg wrote: On 2017-08-25 23:25, Enjoys Math wrote: Something like this: module file_watcher; import std.concurrency; import std.file; import std.signals; import std.datetime; void fileWatcher(Tid tid, string filename, int loopSleep) { auto modified0 = timeLastModified(filename); while (true) { Â Â Â modified = timeLastModified(filename); Â Â Â if (modified > modified0) { Â Â Â modified0 = modified; Â Â Â //if (onFileChange !is null) Â Â Â //Â Â Â onFileChange(receiver); Â Â Â } Â Â Â sleep(dur!"msecs"(loopSleep)); } } But I'm not sure how to send the onFiledChange event. A delegate perhaps? Or you can look at any of the existing event driven libraries that do this: http://code.dlang.org/packages/vibe-core http://code.dlang.org/packages/libasync No a plain delegate won't work. There's something you're not telling me because I've tried delegates. They have to be shared or something, and that causes a big mess with my code.
Unable to set static data member of a class (results in default value 0)
I have: class DataSignal : Thread { public: static int dataReadDelay; void run() { while (true) { Thread.sleep(dur!"msecs"(dataReadDelay)); // Read in the new file data } } } in main I have: DataSignal.dataReadDelay = 8000; // initialize a bunch of signals Then when each thread is running they sleep for 0 seconds, and I can verify that dataReadDelay is staying at 0. I have initialized it no where else. This seems like a major bug.
Re: How do I send a message to a struct member function?
On Saturday, 26 August 2017 at 10:05:31 UTC, drug wrote: 26.08.2017 09:49, Enjoys Math Đ¿Đ¸ÑˆĐµÑ‚: I have a series of structs each of which needs to spawn a worker thread on initialization. There seems to be no way to send a message back to the struct for instance to cause a member function call on /that/ structs data. Please advise me. If it is appropriate for you the better way would be to send /that/ structs to the corresponding worker thread and then it can call any method. Another way is you can during worker thread spawning pass thread id and then pass messages back to parent thread. I can't do the second approach because the parent thread creates many instances of the struct, each of which need a call back to a method. How do I do the first method (in code) because I've tried 20 different ways already.
How do I send a message to a struct member function?
I have a series of structs each of which needs to spawn a worker thread on initialization. There seems to be no way to send a message back to the struct for instance to cause a member function call on /that/ structs data. Please advise me.
How do I create a fileWatcher with an onFileChange event using spawn?
Something like this: module file_watcher; import std.concurrency; import std.file; import std.signals; import std.datetime; void fileWatcher(Tid tid, string filename, int loopSleep) { auto modified0 = timeLastModified(filename); while (true) { modified = timeLastModified(filename); if (modified > modified0) { modified0 = modified; //if (onFileChange !is null) //onFileChange(receiver); } sleep(dur!"msecs"(loopSleep)); } } But I'm not sure how to send the onFiledChange event.
Is it possible to generate a pool of random D or D inline assembler programs, run them safely?
Without them crashing the app running them? Say by wrapping with try / catch? You can assume that I've limited the opcode addresses to the program and/or the data section which I'll try to put right next to the code. Reason is so I don't have to make my own VM. I want to mutate computable functions in a genetic-algorithm style, so in order to include the full space of computable functions I need a full programming language, or a VM that includes conditional jump instructions. The purpose of it is to make a real-time, short-lived function predictor.
Re: How do I cast to from byte[] <-> double for making a small assembler language VM to work?
Thanks for the replies. I will look at 3-address opcodes and consider unions. *Wonders if it matters that Program is a struct with opSlice / opSliceAssign overloaded*.
How do I cast to from byte[] <-> double for making a small assembler language VM to work?
class OpCode { private: byte[] bytes_; public: void opCall(Program program) const; byte[] bytes() const { return bytes_.dup; } } class AddD : OpCode { private: uint d, s; public: this(uint dst, uint src) { d = dst; s = src; } override void opCall(Program p) const { p[d..d+8] = cast(byte[])(cast(double)p[d..d+8] + cast(double)p[s..s+8]); } } --- The cast at the bottom gives a compiler error (can't cast byte[] to double).
D doesn't read the first character of a file (reads everything but the first chararacter) with either read() or readText()
DMD32 D Compiler v2.074.1 import std.file; void main() { string bigInput = readText("input.txt"); } The file is 7 MB of ascii text, don't know if that matters... Should I upgrade versions?
Re: Yesterday Visual D worked, today it does not!
On Monday, 17 July 2017 at 17:57:14 UTC, Enjoys Math wrote: I made a console app the other day and there were build options present. In the build options I had to specify the dmd2 executable directly. Then it worked (but that's another error). Today there are no build options! I tried creating a regular console app and a GDC/DMD console app. Okay, found them. You have to right-click on the project. Duh! :D
Yesterday Visual D worked, today it does not!
I made a console app the other day and there were build options present. In the build options I had to specify the dmd2 executable directly. Then it worked (but that's another error). Today there are no build options! I tried creating a regular console app and a GDC/DMD console app.
Re: How to get rid of const / immutable poisoning (and I didn't even want to use them...)
On Monday, 22 May 2017 at 20:12:56 UTC, Enjoys Math wrote: I had to employ const / immutable to some things to get passed some compiler errors. Then the poisoning continues. How do I get this code to run? String's will hold a T[] which actually will not be modified by the String methods ("immutable strings of T"). I did not want to use any immutable / const anywhere at first, but by passing in [1,2,3] Solved it by reverting back to original code (no const / immutable) on struct and creating two constructors: this(T[] s) { this.s = s; } this(const(T)[] s) { this.s = cast(T[]) s; }
Re: How to get rid of const / immutable poisoning (and I didn't even want to use them...)
On Monday, 22 May 2017 at 20:12:56 UTC, Enjoys Math wrote: I had to employ const / immutable to some things to get passed some compiler errors. Then the poisoning continues. How do I get this code to run? String's will hold a T[] which actually will not be modified by the String methods ("immutable strings of T"). I did not want to use any immutable / const anywhere at first, but by passing in [1,2,3] Crap. I hit tab then enter. By passing in a constant array which is totally legit for testing reasons, the compiler shits. Here's the code: module smallest_grammar; import std.conv; import std.algorithm; struct Symbol(T) { public: this(T sym, bool isVar) { this.sym = sym; this.is_var = isVar; } @property T symbol() { return sym; } @property bool isVar() { return is_var; } private: T sym; bool is_var = false; } immutable struct String(T) { public: this(immutable T[] s) { this.s = s; } alias s this; string toString() const { return to!string(s); } string flattened() const { string t = ""; foreach (c; s) t ~= to!string(c); return t; } size_t toHash() const @system pure nothrow { return hashOf(flattened()); } bool opEquals(ref const String t) const @system pure nothrow { if (t.length != this.length) return false; for(size_t k=0; k < t.length; k++) if (t.s[k] != this.s[k]) return false; return true; } // A compressible is a substring that occurs (non-overlappingly) >=2 and has a length >= 3 // or one that occurs >= 3 and has a length of 2 String[] compressibles() const { auto count = compressibleCount(); String[] substrings; foreach (s, n; count) substrings ~= s; return substrings; } size_t[String] compressibleCount() const { auto count = substringCount(2, size_t(s.length / 2)); foreach (str, n; count) if (str.length == 2 && n < 3 || str.length >= 3 && n < 2) count.remove(str); return count; } String[] substrings(int minLen=0, int maxLen=-1) const { auto count = substringCount(); String[] substrings; foreach (s, n; count) substrings ~= s; return substrings; } size_t[String] substringCount(int minLen=0, int maxLen=-1) const { if (maxLen == -1) maxLen = s.length; assert (maxLen <= s.length && minLen >=0 && minLen <= maxLen); size_t[String] count; if (minLen == 0) count[empty] = s.length + 1; for (size_t i=0; i < s.length - minLen; i++) { size_t max_len = min(s.length - i, maxLen); for (size_t l=1; l < max_len; l++) { auto substr = String(this.s[i..i+l]); if (!(substr in count)) count[substr] = 0; else count[substr] ++; } } return count; } public: immutable(T)[] empty = []; private T[] s; } struct Grammar(T) { public: this(string name) { this.name = name; } private: string name; String!(T)[][T] rules; } unittest { import std.stdio; // String auto s = String!string(["1", "2", "34"]); writeln(s); writeln(s.flattened()); // Compressibles s = String!string(["a", "b", "a", "b", "a", "b", "a"]); writeln(s.substrings()); // Grammar auto g = Grammar!string(); writeln("~ End Smallest Grammar unittests ~"); }
How to get rid of const / immutable poisoning (and I didn't even want to use them...)
I had to employ const / immutable to some things to get passed some compiler errors. Then the poisoning continues. How do I get this code to run? String's will hold a T[] which actually will not be modified by the String methods ("immutable strings of T"). I did not want to use any immutable / const anywhere at first, but by passing in [1,2,3]
Re: How do you call hashOf() on a string?
Changing @safe to @system worked. IDK, but w/e! ;-)
How do you call hashOf() on a string?
module smallest_grammar; import std.conv; import std.algorithm; struct Symbol(T) { public: this(T sym, bool isVar) { this.sym = sym; this.is_var = isVar; } @property T symbol() { return sym; } @property bool isVar() { return is_var; } private: T sym; bool is_var = false; } struct String(T) { public: this(const T[] s) { this.s = s.dup; } alias s this; string toString() const { return to!string(s); } string flattened() const { string t = ""; foreach (c; s) t ~= to!string(c); return t; } size_t toHash() const @safe pure nothrow { return flattened().hashOf(); } bool opEquals(ref const String t) const @safe pure nothrow { if (t.length != this.length) return false; for(size_t k=0; k < t.length; k++) if (t.s[k] != this.s[k]) return false; return true; } private T[] s; } - My hash function: size_t toHash() const @safe pure nothrow { return flattened().hashOf(); } - Is yielding: smallest_grammar.d(35): Error: @safe function 'smallest_grammar.String!string.String.toHash' cannot call @system function 'object.hashOf!string.hashOf'
Re: Getting DUB to work with VS 2017
On Monday, 22 May 2017 at 06:44:27 UTC, Rainer Schuetze wrote: On 22.05.2017 03:54, Enjoys Math wrote: [...] C:\Users\Gabe\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\\infrastructure\windows\python27_digitalmars.lib+ user32.lib+ kernel32.lib/NOMAP/CO/NOI/DELEXE LINK : fatal error LNK1181: cannot open input file 'obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\source\led_ux_grammar.obj+' Building C:\Users\Gabe\Dropbox\MyProjects\___SOUND_UNITED\LED_UX_Designer\lang\PEGparser\PEGparser.exe failed! Details saved as "file://C:\Users\Gabe\Dropbox\MyProjects\___SOUND_UNITED\LED_UX_Designer\lang\PEGparser\.dub\obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\pegparser.buildlog.html" == Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped == This looks like the wrong link.exe has been found in path. When building for Win32/x86 the default is to use optlink that is installed with dmd. The error message is issued by MS link instead. I suspect the DMD installation folder is not set correctly (check Tools->Options->Projects and Solutions->Visual D Settings->DMD directories). Please also check the executable search paths below, they should include "$(DMDInstallDir)windows\bin". There was a bug in Visual D 0.44.0 where a bad character sneaked into the path to DMD's bin folder. > Opening any of the dub.json files with red X's opens them, but then immediately crashes VS. The red cross means it's not part of the build, so that's correct. The crash is not ok. I can reproduce it, seems to happen due to a function not being implemented (which seems fine for other files). Thank you. That fixed it. Simply removing the dub.json files from the project is a temporary solution to the crashes. However, the entire directory under pegged.examples is red X's. So to temp fix that, remove whole directory, add new filter (folder) 'examples', and add the example you need by copy / pasting text from another install of Pegged (so you can find it on disk), from the example grammar you need. E.g. I added new item `c.d` under new folder `examples`, then copy / pasted the contents of `c.d` from a 2nd install of pegged. The red X goes away, and I am able to use the grammar. Alternatively, simply add the new file `c.d` to your project/source folder.
Re: Getting DUB to work with VS 2017
On Monday, 22 May 2017 at 01:49:48 UTC, Enjoys Math wrote: I did `dub generate visuald project_name`. VS 2017 loads the .sln file except for red 'x's on the dub.json files. My dub.json file looks like (if it matters): { "name": "pegparser", "targetName": "PEGparser", "authors": [ "Fruitful Approach" ], "description": "A parser for LED UX Designer using pegged.", "copyright": "Copyright 2017, fruitfulappro...@gmail.co", "license": "proprietary", "dependencies": { "pegged": "~>0.4.2", "pyd": "~>0.9.9", } } Building gives errors although doing `dub build` at the command line works. Shouldn't the build command be `dub build` instead of `$(CC) -c` ? How do I make this work. Otherwise, I will just make calls to a D app from python over the command line or something... Build Errors: --- -- Build started: Project: pegparser, Configuration: debug Win32 -- Building C:\Users\Gabe\Dropbox\MyProjects\___SOUND_UNITED\LED_UX_Designer\lang\PEGparser\PEGparser.exe... Microsoft (R) Incremental Linker Version 14.10.25019.0 Copyright (C) Microsoft Corporation. All rights reserved. obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\source\led_ux_grammar.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\source\main.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\abstract_.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\ast.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\boolobject.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\bufferobject.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\bytearrayobject.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\bytesobject.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\cellobject.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\ceval.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\classobject.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\cobject.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\code.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\codecs.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\compile.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\complexobject.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\cStringIO.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\datetime.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\descrobject.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\dictobject.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\enumobject.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\errcode.obj+ obj\debug\dummy\dummy\dummy\dummy\dummy\dummy\dummy\pegparser\..\..\..\..\..\..\..\AppData\Roaming\dub\packages\pyd-0.9.9\pyd\infrastructure\deimos\python\eval.obj+
Getting DUB to work with VS 2017
I did `dub generate visuald project_name`. VS 2017 loads the .sln file except for red 'x's on the dub.json files. My dub.json file looks like (if it matters): { "name": "pegparser", "targetName": "PEGparser", "authors": [ "Fruitful Approach" ], "description": "A parser for LED UX Designer using pegged.", "copyright": "Copyright 2017, fruitfulappro...@gmail.co", "license": "proprietary", "dependencies": { "pegged": "~>0.4.2", "pyd": "~>0.9.9", } } Building gives errors although doing `dub build` at the command line works. Shouldn't the build command be `dub build` instead of `$(CC) -c` ? How do I make this work. Otherwise, I will just make calls to a D app from python over the command line or something...
Re: How can I implement this in D: a variant array of varying function pointer types (diff number of args or types)
On Tuesday, 17 January 2017 at 10:49:14 UTC, Enjoys Math wrote: Z add(Z...)(Z a...) { return a + b; } func[] operatorPool = [!int]; Variant library isn't liking that. Removing & causes another error. Essentially I want a pool of all operators that I define, but these operators can be of differing types (which I should be able to programatically grab), and different N-aryness. func? I mean std.variant.Variant there.
How can I implement this in D: a variant array of varying function pointer types (diff number of args or types)
Z add(Z...)(Z a...) { return a + b; } func[] operatorPool = [!int]; Variant library isn't liking that. Removing & causes another error. Essentially I want a pool of all operators that I define, but these operators can be of differing types (which I should be able to programatically grab), and different N-aryness.
Does D optimize sqrt(2.0)?
If I just type out sqrt(2.0) in D, is that automatically made into a constant for me? Thanks.
How do you reference variables in an AA of Variants?
This: double b = 1.0; Variant[string] aa = ["b": ]; writeln(aa["b"]); fails with: Error: cannot implicitly convert expression(["b":]) of type double*[string] to VariantN!20u[string] Helps please!
What is a short, fast way of testing whether x in [a, b]?
Right now I'm using a logical ||: if (!(2*PI - EPS!float <= t1-t0 || t1-t0 <= 2*PI + EPS!float)) { But I'll be doing this a lot, so was wondering if there's a D native way of doing it. Thanks.
Re: What is a short, fast way of testing whether x in [a, b]?
On Monday, 8 February 2016 at 02:47:24 UTC, Enjoys Math wrote: Right now I'm using a logical ||: if (!(2*PI - EPS!float <= t1-t0 || t1-t0 <= 2*PI + EPS!float)) { But I'll be doing this a lot, so was wondering if there's a D native way of doing it. Thanks. Currently I have: @property T EPS(T)() { static if (is(T == double)) { return 0.000_000_001; } static if (is(T == float)) { return 0.000_001; } static if (is(T == int)) { return 1; } } alias EPS!float EPSF; alias EPS!double EPSD; bool epsEq(T)(T x, T y) { return x >= y - EPS!T && x <= y + EPS!T; }
How do you pass in a static array by reference?
I have several class members: Arc[4] arcs; Arc[4] arcs_2; and Id like to initialize them with the same function, so how do I "pass them in" by reference?
Re: How do you take the address of a struct in D?
On Friday, 5 February 2016 at 23:53:15 UTC, Enjoys Math wrote: SDL_RenderCopy(...) takes two pointers to SDL_Rect's, I have a property method in another class returning the SDL_Rect equivalent of a Box (my structure). Taking ampersand on the left of a call to the property does not give the address (&). Got it. I was taking the address of a return-by-copy property.
How do you take the address of a struct in D?
SDL_RenderCopy(...) takes two pointers to SDL_Rect's, I have a property method in another class returning the SDL_Rect equivalent of a Box (my structure). Taking ampersand on the left of a call to the property does not give the address (&).
"Error: need 'this' for 'bbox' of type 'Bong!(double, 3u)'"
I'm getting that on the last line of this code: auto wh = Vec2([loadSurf.w, loadSurf.h]); wh /= 2; auto x = wh.plus1Dim(pos[Z]); this.bbox = Box3(pos - x, pos + x); Any ideas?
Re: "Error: need 'this' for 'bbox' of type 'Bong!(double, 3u)'"
On Saturday, 6 February 2016 at 04:41:26 UTC, Enjoys Math wrote: I'm getting that on the last line of this code: auto wh = Vec2([loadSurf.w, loadSurf.h]); wh /= 2; auto x = wh.plus1Dim(pos[Z]); this.bbox = Box3(pos - x, pos + x); Any ideas? Found it, this was occuring in a static function.
Re: std.signals crashes GtkD gui application when SpinButton tied to signal.
On Friday, 5 February 2016 at 06:52:11 UTC, Enjoys Math wrote: I have two spin buttons connected to the width and height of 2d objects in a scene. Using mixin std.signals.Signal!(double, double) dimentionChanged; and there is a growing delay that happens not caused by the rendering code, the transform code, or the triggering code (I used a timer to measure). Then switching over to a D delegate, the issue went away. It starts to freeze the gui app so that you can't do much at all. Thus std.signals can't handle a large number of signals maybe 50 / second. It causes some weird delays to happen. Would anyone like to see my source code? You need: Visual D GtkD-3.(latest) (32-bit) Gtk Runtime Wait it's happening again. It's sporadic I guess.
std.signals crashes GtkD gui application when SpinButton tied to signal.
I have two spin buttons connected to the width and height of 2d objects in a scene. Using mixin std.signals.Signal!(double, double) dimentionChanged; and there is a growing delay that happens not caused by the rendering code, the transform code, or the triggering code (I used a timer to measure). Then switching over to a D delegate, the issue went away. It starts to freeze the gui app so that you can't do much at all. Thus std.signals can't handle a large number of signals maybe 50 / second. It causes some weird delays to happen. Would anyone like to see my source code? You need: Visual D GtkD-3.(latest) (32-bit) Gtk Runtime
Re: How do you get a hexstring from a base10 string -or- from a number?
On Wednesday, 3 February 2016 at 23:43:45 UTC, Enjoys Math wrote: I am making a method called: @property string debugIDString() { in { assert(super.toHash() == this.toHash()); } body { } body { // is currently: return to!string(this.toHash()); } and is returning a base10 string, so how would I return a hex string so I can compare numbers displayed to the debugger addresses in visual D?
How do you get a hexstring from a base10 string -or- from a number?
I am making a method called: @property string debugIDString() { in { assert(super.toHash() == this.toHash()); } body { }
Re: How do you get a hexstring from a base10 string -or- from a number?
On Wednesday, 3 February 2016 at 23:45:15 UTC, Enjoys Math wrote: On Wednesday, 3 February 2016 at 23:43:45 UTC, Enjoys Math wrote: I am making a method called: @property string debugIDString() { in { assert(super.toHash() == this.toHash()); } body { } body { // is currently: return to!string(this.toHash()); } and is returning a base10 string, so how would I return a hex string so I can compare numbers displayed to the debugger addresses in visual D? One solution: create "string_tools.d": module string_tools; import std.conv: to; string hexString(int x) { string hex = "0x"; for(uint k=0; k < 8; k++) { int hexDig = (x >> (k << 2)) & 0x000F; if (hexDig < 10) { hex ~= to!string(hexDig); } else { string hexDixStr; switch (hexDig) { case 10:hexDigStr = "A"; break; case 11:hexDigStr = "B"; break; case 12:hexDigStr = "C"; break; case 13:hexDigStr = "D"; break; case 14:hexDigStr = "E"; break; case 15:hexDigStr = "F"; break; } hex ~= hexDigStr; } } return hex; }
How do you check if object o has base type B?
Consider: class C { } class B : C { } class A : B { } class D : C { } C[] objList; how do we test if objLis[k] is of base type "B"? Ie for [new A(), new B(), new D(), new C()] would give output [true, true, false, false]. ? Thank you! :D
How would you implement this in D? (signals & slots)
module signals_and_slots; import std.algorithm: remove; struct Slots(DelegateType, ArgTypes...) { this() { } // How would you implement this? void call(ArgTypes args) { foreach (dg; delegates) dg(args); } void connect(DelegateType slot) { foreach (dg; delegates) { if (dg == slot) return; } delegates ~= slot; } void disconnect(DelegateType slot) { for (uint k=0; k < delegates.length; k++) { if (delegates[k] == slot) delegates = delegates.remove(k); } } private: DelegateType[] delegates; } = How do you implement this template called like: void onColorChange(in Color) { // do something with color } auto slots = Slots!(void delegate(in Color), Color); slots.connect(); auto color = Color(0.0, 1.0, 1.0, 1.0); slots.call(color); ? Thank you!
Re: How would you implement this in D? (signals & slots)
On Monday, 1 February 2016 at 21:40:45 UTC, Enjoys Math wrote: module signals_and_slots; import std.algorithm: remove; [...] D's signals & slots: https://dlang.org/phobos/std_signals.html
How do you get system time in specified precision?
That is in metric system units? Ie milli-, micro-, hectanano-, nano-seconds? The documentation doesn't show this well and many things are deprecated. Please show me how! Thank you.
How do you do a typeid(obj) to get the most derived class that it is, or string?
class A { } class B : A { } class C : B { } auto b = new B(); typeid(b) == "B" ? Thanks.
Re: Unterminated format specifier exception keeps occuring and I don't know why.
On Sunday, 31 January 2016 at 19:51:34 UTC, Enjoys Math wrote: On Sunday, 31 January 2016 at 19:40:15 UTC, Enjoys Math wrote: This weird exception keeps occuring and visual D is not bringing me to the place in my code that might be calling it. [...] The exception is not listed in the Exception Settings checkable list. I will try commenting out the D source code that throws it. The easiest solution is just to ignore the exception and continue. The exception doesn't occur in release mode.
Unterminated format specifier exception keeps occuring and I don't know why.
This weird exception keeps occuring and visual D is not bringing me to the place in my code that might be calling it. Message: First-chance exception: std.format.FormatException Unterminated format specifier: "%" at C:\D\dmd2\windows\bin\..\..\src\phobos\std\format.d(830) I've gotten rid of it before, but I'm not sure how. Here's the call stack: KernelBase.dll!76e1d8a8 ___LIGHTSHOWAPP.exe!_D2rt9deh_win329throwImplFC6ObjectZv() + 0x2a bytes D ___LIGHTSHOWAPP.exe!std.exception.enforceEx!(std.format.FormatException).enforceEx!bool.enforceEx( uint line ) Line 618 D ___LIGHTSHOWAPP.exe!std.format.FormatSpec!char.FormatSpec.writeUpToNextSpec!(std.array.Appender!(char[])).writeUpToNextSpec( std.format.FormatSpec!char.FormatSpec* this ) Line 831 D ___LIGHTSHOWAPP.exe!std.format.FormatSpec!char.FormatSpec.__unittestL848_2148.__dgliteral1( void* this ) Line 878 + 0x20 bytes D ___LIGHTSHOWAPP.exe!std.exception.assertThrown!(std.format.FormatException, bool).assertThrown( uint line ) Line 231 + 0xb bytes D ___LIGHTSHOWAPP.exe!std.format.FormatSpec!char.FormatSpec.__unittestL848_2148() Line 879 D ___LIGHTSHOWAPP.exe!_D15bounded_2d_geom9__modtestFZv() + 0x8 bytes D ___LIGHTSHOWAPP.exe!_D4core7runtime18runModuleUnitTestsUZ14__foreachbody1MFPS6object10ModuleInfoZi() + 0x45 bytes D ___LIGHTSHOWAPP.exe!_D6object10ModuleInfo7opApplyFMDFPS6object10ModuleInfoZiZ9__lambda2MFyPS6object10ModuleInfoZi() + 0xf bytes D
Re: Unterminated format specifier exception keeps occuring and I don't know why.
On Sunday, 31 January 2016 at 19:40:15 UTC, Enjoys Math wrote: This weird exception keeps occuring and visual D is not bringing me to the place in my code that might be calling it. [...] The exception is not listed in the Exception Settings checkable list. I will try commenting out the D source code that throws it.
How do you initialize a class instance which has static storage within another class?
class A { static B b; } class B {} doing b = new B() does NOT work. Nor could I create a this() {} at module level
Re: How do you initialize a class instance which has static storage within another class?
On Saturday, 30 January 2016 at 21:52:20 UTC, Enjoys Math wrote: class A { static B b; } class B {} doing b = new B() does NOT work. Nor could I create a this() {} at module level More info: B : A so I can't do class A { this () { if (b is null) { b = new B(); } } } Since it OVERFLOWS THE STACK!!
To cast a uint to float to compute k/n, use to! or cast()?
I want to compute the points of a regular polygon in a loop: float r = 1.0; for (uint k=0; k < numVerts; k++) { vertlist ~= Vec2D(r * cos(k/n * 2 * PI), ...) } How do I make sure k/n is a float or double?
Computing the min() / max() of a slice of doubles.
I want to use std.algorithm.min/max, how would I apply that to a slice of doubles and not a tuple of args? Thanks.