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.

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

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

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 > t

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 :)

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 }

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.

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;

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

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

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

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

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

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: 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

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: 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

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

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

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

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

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

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

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

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

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

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:

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

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

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

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: 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

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"

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

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().unwrap(); from_str is defined as: pub fn from_str<'a, T>(s: &'a str) -> Result From what I understand, the function infers the

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

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.

How to disable/hide constructor when using factory method?

2019-01-23 Thread JN via Digitalmars-d-learn
class Foo { static Foo makeFoo() { Foo f = new Foo(); return f; } } void main() { Foo f = Foo.makeFoo(); } For a code like this. I'd like all users of the class to be forced to create instances using the static method makeFoo. I want to disallow "new Foo()".

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

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

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:

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"

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

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

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: Where is GDC being developed?

2019-03-21 Thread JN via Digitalmars-d-learn
On Thursday, 21 March 2019 at 08:19:56 UTC, Per Nordlöw wrote: At https://github.com/D-Programming-GDC/GDC/commits/master there's the heading "This repository has been archived by the owner. It is now read-only." Where will the development of GDC continue? I am not exactly sure, but if

Re: What Does @ Mean?

2019-04-08 Thread JN via Digitalmars-d-learn
On Monday, 8 April 2019 at 14:19:04 UTC, XavierAP wrote: The only other example of language using @, in an almost but not quite completely different way, is C#. It's also a prefix that allows you to define names that would collide with reserved words, for example string @class = "menu"; Of

Re: How to call other variadic function with the same arguments?

2019-02-24 Thread JN via Digitalmars-d-learn
On Sunday, 24 February 2019 at 13:09:15 UTC, Victor Porton wrote: Let f be a variadic function: Result f(...); How to implement variadic function g which calls f with the same arguments as one it receives? Result g(...) { // ... } void f(A...)(A a) { foreach(t; a)

Re: Using arsd.simpledisplay module

2019-02-25 Thread JN via Digitalmars-d-learn
On Monday, 25 February 2019 at 23:35:24 UTC, Murilo wrote: I need help with the arsd.simpledisplay module. Is there anyone there who knows about it? I have doubts concerning SimpleWindow.eventLoop(). I'm pretty sure Adam D. Ruppe knows about it since he's the author :) What exactly is the

Re: How to setup dub to use x86 and x64 dll's when appropriate?

2019-02-25 Thread JN via Digitalmars-d-learn
On Tuesday, 26 February 2019 at 04:20:27 UTC, Michelle Long wrote: On Tuesday, 26 February 2019 at 04:17:04 UTC, Michelle Long wrote: e.g., using sdl for different versions and have it automatically switch. What would be nice is if one could stick all the files for x86 in one dir and x64 in

Struct destructor

2019-03-02 Thread JN via Digitalmars-d-learn
Compare this D code: import std.stdio; struct Foo { ~this() { writeln("Destroying foo"); } } void main() { Foo[string] foos; foos["bar"] = Foo(); writeln("Preparing to destroy"); foos.remove("bar"); writeln("Ending program"); } and equivalent C++ code:

Re: Setting the GtkD Include Path in dexed?

2019-03-12 Thread JN via Digitalmars-d-learn
On Tuesday, 12 March 2019 at 17:39:06 UTC, Ron Tarrant wrote: Another way of asking this, I suppose, would be: How do I pass command line arguments to dmd from within dexed? How about Project -> Project editor -> Categories -> Other -> dmdOtherOptions ?

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

2019-02-07 Thread JN via Digitalmars-d-learn
On Thursday, 7 February 2019 at 03:50:32 UTC, Vladimir Panteleev wrote: On Monday, 17 December 2018 at 21:59:59 UTC, JN wrote: while working on my game engine project, I encountered a DMD codegen bug. It occurs only when compiling in release mode, debug works. Old thread, but FWIW, such bugs

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

2019-02-08 Thread JN via Digitalmars-d-learn
On Friday, 8 February 2019 at 07:30:41 UTC, Vladimir Panteleev wrote: On Thursday, 7 February 2019 at 22:16:19 UTC, JN wrote: Does it also work for dub projects? It will work if you can put all the relevant D code in one directory, which is harder for Dub, as it likes to pull dependencies

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

