Re: I think Associative Array should throw Exception

2020-09-03 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 3 September 2020 at 15:12:14 UTC, Steven Schveighoffer wrote: int[int] aa; aa[4] = 5; auto b = aa[4]; How is this code broken? It's valid, will never throw, and there's no reason that we should break it by adding an exception into the mix. int foo() nothrow { return

Re: Unable to open filename passed as command line argument

2020-09-03 Thread Curious via Digitalmars-d-learn
On Thursday, 3 September 2020 at 11:12:49 UTC, user1234 wrote: On Thursday, 3 September 2020 at 10:47:04 UTC, Curious wrote: otherwise what you get as args are D dynamic arrays (a payload made of .ptr and .length) so you can use std.file or std.stdio to open a file using the "D main"

Re: BetterC + WASM Update

2020-09-03 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 20:39:58 UTC, Mike Brown wrote: Is there an alternative that works with BetterC for dynamic arrays? You may give these a try: https://github.com/aferust/dvector For associative arrays: https://github.com/aferust/bcaa

Re: BetterC + WASM Update

2020-09-03 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Sep 03, 2020 at 06:18:00PM +, Mike Brown via Digitalmars-d-learn wrote: [...] > I did however, get taken in by how small and precise the D code was > compared to my C++ equivalent. The templating is beautiful, I’m now > considering writing in D rather than C++ as the smaller and

Re: BetterC + WASM Update

2020-09-03 Thread Mike Brown via Digitalmars-d-learn
Hi again, I now understand the issues at play. I get linking errors to the druntime features. I now understand the earlier replies. I was able to resolve all but TypeInfo errors from the suggested druntime replacements. Coming from a C++ background - I’m not even sure how I’m using TypeInfo

LNK2019 error in the C++ interface

2020-09-03 Thread dokutoku via Digitalmars-d-learn
I tried to use a function from a library written in C++ in D. I've been trying to use it in D. But I got an error in LNK2019 and the build failed. So I created a simple static library as follows and built it. ```cpp #pragma once #include namespace static_test { void str_test(LPCSTR

Re: I think Associative Array should throw Exception

2020-09-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/3/20 10:43 AM, Jesse Phillips wrote: On Tuesday, 1 September 2020 at 18:55:20 UTC, Steven Schveighoffer wrote: On 9/1/20 2:20 PM, Jesse Phillips wrote: Using RangeError is nice as it allows code to use array index inside `nothrow.` This is the big sticking point -- code that is nothrow

Re: I think Associative Array should throw Exception

2020-09-03 Thread Jesse Phillips via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 18:55:20 UTC, Steven Schveighoffer wrote: On 9/1/20 2:20 PM, Jesse Phillips wrote: Using RangeError is nice as it allows code to use array index inside `nothrow.` This is the big sticking point -- code that is nothrow would no longer be able to use AAs. It

Re: Install multiple executables with DUB

2020-09-03 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-03 14:41, glis-glis wrote: Yes I already tried that, but I get the error Error: only one main allowed. Previously found main at src/scripts/copy.d Looks like DUB doesn't like multiple binaries? Oh, multiple binaries, I missed that. You can try to add multiple configurations [1].

Re: Problem with gfm.math.matrix (some gamedevs out there ?)

2020-09-03 Thread Thomas via Digitalmars-d-learn
On Thursday, 3 September 2020 at 13:31:01 UTC, Mike Parker wrote: On Thursday, 3 September 2020 at 12:36:35 UTC, Thomas wrote: My example code: - import std.stdio; int main() { import gfm.math.matrix; const int width = 800; const int height = 600; auto

Re: Problem with gfm.math.matrix (some gamedevs out there ?)

2020-09-03 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 3 September 2020 at 12:36:35 UTC, Thomas wrote: My example code: - import std.stdio; int main() { import gfm.math.matrix; const int width = 800; const int height = 600; auto projectionMatrix = mat4!(float).identity(); auto ratio =

Re: Problem with gfm.math.matrix (some gamedevs out there ?)

2020-09-03 Thread drug via Digitalmars-d-learn
On 9/3/20 3:36 PM, Thomas wrote: Hi! I am following some examples in C++ about how OpenGL is working. There are great tutorials out there and most of it works also with D. For my code I am using gfm.math.matrix (Version 8.0.3) to be able to calculate the mouse position in a 3d world. Now I

Re: Install multiple executables with DUB

2020-09-03 Thread glis-glis via Digitalmars-d-learn
On Thursday, 3 September 2020 at 09:36:53 UTC, Jacob Carlborg wrote: On Thursday, 3 September 2020 at 08:22:25 UTC, glis-glis wrote: I usually would just write a makefile for that, but I thought I'd give DUB a go. Unfortunately, the DUB-documentation is a little thin and I cannot find a way

Re: How to use std.net.curl with specific curl query?

2020-09-03 Thread tastyminerals via Digitalmars-d-learn
On Thursday, 3 September 2020 at 11:14:14 UTC, tastyminerals wrote: I have a specific curl query that I want to use in a D script via std.net.curl. Here is the query: curl -v -X POST --data-urlencode "username=u...@gmail.net" --data-urlencode "password=12345" -H

Problem with gfm.math.matrix (some gamedevs out there ?)

2020-09-03 Thread Thomas via Digitalmars-d-learn
Hi! I am following some examples in C++ about how OpenGL is working. There are great tutorials out there and most of it works also with D. For my code I am using gfm.math.matrix (Version 8.0.3) to be able to calculate the mouse position in a 3d world. Now I have some problems with the

How to use std.net.curl with specific curl query?

2020-09-03 Thread tastyminerals via Digitalmars-d-learn
I have a specific curl query that I want to use in a D script via std.net.curl. Here is the query: curl -v -X POST --data-urlencode "username=u...@gmail.net" --data-urlencode "password=12345" -H "Content-Type: application/x-www-form-urlencoded" -H "Accept:

Re: Unable to open filename passed as command line argument

2020-09-03 Thread user1234 via Digitalmars-d-learn
On Thursday, 3 September 2020 at 10:47:04 UTC, Curious wrote: Given the following: =a== void main(string[] args) { FILE* fp = fopen(args[1].ptr, "r"); if (!fp) throw new Exception("fopen"); } =b== void main(string[] args) { FILE* fp = fopen(args[1].dup.ptr, "r");

Re: Unable to open filename passed as command line argument

2020-09-03 Thread drug via Digitalmars-d-learn
On 9/3/20 1:47 PM, Curious wrote: Given the following: =a== void main(string[] args) {     FILE* fp = fopen(args[1].ptr, "r");     if (!fp) throw new Exception("fopen"); } =b== void main(string[] args) {     FILE* fp = fopen(args[1].dup.ptr, "r");     if (!fp) throw new

Unable to open filename passed as command line argument

2020-09-03 Thread Curious via Digitalmars-d-learn
Given the following: =a== void main(string[] args) { FILE* fp = fopen(args[1].ptr, "r"); if (!fp) throw new Exception("fopen"); } =b== void main(string[] args) { FILE* fp = fopen(args[1].dup.ptr, "r"); if (!fp) throw new Exception("fopen"); } Why does a fail but

Re: Install multiple executables with DUB

2020-09-03 Thread Jacob Carlborg via Digitalmars-d-learn
On Thursday, 3 September 2020 at 08:22:25 UTC, glis-glis wrote: I usually would just write a makefile for that, but I thought I'd give DUB a go. Unfortunately, the DUB-documentation is a little thin and I cannot find a way to tell DUB "compile all the files in the scripts folder and put the

Install multiple executables with DUB

2020-09-03 Thread glis-glis via Digitalmars-d-learn
Hi, I have a few modules for parsing different file formats and a folder with d-scripts using these parsers to perform manipulations, extract information, ... Until now, I just added #!/usr/bin/env rdmd to the d-scripts and run them that way, but I'd like to make the scripts available to