Re: Debugging a dub build

2019-01-21 Thread JN via Digitalmars-d-learn
On Monday, 21 January 2019 at 11:16:31 UTC, Per Nordlöw wrote: Correction should be dub build --build=unittest or dub build --build=debug followed by gdb PATH_TO_APP_BINARY Does using an IDE count? Some D IDEs should be able to assist in debugging.

Re: Is there a nice syntax to achieve optional named parameters?

2019-01-16 Thread JN via Digitalmars-d-learn
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote: auto window = Window(); window.title = "My Window"; window.width = 1000; window.create(); You can slightly modify it to the way APIs like DirectX or Vulkan do it. auto windowinfo = WindowInfo(); windowinfo.title = "My Window";

Re: Reversing a string

2019-01-11 Thread JN via Digitalmars-d-learn
On Friday, 11 January 2019 at 11:15:05 UTC, Mike James wrote: Check out the origin :-) https://forum.dlang.org/thread/hl8345$2b1q$1...@digitalmars.com?page=1 I guess something like iterReverse, reverseIter, backIterator would be too simple...

Re: Reversing a string

2019-01-11 Thread JN via Digitalmars-d-learn
On Friday, 11 January 2019 at 08:15:01 UTC, rikki cattermole wrote: Note the immutable, it means you cannot modify individual values. Which is a problem for reverse because it modifies in place. The error message is kind of unfortunate. This is a simple usecase and the error message is unde

Re: Tricky DMD bug, but I have no idea how to report

2018-12-18 Thread JN via Digitalmars-d-learn
On Monday, 17 December 2018 at 22:22:05 UTC, H. S. Teoh wrote: A less likely possibility might be an optimizer bug -- do you get different results if you add / remove '-O' (and/or '-inline') from your dmd command-line? If some combination of -O and -inline (or their removal thereof) "fixes" th

Tricky DMD bug, but I have no idea how to report

2018-12-17 Thread JN via Digitalmars-d-learn
Hey guys, while working on my game engine project, I encountered a DMD codegen bug. It occurs only when compiling in release mode, debug works. Unfortunately I am unable to minimize the code, since it's quite a bit of code, and changing the code changes the bug occurrence. Basically my faulty

Re: Native PDB Error

2018-12-15 Thread JN via Digitalmars-d-learn
On Saturday, 15 December 2018 at 20:54:03 UTC, JN wrote: Bump. Encountering the same issue. Just reinstalled Windows and having the same error on DMD32 D Compiler v2.083.1 . OK, fixed it. Since it's the first hit from Google, here's a solution: https://www.reddit.com/r/roguelikedev/commen

Re: Native PDB Error

2018-12-15 Thread JN via Digitalmars-d-learn
On Wednesday, 7 November 2018 at 14:43:07 UTC, Chris M. wrote: On Wednesday, 7 November 2018 at 01:37:29 UTC, Chris M. wrote: On Tuesday, 29 May 2018 at 07:47:07 UTC, Begah wrote: [...] This works fine on my home Win10 machine, dmd 2.082/2.083 + dub 1.11.0, installed using the executable fro

Re: Compiling a template

2018-12-06 Thread albertas-jn via Digitalmars-d-learn
On Friday, 7 December 2018 at 01:21:42 UTC, Ali Çehreli wrote: There is no trace of the template in the library or the object file. You can investigate the compiled symbols with e.g. the 'nm' tool on Linux systems: // deneme.d: void foo(T)(T t) { import std.stdio; writeln(t); } void

Compiling a template

2018-12-06 Thread albertas-jn via Digitalmars-d-learn
If templates are a compile-time feature and instances of templates are generated by compiler at compile time, why is it possible to compile a template definition with dmd -lib or -c?

Re: Messing with OpenGL in D

2018-12-05 Thread JN via Digitalmars-d-learn
On Wednesday, 5 December 2018 at 19:12:34 UTC, Nadir Chowdhury wrote: I'm fairly new to Dlang, but have learnt the basics. I wondered how I would be able to make an OpenGL-based Engine in D, what libraries would I need? Your help will be much appreciated! - NCPlayz I use Derelict's GLFW bind

Re: Reading into the output of a long running shellExecute