2019-02-06 Thread JN via Digitalmars-d-learn
On Tuesday, 18 December 2018 at 22:56:19 UTC, H. S. Teoh wrote: Since no explicit slicing was done, there was no compiler error / warning of any sort, and it wasn't obvious from the code what had happened. By the time doSomething() was called, it was already long past the source of the problem

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

2019-02-08 Thread JN via Digitalmars-d-learn
On Friday, 8 February 2019 at 22:11:31 UTC, H. S. Teoh wrote: Pity I still can't reproduce the problem locally. Otherwise I would reduce it even more -- e.g., eliminate std.stdio dependency and have the program fail on assert(obj != null), and a bunch of other things to make it easier for

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

2019-02-08 Thread JN via Digitalmars-d-learn
On Friday, 8 February 2019 at 09:30:12 UTC, Vladimir Panteleev wrote: On Friday, 8 February 2019 at 09:28:48 UTC, JN wrote: I will try. However, one last thing - in the example test scripts, it runs first with one compiler setting (or D version) and the second time with the other compiler

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

2019-02-08 Thread JN via Digitalmars-d-learn
On Friday, 8 February 2019 at 21:35:34 UTC, H. S. Teoh wrote: On Fri, Feb 08, 2019 at 09:23:40PM +, JN via Digitalmars-d-learn wrote: [...] I managed to greatly reduce the source code. I have filed a bug with the reduced testcase https://issues.dlang.org/show_bug.cgi?id=19662 . Haha, you

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

2019-02-08 Thread JN via Digitalmars-d-learn
On Friday, 8 February 2019 at 23:30:44 UTC, H. S. Teoh wrote: On Fri, Feb 08, 2019 at 10:45:39PM +, JN via Digitalmars-d-learn wrote: [...] Anyway, I reduced the code further manually. It's very hard to reduce it any further. For example, removing the assignments in fromEulerAngles static

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

2019-02-06 Thread JN via Digitalmars-d-learn
On Wednesday, 6 February 2019 at 22:22:26 UTC, H. S. Teoh wrote: Of course, I've no clue whether this is the cause of your problems -- it's just one of many possibilities. Pointer bugs are nasty things to debug, regardless of whether or not they've been abstracted away in nicer clothing. I

Re: Why -I flag does not work?

2019-02-09 Thread JN via Digitalmars-d-learn
On Saturday, 9 February 2019 at 08:15:36 UTC, Victor Porton wrote: Why does -I flag in DFLAGS does not work? (Ubuntu Linux) I'm no expert on dub, but it's possible that it's overriding the import path anyway. One of the main points of dub is that you shouldn't have to handle the import paths

Re: Windows Defender won't let me install DMD

2019-02-19 Thread JN via Digitalmars-d-learn
On Monday, 18 February 2019 at 16:32:26 UTC, belkin wrote: Additional question as a beginner. What do I need to install to get started. Obviously I need a compiler (which one is best ). But I also want an IDE and so far it seems Visual D would be a best choice. Ideas? Visual D works well,

Re: How to disable/hide constructor when using factory method?

2019-01-24 Thread JN via Digitalmars-d-learn
On Thursday, 24 January 2019 at 12:52:47 UTC, Arafel wrote: You are declaring the constructor, but not defining it, i.e. you're telling the compiler that it's in some other compilation unit. The compiler won't complain, but the linker will. If you replace: [...] with: [...] it should

Re: How to disable/hide constructor when using factory method?

2019-01-24 Thread JN via Digitalmars-d-learn
On Wednesday, 23 January 2019 at 19:41:44 UTC, Alex wrote: On Wednesday, 23 January 2019 at 19:26:37 UTC, JN wrote: class Foo { static Foo makeFoo() { Foo f = new Foo(); return f; } } void main() { Foo f = Foo.makeFoo(); } For a code like this. I'd like all

Re: crashing with no stack trace, why?

2019-02-01 Thread JN via Digitalmars-d-learn
On Thursday, 31 January 2019 at 11:09:56 UTC, DanielG wrote: However it was simply crashing with an exit code (-1073740771 / ‭0xC41D‬), and I was having a heck of a time trying to debug on Windows. (Shoutout to the revamped WinDbg Preview, couldn't get anything else to work!) For

Re: Using python in D

2019-06-07 Thread JN via Digitalmars-d-learn
On Friday, 7 June 2019 at 05:04:30 UTC, rnd wrote: On Friday, 7 June 2019 at 04:39:14 UTC, rikki cattermole wrote: On 07/06/2019 3:54 PM, rnd wrote: How should I 'initialize python' ? The example is probably a good place to begin.

Re: What is iota function full name

2019-06-21 Thread JN via Digitalmars-d-learn
On Friday, 21 June 2019 at 09:18:49 UTC, Jonathan M Davis wrote: So, iota is the name of the function, and it doesn't stand for anything. It's just the name of the Greek letter that was used for a similar function in another language that most programmers these days have probably never heard

Re: Unexpected behaviour in associative array

2019-04-19 Thread JN via Digitalmars-d-learn
On Friday, 19 April 2019 at 12:37:10 UTC, Arredondo wrote: Here's a reasonably-sized code fragment that demonstrates the issue. I hope the comments along the way are descriptive enough Hmm. Have you tried using a different compiler or 32/64 bit? I had a weird "null out of nowhere" bug going

D on ARM laptops?

2019-07-03 Thread JN via Digitalmars-d-learn
Does anyone know if and how well D works on ARM laptops (such as Chromebooks and similar)? For example this one https://www.pine64.org/pinebook/ . Can it compile D? Obviously DMD is out because it doesn't have ARM builds. Not sure about GDC. How about LDC?

Static struct?

2019-04-24 Thread JN via Digitalmars-d-learn
I noticed a construct I haven't seen before in D when reading the description for automem - https://github.com/atilaneves/automem static struct Point { int x; int y; } What does "static" do in this case? How does it different to a normal struct?

Re: Can I remove an element from a global associative array from within a class destructor?

2019-08-03 Thread JN via Digitalmars-d-learn
On Friday, 2 August 2019 at 23:13:10 UTC, realhet wrote: Today I read the documentation about structs, unions and classes, but I haven't find any restrictions for the ~this() destructors. Is there some extra rules regarding the GC and what I must not do in the destructors? Class

Re: Sort Associative Array by Key

2019-08-25 Thread JN via Digitalmars-d-learn
On Sunday, 25 August 2019 at 17:01:23 UTC, a11e99z wrote: On Sunday, 25 August 2019 at 16:54:33 UTC, Samir wrote: Is there a way to output the values of an associative array based on the lexicographic order of the keys? For example, if foo = ["VXE":8, "BZP":5, "JLC":2], I'd like to output

Re: Help me decide D or C

2019-08-01 Thread JN via Digitalmars-d-learn
On Thursday, 1 August 2019 at 09:43:20 UTC, Kagamin wrote: On Wednesday, 31 July 2019 at 22:30:52 UTC, Alexandre wrote: 1) Improve as a programmer 2) Have fun doing programs Thats it basically. I am planning to study all "free" time I have. I am doing basically this since last year. Try

Interfaces and templates

2019-09-20 Thread JN via Digitalmars-d-learn
import std.stdio; interface IWriter { void write(U)(U x); } class Foo : IWriter { void write(U)(U x, int y) { writeln(x); } } void main() { } Does this code make sense? If so, why doesn't it throw an error about unimplemented write (or incorrectly implemented)

Re: Help playing sounds using arsd.simpleaudio

2019-09-29 Thread JN via Digitalmars-d-learn
On Saturday, 28 September 2019 at 03:21:38 UTC, Murilo wrote: Can anyone just please show me how to play a background sound(like those in games) using arsd.simpleaudio? I'd like something simple with a code snippet please. I recommend SoLoud - bindings are available here

Re: Saving and loading large data sets easily and efficiently

2019-10-01 Thread JN via Digitalmars-d-learn
On Monday, 30 September 2019 at 20:10:21 UTC, Brett wrote: So it much more difficult than POD but would still be a little more work to right... hoping that there is something already out there than can do this. It should be I'm afraid there's nothing like this available. Out of serialization

Re: Dmd install to new Windows 10 system can't run app.d