2018-11-10 Thread JN via Digitalmars-d-learn
On Saturday, 10 November 2018 at 15:05:38 UTC, helxi wrote: Hi. I have not done any multi-threaded programming before. What I basically want is to read into the output of a long shellExecute function each second. In details, I am calling shellExecute("pkexec dd if=/path/to/file of=/dev/sdx st

Template return type?

2018-10-03 Thread JN via Digitalmars-d-learn
I was looking over some Rust examples, and found something interesting: https://github.com/serde-rs/serde let deserialized: Point = serde_json::from_str(&serialized).unwrap(); from_str is defined as: pub fn from_str<'a, T>(s: &'a str) -> Result From what I understand, the function infers t

Re: C++ GLM(OpenGL Mathematics) D Equivalent.

2018-09-04 Thread JN via Digitalmars-d-learn
On Tuesday, 4 September 2018 at 19:23:16 UTC, SrMordred wrote: Most C++ game related projects uses GLM as they default math/vector lib (even if not using opengl). In D we have (that I found): gfm.math - https://github.com/d-gamedev-team/gfm dlib.math - https://github.com/gecko0307/dlib Gl3n

Re: "The D Way" to run a sequence of executables?

2018-08-25 Thread JN via Digitalmars-d-learn
On Friday, 24 August 2018 at 17:36:25 UTC, Matthew OConnor wrote: I'd like to run a sequence of executables with something like std.process.execute, but I would like the sequence to error out if one of the executables returns a non-zero return code. What is the recommended way to do this? A wra

Re: "The D Way" to run a sequence of executables?

2018-08-25 Thread JN via Digitalmars-d-learn
On Saturday, 25 August 2018 at 22:00:47 UTC, JN wrote: It's kind of a dirty and not very portable solution, but if you run by executeShell, you could so something like executeShell("cmd1 && cmd2 && cmd3") and let the shell do the sequence for you. Oops, didn't notice it was suggested already.

Re: Null-Coalescing Operator and Extensions

2018-08-25 Thread JN via Digitalmars-d-learn
On Saturday, 25 August 2018 at 13:33:58 UTC, SG wrote: Hi, 1) I program in C# and I'm wondering if there is something like ?? (Null-Coalescing Operator) in D? (I remember some proposals in the past). 2) Is possible to create Extensions like in C#? For example: public int StrToInt (this st

Re: Auto keyword and when to use it

2018-08-20 Thread JN via Digitalmars-d-learn
On Monday, 20 August 2018 at 17:52:17 UTC, QueenSvetlana wrote: Great! So I can't declare class level variables with auto, correct? only local method variables? You can, globals, class members: class Foo { auto bar = "hi"; } Foo.bar will be of string type here, because "hi" is a string.

Re: Auto keyword and when to use it

2018-08-20 Thread JN via Digitalmars-d-learn
On Monday, 20 August 2018 at 17:24:19 UTC, QueenSvetlana wrote: I'm new to D programming, but have I have a background with Python. I'm struggling to understand what the auto keyword is for and it's appropriate uses. From research, it seems to share the same capabilities as the var keyword in

Re: Assignment in ternary condition operator

2018-08-07 Thread JN via Digitalmars-d-learn
On Tuesday, 7 August 2018 at 19:58:40 UTC, Steven Schveighoffer wrote: On 8/7/18 3:18 PM, JN wrote: [...] But operator precedence says that this is really: b = (a = (3 ? 4 : 5)) It's a different thing than the if statement. In the if statement, it's the *assignment* that is now the conditio

Assignment in ternary condition operator

2018-08-07 Thread JN via Digitalmars-d-learn
int a, b; if (a = 3) { } <- not allowed: Error: assignment cannot be used as a condition, perhaps == was meant? b = a = 3 ? 4 : 5 <- allowed I believe the second case should be disallowed also. It seems illogical, that the first one isn't allowed, but the second one is, when the second

Re: Orange not working?

2018-07-13 Thread JN via Digitalmars-d-learn
On Friday, 13 July 2018 at 19:03:32 UTC, Jacob Carlborg wrote: On 2018-07-13 20:52, Jacob Carlborg wrote: Orange master is working properly. The tests are run on each push and PR with the latest DMD compiler. I just added a cron job in Travis CI as well to make sure it every month even thoug

Re: Orange not working?

2018-07-12 Thread JN via Digitalmars-d-learn
On Friday, 13 July 2018 at 05:29:58 UTC, Timoses wrote: On Thursday, 12 July 2018 at 20:44:43 UTC, JN wrote: I am trying to make use of the Orange package, I added the latest version from dub to my project: "orange": "~>1.0.0" and copy pasted the "simple usage" code from https://github.com/jac

Orange not working?

2018-07-12 Thread JN via Digitalmars-d-learn
I am trying to make use of the Orange package, I added the latest version from dub to my project: "orange": "~>1.0.0" and copy pasted the "simple usage" code from https://github.com/jacob-carlborg/orange , but I am getting a long list of errors: ..\..\AppData\Local\dub\packages\orange-1.0.0\o

Cleanup class after method?

2018-07-04 Thread JN via Digitalmars-d-learn
Imagine I have a very short-lived class: void print(File f) { PrinterManager pm = new PrinterManager(); pm.print(f); } My understanding is that PrinterManager will be GC allocated, and when it goes out of scope, the GC will possibly clean it up at some point in the future. But I know t

Re: Making an .exe that executes source file inside itself.

2018-04-26 Thread JN via Digitalmars-d-learn
On Wednesday, 25 April 2018 at 19:19:58 UTC, BoQsc wrote: So there has been idea I've got for around few months now: making a software which executable would contain a source file. A software that anyone could modify by opening an executable and quickly change a few lines of it, rerun an executa

Re: how to make private class member private

2018-03-13 Thread JN via Digitalmars-d-learn
On Tuesday, 13 March 2018 at 02:06:57 UTC, psychoticRabbit wrote: On Tuesday, 13 March 2018 at 01:39:13 UTC, Jonathan M Davis wrote: private is private to the module, not the class. There is no way in D to restrict the rest of the module from accessing the members of a class. This simplificat

Re: Get function argument name?

2018-03-04 Thread JN via Digitalmars-d-learn
On Sunday, 4 March 2018 at 21:12:44 UTC, arturg wrote: you can pass it by alias: import std.stdio; void main(string[] args) { int x; printName!(x); } void printName(alias var)() { writeln(__traits(identifier, var), " ", var); } Well, it works. But I am confused now, why. Isn't a

Get function argument name?

2018-03-04 Thread JN via Digitalmars-d-learn
Imagine a function like this: void printValue(T)(string name, T value) { writeln(name, " = ", value); } int x = 10; printValue("x", x); is it somehow possible to convert that printValue into a mixin or something, so I could do something like: printValue(x); and it will figure out the "x"

Traits redux

2018-03-03 Thread JN via Digitalmars-d-learn
https://run.dlang.io/gist/ec7008372d60ac52460dd58068f1ca6d?compiler=dmd Why only listUDA2 works and listUDA doesn't? Why do I need to use __traits(getMember again, if I use what I saved in a variable, it doesn't work :(

Re: Game and GC

2018-02-23 Thread JN via Digitalmars-d-learn
On Friday, 23 February 2018 at 01:54:07 UTC, Leonardo wrote: Hi, I'm new to language and games. Many people say that GC is bad and can slow down your project in some moments. What can happen if I create a game using D without worrying with memory management? (using full GC) Most people who s

Re: Function overloading between modules

2018-02-22 Thread JN via Digitalmars-d-learn
On Thursday, 22 February 2018 at 21:19:12 UTC, ketmar wrote: yes. this is done so unqualified won't silently "steal" your functions. this can cause some unexpected (and hard to find) bugs. if you want it to work, you can either do qualified import import bar : foo; or manuall bring

Function overloading between modules

2018-02-22 Thread JN via Digitalmars-d-learn
Is this expected behaviour? bar.d --- void foo(string s) { } app.d --- import std.stdio; import bar; void foo(int x) { } void main() { foo("hi"); }; === Error: function app.foo (int x) is not callable using argument types (string)

Re: confused with data types

2018-02-17 Thread JN via Digitalmars-d-learn
On Saturday, 17 February 2018 at 16:12:48 UTC, thorstein wrote: Hello, This was my goal: - public double[][] skalar_m_2d(double[][] array, double skalar) { return array.map!(b => b[].map!(c => c * skalar)); } !!! But: return value is not double! Type check for return value: -

Re: Debugging on Windows

2018-02-11 Thread JN via Digitalmars-d-learn
On Friday, 9 February 2018 at 19:02:14 UTC, Benjamin Thaut wrote: On Thursday, 8 February 2018 at 21:09:33 UTC, JN wrote: Hi, is there any way to debug binaries on Windows? I'd at least like to know which line of code made it crash. If it's D code, I get a call trace usually, but if it's a ca

Debugging on Windows

2018-02-08 Thread JN via Digitalmars-d-learn
Hi, is there any way to debug binaries on Windows? I'd at least like to know which line of code made it crash. If it's D code, I get a call trace usually, but if it's a call to a C library, I get a crash and that's it. I am using VSCode and I'd prefer to debug in it if possible, but using oth