2019-11-21 Thread JN via Digitalmars-d-learn
On Thursday, 21 November 2019 at 09:26:39 UTC, zoujiaqing wrote: On Thursday, 21 November 2019 at 08:42:39 UTC, Seb wrote: Note this line: Running .\myproject.exe Program exited with code -1073741515 Your compiled program is crashing. Could you run the compiled binary manually and obtain

Re: How use Resedit Dialogs + Dlang?

2019-12-15 Thread JN via Digitalmars-d-learn
On Sunday, 15 December 2019 at 04:00:14 UTC, Marcone wrote: There's a way to create simple GUI for Dlang using Resedit? How? Do you know how to do it with C++? It should work the same in D, just use the WinApi bindings for calls.

Re: Lambda capture by value

2020-02-24 Thread JN via Digitalmars-d-learn
On Monday, 24 February 2020 at 20:00:20 UTC, Adam D. Ruppe wrote: On Monday, 24 February 2020 at 19:50:23 UTC, JN wrote: foreach (i; iota(5)) { printers[i] = () { write(i); }; I know it looks silly but if you make that: printers[i] = (int i) { return () { write(i);

Lambda capture by value

2020-02-24 Thread JN via Digitalmars-d-learn
import std.range; import std.stdio; alias NumberPrinter = void delegate(); NumberPrinter[int] printers; void main() { foreach (i; iota(5)) { printers[i] = () { write(i); }; } foreach (i; iota(5)) { printers[i](); } } This prints 4 4 4 4 4. How to make

in not working for arrays is silly, change my view

2020-02-29 Thread JN via Digitalmars-d-learn
assert(1 in [1, 2, 3]); Error: incompatible types for (1) in ([1, 2, 3]): int and int[ Yes, I know about .canFind(), but this is something that trips people over and over. I think it would be better if "in" worked for both assoc arrays and normal arrays, or didn't work at all, for added

Re: in not working for arrays is silly, change my view

2020-03-02 Thread JN via Digitalmars-d-learn
On Saturday, 29 February 2020 at 21:56:51 UTC, Ali Çehreli wrote: Because you mentioned canFind, I think you want the semantics to be "is there an element with this value." If so, it would be confusing to use the same operator for two different things: For associative arrays, it means "is

Re: Where are the GSOC 2020 ideas?

2020-02-27 Thread JN via Digitalmars-d-learn
On Thursday, 27 February 2020 at 08:16:32 UTC, mark wrote: On https://wiki.dlang.org I can find GSOC ideas 2011-2019, but not 2020. I know the 2020 one's haven't been accepted, but I'd like to know what they are in case I feel like having a go at one as part of learning D. I don't know

Re: bindbc-opengl: Now drawing triangle

2020-01-25 Thread JN via Digitalmars-d-learn
On Saturday, 25 January 2020 at 19:52:25 UTC, Luhrel wrote: Hello, I made a simple OpenGL file using bindbc-opengl and glfw (https://pastebin.com/ehmcHwxj) based on https://github.com/SonarSystems/Modern-OpenGL-Tutorials/blob/master/%5BGETTING%20STARTED%5D/%5B1%5D%20Triangle/main.cpp The

Re: Is there a std.zip.ZipArchive isDir or isFile method?

2020-02-03 Thread JN via Digitalmars-d-learn
On Monday, 3 February 2020 at 13:26:38 UTC, mark wrote: I'm using std.zip.ZipArchive to read zip files, e.g.: auto zip = new ZipArchive(read(filename)); // ... foreach (name, member; zip.directory) { if (name.endsWith('/')) // skip dirs continue;

Assoc array init

2020-02-03 Thread JN via Digitalmars-d-learn
int[int] a = [5: 7]; void main() { } This fails because apparently [5: 7] is a "non-const expression". How? Why? Yes, I know I can just init in a static this() section, but that feels like a bad workaround.

Re: Empty string vs null

2020-02-03 Thread JN via Digitalmars-d-learn
On Tuesday, 4 February 2020 at 07:44:08 UTC, mark wrote: Just found this post by Mark Parker that explains: https://forum.dlang.org/post/gvveit$10i5$1...@digitalmars.com I recommend using Nullable from https://dlang.org/phobos/std_typecons.html#Nullable if you want to explicitly allow a

Re: total newbie + IDE

2020-02-07 Thread JN via Digitalmars-d-learn
On Friday, 7 February 2020 at 17:02:18 UTC, solnce wrote: Hi guys, I am total newbie and trying to learn a little bit of programming for personal purposes (web scrapping, small databases for personal use etc.). I've been trying to install any of IDE available, but had no success. [...]

Re: GtkD on Windows: notes + question

2020-02-09 Thread JN via Digitalmars-d-learn
On Sunday, 9 February 2020 at 13:28:59 UTC, mark wrote: I found a much easier way to get GtkD working on windows than that described in https://gtkdcoding.com/2019/01/11/-introduction-to-gtkDcoding.html 1. I downloaded and installed the Gtk3 runtime (the link is on

Re: total newbie + IDE

2020-02-09 Thread JN via Digitalmars-d-learn
On Sunday, 9 February 2020 at 13:22:56 UTC, solnce wrote: I really enjoy Pascal having Lazarus. Although it is not perfected, it provides very good start for beginners - native IDE, RAD, easy to setup and adjust, integrated debugger. All that beginners need to have for good start at no time

Default value for member class

2020-02-10 Thread JN via Digitalmars-d-learn
class IntValue { int x = 5; } class Foo { IntValue val = new IntValue(); } void main() { Foo f1 = new Foo(); Foo f2 = new Foo(); assert(f1.val == f2.val); } Is this expected? Or should each Foo have their own IntValue object? They're equal right now, changing one changes

Re: How to parse epub content

2020-01-11 Thread JN via Digitalmars-d-learn
On Saturday, 11 January 2020 at 12:38:38 UTC, Adnan wrote: How would someone approach parsing epub files in D? Is there any libraries to parse XHTML? XHTML is XML. There are libraries to parse XML, from std.xml in the standard library to libraries like dxml in the package repository.

lambda alias import

2020-01-17 Thread JN via Digitalmars-d-learn
stuff.d: alias doStuff = () {}; main.d: import stuff; void main() { doStuff(); } DMD throws compile error: Error 42: Symbol Undefined __D5stuff9__lambda3FNaNbNiNfZv Is this expected behavior? It tripped me while trying to use DerelictVulkan :(

Re: Finding position of a value in an array

2019-12-30 Thread JN via Digitalmars-d-learn
On Sunday, 29 December 2019 at 08:31:13 UTC, mipri wrote: int i = a.countUntil!(v => v == 55); assert(i == 2); I also had to ask because I couldn't find it. In other languages it's named "index()", "indexOf()" or "find()". D is the only language I know which uses the "countUntil" scheme.

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-23 Thread JN via Digitalmars-d-learn
On Sunday, 22 December 2019 at 17:20:51 UTC, BoQsc wrote: There are lots of editors/IDE's that support D language: https://wiki.dlang.org/Editors What kind of editor/IDE are you using and which one do you like the most? This list could use some cleaning up. Some of the IDEs haven't been

Re: Unfold string array

2020-01-05 Thread JN via Digitalmars-d-learn
On Sunday, 5 January 2020 at 08:21:54 UTC, Teo wrote: All advises are welcome Thank you! For some reason I can't get run.dlang.io to shorten a link... hmm... I'll use ideone. https://ideone.com/EjbhIs It's kind of a naive implementation, there probably is room for improvement but should

Re: How load icon from resource using LoadImage?

2020-01-05 Thread JN via Digitalmars-d-learn
On Sunday, 5 January 2020 at 13:33:35 UTC, Marcone wrote: I am using this code to load icon from local directory, but I want to load icon from resource.res file: wndclass.hIcon = LoadImage( NULL, "icon.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE| LR_SHARED | LR_LOADTRANSPARENT);

Default values in derived class

2019-12-28 Thread JN via Digitalmars-d-learn
import std.stdio; class Base { bool b = true; } class Derived : Base { bool b = false; } void main() { // 1 Base b = new Derived(); writeln(b.b); // true // 2 Derived d = new Derived(); writeln(d.b); // false } Expected behavior or bug? 1) seems like a bug to me.

  1   2   >