Re: Using std traits

2018-01-25 Thread JN via Digitalmars-d-learn
On Thursday, 25 January 2018 at 19:49:05 UTC, JN wrote: if (!hasUDA!(member, "noserialize")) Nevermind, I get it now, member is only the field name, not a 'reference', changed it to: if (!hasUDA!(mixin(T.stringof ~ "." ~ member), "noserialize")) and works now

Using std traits

2018-01-25 Thread JN via Digitalmars-d-learn
I decided it's time to learn how std traits work. I still find the whole compile time business a bit weird to deal with, so I decided to write a simple JSON serializer for struct that loops over member fields and outputs them. import std.stdio; import std.json; import std.traits; struct TestS

Re: Silly struct behaviour

2017-07-13 Thread JN via Digitalmars-d-learn
On Thursday, 13 July 2017 at 18:09:46 UTC, H. S. Teoh wrote: It's not quite so simple. Consider for example: struct Foo { int bar; } struct Oof { int bar; } void process(Foo foo) { } void process(Oof oof) { formatDisk(); } void main() {

Re: Silly struct behaviour

2017-07-13 Thread JN via Digitalmars-d-learn
I know that's a wrong syntax, I was just showing an example. Yes, here it will work, but if you want to initialize only some fields (poor man's keyword arguments), you can't use the default constructor.

Silly struct behaviour

2017-07-13 Thread JN via Digitalmars-d-learn
Consider: struct Foo { int bar; } void processFoo(Foo foo) { } void main() { Foo f = {bar: 5}; processFoo(f);// ok processFoo(Foo(5)); // ok processFoo({bar: 5}); // fail processFoo(Foo({bar: 5}));// fail }

Any way to reproduce Dart style constructors?

2017-05-25 Thread JN via Digitalmars-d-learn
One of my favourite language features of Dart (other one being factory constructors) are auto-assign constructors, for example (writing it in pseudo-D): class Person { string name; int age; this(this.age, this.name); } would translate to class Person { string name; int age; this(i

Thread will get garbage collected?

2017-01-16 Thread JN via Digitalmars-d-learn
I'm looking at the example code for core.thread Thread class: new Thread({ // Codes to run in the newly created thread. }).start(); let's imagine I put the code in a function: void loadFileAsync(string path) { new Thread({ writeln(readText(path));// imagine the file is

Re: Easy sockets - don't exist yet?

2016-09-27 Thread JN via Digitalmars-d-learn
On Tuesday, 27 September 2016 at 11:16:00 UTC, Russel Winder wrote: On Tue, 2016-09-27 at 10:16 +, JN via Digitalmars-d-learn wrote: On Tuesday, 27 September 2016 at 09:23:35 UTC, Russel Winder wrote: > > Why not just create a binding to 0MQ and get much, much more > than

Re: Easy sockets - don't exist yet?

2016-09-27 Thread JN via Digitalmars-d-learn
On Tuesday, 27 September 2016 at 09:23:35 UTC, Russel Winder wrote: Why not just create a binding to 0MQ and get much, much more than asked for? http://code.dlang.org/packages/zmqd http://code.dlang.org/packages/zeromq http://code.dlang.org/packages/dzmq or use existing ones :)

Re: Derelict, SDL, and OpenGL3: Triangle Tribulations

2015-08-12 Thread JN via Digitalmars-d-learn
On Wednesday, 12 August 2015 at 05:58:23 UTC, BBasile wrote: On Wednesday, 12 August 2015 at 05:46:27 UTC, Mike Parker wrote: On Wednesday, 12 August 2015 at 05:34:22 UTC, BBasile wrote: [...] It seems to me that your driver is doing things it isn't actually supposed to do. This code is bin

Re: Derelict, SDL, and OpenGL3: Triangle Tribulations

2015-08-11 Thread JN via Digitalmars-d-learn
On Wednesday, 12 August 2015 at 03:32:47 UTC, DarthCthulhu wrote: So I decided to try some OGL3 stuff in D utilizing the Derelict bindings and SDL. Creating an SDL-OGL window worked fine, but I'm having trouble with doing the most basic thing of rendering a triangle. I get the window just fine

Re: Is D's GC.calloc and C's memset played the same role?

2014-12-24 Thread JN via Digitalmars-d-learn
I know this is probably a theoretical exercise, but easier way might be to execute "tasklist" and just grep the output.

<    1   2