Re: Can't pass [] to extern function object method

2020-11-18 Thread Bastiaan Veelo via Digitalmars-d-learn
On Wednesday, 18 November 2020 at 10:50:12 UTC, frame wrote: I found the "bug". It was caused by a debug {} statement within a struct method. I assume that the debug symbol is just incompatible called from the DLL context. Were the DLL and main program built in different modes

Re: How can execute method in new Thread?

2020-11-15 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 14 November 2020 at 17:21:15 UTC, Marcone wrote: Error: D:\dmd2\windows\bin\..\..\src\phobos\std\parallelism.d(516): Error: struct `Fruit` does not overload () I think you need to pass the this pointer somehow. This works: import std; struct Fruit { string name;

Re: App hangs, GC.collect() fixet it. Why?

2020-09-29 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 28 September 2020 at 21:58:31 UTC, Steven Schveighoffer wrote: On 9/28/20 3:28 PM, Bastiaan Veelo wrote: I’m leaning towards ditching the memory mapped I/O on the D end, and replace it by regular serialisation/deserialisation. That will be a manual rewrite though, which is a bit of

Re: App hangs, GC.collect() fixet it. Why?

2020-09-28 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 28 September 2020 at 15:44:44 UTC, Steven Schveighoffer wrote: On 9/28/20 8:57 AM, Bastiaan Veelo wrote: I am glad to have found the cause of the breakage finally, but it won't be easy to find a generic solution... Obviously, this isn't a real piece of code, but there is no way

Re: App hangs, GC.collect() fixet it. Why?

2020-09-28 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 5 June 2020 at 21:20:09 UTC, Steven Schveighoffer wrote: This kind of sounds like a codegen bug, a race condition, or (worst case) memory corruption. I think it must have been memory corruption: I had not realized that our old Pascal compiler aligns struct members on one byte

Re: Why Pegged action dont not work in this case ?

2020-06-11 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 19 April 2020 at 16:47:06 UTC, Basile B. wrote: I 've started experimenting Pegged action. Quickly i got blocked by this problem. The start action works where I use the rule but not directly in the rule. I don't understand the difference between how you use "where" and "directly

App hangs, GC.collect() fixet it. Why?

2020-06-05 Thread Bastiaan Veelo via Digitalmars-d-learn
I've been tracking down a hang in our pilot app. Using writeln, it appears to hang at newing a slice. After many hours of trying things, I discovered that program flow would continue past that point when I inserted a call to `GC.collect()` just before. Then it stalled again at a call to Win32

Re: Postblit segfault.

2020-06-01 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 1 June 2020 at 09:42:44 UTC, Boris Carvajal wrote: On Monday, 1 June 2020 at 06:35:36 UTC, MaoKo wrote: Hello, I don't understand why this code segfault on Reduced to: import std.stdio; struct S {} void main() { S[1] s; writeln(s); } This used to work up to dmd 2.084.1. It

Re: CT BitArray

2020-04-02 Thread Bastiaan Veelo via Digitalmars-d-learn
On Thursday, 1 November 2018 at 08:50:38 UTC, Bastiaan Veelo wrote: On Thursday, 1 November 2018 at 00:01:04 UTC, Stefan Koch wrote: On Wednesday, 31 October 2018 at 23:14:08 UTC, Bastiaan Veelo wrote: Currently, BitArray is not usable at compile time, so you cannot do ``` enum e =

Re: New with alias

2020-03-10 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 10 March 2020 at 06:09:23 UTC, tcak wrote: I write a code as below: auto result = new char[4]; It allocates memory as expected. This is a slice of four chars, which can be used as a dynamic array. Later I define an alias and do the above step: alias Pattern = char[4]; This

Re: Specify dmd or ldc compiler and version in a json dub file?

2020-01-20 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 09:17:02 UTC, data pulverizer wrote: I would like to know how to specify dmd or ldc compiler and version in a json dub file. Update: you can at least specify these in the toolchain requirements section:

Re: Slice/Substr [0..?lastIndexOf(".")] How refer itself without create a variable?

2019-12-05 Thread Bastiaan Veelo via Digitalmars-d-learn
On Thursday, 5 December 2019 at 11:28:51 UTC, Marcone wrote: Simple example: writeln("Hi\nHow are you?\nGood".splitLines()[0][0..?lastIndexOf(r"\")]); How to refer to this string in lastIndexOf() without create a variable? Thank you. .splitLines[0] already just produces "Hi", containing

Re: const and immutable values, D vs C++?

2019-12-04 Thread Bastiaan Veelo via Digitalmars-d-learn
On Wednesday, 4 December 2019 at 14:44:43 UTC, Ola Fosheim Grøstad wrote: When is there a noticable difference when using const values instead of immutable values in a function body? And when should immutable be used instead of const? f(){ const x = g(); immutable y = g(); ... do stuff

Re: Unexpected aliasing

2019-11-12 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 12 November 2019 at 08:15:20 UTC, Basile B. wrote: I'm curious to know what is the equivalent in Pascal that your transpiler fails to translate since Pascal records don't have constructors at all. Maybe you used an old school 'Object' ? Note that Extended Pascal is not exactly

Re: Unexpected aliasing

2019-11-12 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 11 November 2019 at 21:52:12 UTC, Jonathan M Davis wrote: On Monday, November 11, 2019 12:17:37 PM MST Bastiaan Veelo via Digitalmars- d-learn wrote: [...] I could use some help in rewriting the code below so that arr1 and arr2 each have their own data; ideally with minimal

Re: Unexpected aliasing

2019-11-12 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 11 November 2019 at 20:05:11 UTC, Antonio Corbi wrote: Defining and using a constructor for WrapIntegerArray seems to work: void main() { import std.stdio; WrapIntegerArray arr1 = WrapIntegerArray(5); arr1[0] = 42; WrapIntegerArray arr2 =

Unexpected aliasing

2019-11-11 Thread Bastiaan Veelo via Digitalmars-d-learn
Recently I got my first surprise with our use of D. The symptom was that two local variables in two different functions appeared to be sharing data. A simplified example is shown below (the original was machine translated from Pascal and involved templates and various levels of indirection).

Re: Saving and loading large data sets easily and efficiently

2019-10-03 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 30 September 2019 at 20:10:21 UTC, Brett wrote: [...] The way the data is structured is that I have a master array of non-ptr structs. E.g., S[] Data; S*[] OtherStuff; then every pointer points to an element in to Data. I did not use int's as "pointers" for a specific

Re: How to use #pragma omp parallel for collapse(n) in dlang?

2019-08-15 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 08:41:07 UTC, ijet wrote: How to use #pragma omp parallel for collapse(n) in dlang? I don’t understand the question. Bastiaan.

Re: 1 new

2019-08-03 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 2 August 2019 at 18:25:28 UTC, jmh530 wrote: When I navigate to https://forum.dlang.org/ I have a message that says "1 new reply" to "your posts." Normally, I click on that "1 new reply" and find the post that's new, go to it, and the message disappears. However, it doesn't seem to

Re: How to get name of my application (project)

2019-08-03 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 3 August 2019 at 09:26:03 UTC, Andrey wrote: Hello, how to get name of my application (project) that we write in dub.json? Is there any compile-time constant like __MODULE__? The name of an application is not a compile time constant: you can rename the executable at any time.

Re: Help me decide D or C

2019-08-02 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 2 August 2019 at 13:45:17 UTC, Alexandre wrote: On Friday, 2 August 2019 at 12:30:44 UTC, berni wrote: On Wednesday, 31 July 2019 at 18:38:02 UTC, Alexandre wrote: [...] In my oppinion C should have been deprecated about 50 years ago and it's not worth while to learn it if you

Re: Help me decide D or C

2019-08-02 Thread Bastiaan Veelo via Digitalmars-d-learn
On Thursday, 1 August 2019 at 20:02:08 UTC, Aurélien Plazzotta wrote: [...] But don't fool yourself, D is not for beginners. Ali Çehreli is a very skilled programmer, ergo, he can't reason like a new/starting programmer anymore, regardless of his patience and kindness. I am sorry, but this

Re: 1 - 17 ms, 553 ╬╝s, and 1 hnsec

2019-05-17 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 17 May 2019 at 18:36:00 UTC, ag0aep6g wrote: I'd suggest "17 ms, and 553.1µs" for a better default (1 hns is 0.1 µs, right?). No weird "hnsecs", no false precision, still all the data that is there. I was going to propose the same. Hns is weird. Bastiaan.

Re: Windows / redirect STDERR to see assert messages

2019-05-14 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 12 May 2019 at 13:39:15 UTC, Robert M. Münch wrote: When developing Windows GUI applications I use: // detach from console and attach to a new one, works for x86 and x86_64 FreeConsole(); AllocConsole(); freopen("CONIN$", "r", stdin); freopen("CONOUT$",

Re: CTFE in imported static initializers

2019-05-14 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 13 May 2019 at 20:39:57 UTC, Steven Schveighoffer wrote: Why? I can't even use it at compile time... pragma(msg, moddata.length); Is that a good test or "usable at compile time", though? Isn't pragma(msg) done at an earlier stage than CTFE? I think that was the argument for

Re: Compile time mapping

2019-05-12 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 12 May 2019 at 18:47:20 UTC, Bogdan wrote: On Sunday, 12 May 2019 at 17:53:56 UTC, Bastiaan Veelo wrote: If I understand your question correctly, you have two enums of equal length, and you want to convert members across enums according to their position, right? My question was

Re: Compile time mapping

2019-05-12 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 12 May 2019 at 17:53:56 UTC, Bastiaan Veelo wrote: On Saturday, 11 May 2019 at 15:48:44 UTC, Bogdan wrote: What would be the most straight-forward way of mapping the members of an enum to the members of another enum (one-to-one mapping) at compile time? If I understand your

Re: Compile time mapping

2019-05-12 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 11 May 2019 at 15:48:44 UTC, Bogdan wrote: What would be the most straight-forward way of mapping the members of an enum to the members of another enum (one-to-one mapping) at compile time? If I understand your question correctly, you have two enums of equal length, and you want

Re: OT - Git training Lon/HK and book recommendation on taste in programming

2019-05-02 Thread Bastiaan Veelo via Digitalmars-d-learn
On Wednesday, 1 May 2019 at 09:51:01 UTC, Laeeth Isharc wrote: Hi. First question - can anyone recommend git / Gitlab training providers in HK and London? Two distinct audiences - highly intelligent people that may or may not really program, and experienced developers with a finance

Re: Any full feature xml library available?

2019-05-02 Thread Bastiaan Veelo via Digitalmars-d-learn
On Thursday, 2 May 2019 at 15:50:53 UTC, rikki cattermole wrote: On 03/05/2019 3:36 AM, Russel Winder wrote: On Thu, 2019-05-02 at 02:11 +1200, rikki cattermole via Digitalmars-d- learn wrote: […] It does not. Those features come under the big bad guys feature list. Gonna have to go to C

Re: druntime giving wrong line for copy assert?

2019-04-30 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 30 April 2019 at 13:59:52 UTC, Rudy Raab wrote: The error was on line 36, which is the format, not my bad slice. Is there a reason for this, or is it a bug The message is correct when not using dub: https://run.dlang.io/is/chFTOY I suspect that if you remove the dub related lines

Re: Does D have a tool like pySnooper?

2019-04-26 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 26 April 2019 at 16:59:15 UTC, H. S. Teoh wrote: On Fri, Apr 26, 2019 at 02:33:16PM +, Taylor Hillegeist via Digitalmars-d-learn wrote: On Friday, 26 April 2019 at 10:22:49 UTC, Bastiaan Veelo wrote: [...] > Proofing the concept: > --- > mixin(snoop(q{ > int fun(int a, int

Re: Does D have a tool like pySnooper?

2019-04-26 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 26 April 2019 at 08:35:57 UTC, Bastiaan Veelo wrote: On Thursday, 25 April 2019 at 08:44:14 UTC, Dennis wrote: On Monday, 22 April 2019 at 16:24:53 UTC, Taylor Hillegeist wrote: Or would this not be easy at all with D? I don't think so. While there are lots of traits for

Re: Does D have a tool like pySnooper?

2019-04-26 Thread Bastiaan Veelo via Digitalmars-d-learn
On Thursday, 25 April 2019 at 08:44:14 UTC, Dennis wrote: On Monday, 22 April 2019 at 16:24:53 UTC, Taylor Hillegeist wrote: Or would this not be easy at all with D? I don't think so. While there are lots of traits for introspection of declarations, there is no way to introspect lines of

Re: Logging best practices

2019-04-26 Thread Bastiaan Veelo via Digitalmars-d-learn
On Thursday, 25 April 2019 at 10:33:00 UTC, Vladimirs Nordholm wrote: Hello. Is there a current "Best Practices" for logging in D? For the actual logging, I know of `std.experimental.logger`. However, the `experimental` has kept me away from it. Is it good, or are there any better

Re: Logging best practices

2019-04-26 Thread Bastiaan Veelo via Digitalmars-d-learn
On Thursday, 25 April 2019 at 15:51:43 UTC, dangbinghoo wrote: On Thursday, 25 April 2019 at 10:33:00 UTC, Vladimirs Nordholm wrote: Hello. Is there a current "Best Practices" for logging in D? For the actual logging, I know of `std.experimental.logger`. However, the `experimental` has kept

Re: CTFE & code generators based on PEG grammars?

2019-04-06 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 6 April 2019 at 12:06:22 UTC, Robert M. Münch wrote: The idea is, that I can write a string (or maybe even a scope block?) in my DSL and use a CTFE grammer to transpile the code. Are you aware of Pegged[1]? It’s for exactly that. [1] http://code.dlang.org/packages/pegged

Re: Duplicate class/interface/struct completely

2019-03-26 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 26 March 2019 at 05:29:08 UTC, Michelle Long wrote: The idea is to be able to make sure one can modify a class and drop it in for the original and it work in all cases. With alias this, it can fail unless we can alias it too. This sounds like mocking, this answer might be of help:

Re: Why this eponymous template does not compile?

2019-03-25 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 25 March 2019 at 09:27:03 UTC, Victor Porton wrote: /tmp/temp_7F3C101460D0.d(9,5): Error: template instance `synchronizedMemoize!f` template `synchronizedMemoize` is not defined, did you mean sychronizedMemoize(alias fun)()? Why the error? Sometimes, template error messages are

Re: Compile-time associative array

2019-03-20 Thread Bastiaan Veelo via Digitalmars-d-learn
On Wednesday, 20 March 2019 at 08:11:27 UTC, boolangery wrote: Got it ! Thank you, so I need to write: enum string[string] CtfeFoo = ["foo" : "bar"]; static immutable string[string] Foo; static this() { Foo = CtfeFoo; } string ctfeableFunction() { if (__ctfe) return

Re: PyD - accessing D class fields in Python

2019-03-19 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 18 March 2019 at 22:25:10 UTC, clothlen wrote: Howdy; I'm trying to extend my Python program with D, but I'm having trouble accessing a D class's field/attribute/property/something. My D file looks like this: ``` module simpletest; import pyd.pyd; import std.stdio; class

Re: Compile-time associative array

2019-03-19 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 19 March 2019 at 08:50:15 UTC, boolangery wrote: Hi, I want to use a constant associative array in a ctfe-able function. Example: string ctfeableFunction() { return Foo["foo"]; } Then I force ctfe with: enum res = ctfeableFunction(); When I use an enum like: enum Foo =

Re: why is ifThrown un@safe?

2019-03-15 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 15 March 2019 at 19:24:17 UTC, Bastiaan Veelo wrote: Will do the filing and maybe experiment a bit. Bastiaan. https://issues.dlang.org/show_bug.cgi?id=19741

Re: why is ifThrown un@safe?

2019-03-15 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 15 March 2019 at 19:19:41 UTC, H. S. Teoh wrote: On Fri, Mar 15, 2019 at 06:46:25PM +, bauss via Digitalmars-d-learn wrote: On Friday, 15 March 2019 at 18:04:05 UTC, Bastiaan Veelo wrote: > In the code below (https://run.dlang.io/is/d0oTNi), ifThrown > is inferred as un@safe. If

Re: why is ifThrown un@safe?

2019-03-15 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 15 March 2019 at 18:46:25 UTC, bauss wrote: On Friday, 15 March 2019 at 18:04:05 UTC, Bastiaan Veelo wrote: In the code below (https://run.dlang.io/is/d0oTNi), ifThrown is inferred as un@safe. If instead I write the implementation of ifThrown out (after res2) then it is @safe. As

why is ifThrown un@safe?

2019-03-15 Thread Bastiaan Veelo via Digitalmars-d-learn
In the code below (https://run.dlang.io/is/d0oTNi), ifThrown is inferred as un@safe. If instead I write the implementation of ifThrown out (after res2) then it is @safe. As far as I can see, there is no real difference. So why doesn't ifThrown work in this case, and can it be made to work?

Re: Phobos in BetterC

2019-03-09 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 8 March 2019 at 09:24:25 UTC, Vasyl Teliman wrote: I've tried to use Mallocator in BetterC but it seems it's not available there: https://run.dlang.io/is/pp3HDq This produces a linker error. I'm wondering why Mallocator is not available in this mode (it would be intuitive to

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

2019-02-24 Thread Bastiaan Veelo 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(...) { // ... } I don’t know if you can, but if at least g is a variadic

Re: Odd behavior of darray.dup

2019-02-24 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 24 February 2019 at 12:10:22 UTC, Bastiaan Veelo wrote: 1) You get "immutable(Color)(#{overlap raw, colors})" on immutable Color because the `Color.toString()` method is not const (corrected in the Gist). This is a bug in pixelperfectengine. Likewise, getters like `green()` should

Re: Odd behavior of darray.dup

2019-02-24 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 23 February 2019 at 23:35:14 UTC, solidstate1991 wrote: On Saturday, 23 February 2019 at 19:21:10 UTC, Bastiaan Veelo wrote: It works for me: https://run.dlang.io/gist/473b0021487275751accaebeb00be05c -- Bastiaan Still no luck, not even with memcpy. There's even more mystery

Re: Odd behavior of darray.dup

2019-02-23 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 22 February 2019 at 11:36:35 UTC, solidstate1991 wrote: If I want to copy an array of structs with .dup (cannot post the link in question here at the moment due to non-working clipboard, it's Color from pixelperfectengine.graphics.common) I get all zeroes instead of the values from

Re: Generalizing over function pointers and delegates

2019-02-15 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 15 February 2019 at 17:28:45 UTC, H. S. Teoh wrote: On Fri, Feb 15, 2019 at 05:40:39PM +0100, ag0aep6g via Digitalmars-d-learn wrote: Your fun_to_dlg fails when the function has parameters. Yes. Delegates are basically syntactic sugar for a function pointer with an implicit first

Re: Generalizing over function pointers and delegates

2019-02-15 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 15 February 2019 at 16:40:39 UTC, ag0aep6g wrote: Your fun_to_dlg fails when the function has parameters. Hah ok. std.functional.toDelegate() does work in its place though. As far as I see, it would be possible make the conversion would work by changing how a delegate's context is

Re: Generalizing over function pointers and delegates

2019-02-15 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 15 February 2019 at 14:30:45 UTC, Alex wrote: There is https://dlang.org/library/std/functional/to_delegate.html Ah, there it is :-) Thanks. A templated function also works. ``` int genfun(F)(F dg) {return dg();} ​ int top_level() {return -1;} ​ void main() { int nested()

Generalizing over function pointers and delegates

2019-02-15 Thread Bastiaan Veelo via Digitalmars-d-learn
Given a function taking a delegate, for example ``` int fun(int delegate() dg) {return dg();} ``` Sometimes we need to call `fun` with a pointer to a nested function and other times with a pointer to a top level function. As function pointers do not implicitly convert to delegates, this does

Re: Determination of thread status.

2018-12-26 Thread Bastiaan Veelo via Digitalmars-d-learn
On Wednesday, 26 December 2018 at 05:43:47 UTC, Vitaly wrote: On Tuesday, 25 December 2018 at 17:08:00 UTC, Neia Neutuladh wrote: 1. Find the Thread object: Tid threadId = spawn(); auto thread = Thread.getAll.filter!(x => x.id == threadId).front; 2. Check the `isRunning` property. The

Re: Determination of thread status.

2018-12-25 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 25 December 2018 at 14:44:43 UTC, Vitaly wrote: Hi all. I can not understand how to track me that the thread has finished work. eg: import std.concurrency; void myThread () { // Do the work } void main () { Tid thread = spawn (& myThread); // It is necessary to check whether the

Re: CT BitArray

2018-11-01 Thread Bastiaan Veelo via Digitalmars-d-learn
On Thursday, 1 November 2018 at 00:01:04 UTC, Stefan Koch wrote: Tell me which version are you using and I'll make it for you. By the way this is a really generous offer, thanks for being like that!

Re: CT BitArray

2018-11-01 Thread Bastiaan Veelo via Digitalmars-d-learn
On Thursday, 1 November 2018 at 00:01:04 UTC, Stefan Koch wrote: On Wednesday, 31 October 2018 at 23:14:08 UTC, Bastiaan Veelo wrote: Currently, BitArray is not usable at compile time, so you cannot do ``` enum e = BitArray([1, 1, 1, 0]); ``` This gives

CT BitArray

2018-10-31 Thread Bastiaan Veelo via Digitalmars-d-learn
Currently, BitArray is not usable at compile time, so you cannot do ``` enum e = BitArray([1, 1, 1, 0]); ``` This gives /dlang/dmd/linux/bin64/../../src/phobos/std/bitmanip.d(1190): Error: `bts` cannot be interpreted at compile time, because it has no available source code IIUC, that is

Re: Dub project has both .sdl and .json files. Is this normal or did I do something wrong?

2018-08-05 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 4 August 2018 at 17:53:45 UTC, Neia Neutuladh wrote: On Friday, 3 August 2018 at 19:41:32 UTC, Bastiaan Veelo wrote: But if you commit it, and a compiler deprecation causes a dependency in that pinned version to fail to compile, then your app won't compile either, even though your

Re: Dub project has both .sdl and .json files. Is this normal or did I do something wrong?

2018-08-03 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 19 December 2017 at 10:15:18 UTC, Jacob Carlborg wrote: On 2017-12-18 23:36, WhatMeWorry wrote: [...] But when I look the directory that has the dub.sdl file, I also see a file called dub.selections.json { "fileVersion": 1, "versions": {     "derelict-al":

Re: Newbie: out-of-source builds with "dub"?

2018-07-30 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 30 July 2018 at 01:50:23 UTC, CC wrote: [...] My usual modus operandi is: 1. check out the project into some directory "foo". 2. create another directory "foo.build", somewhere outside of "foo". 3. "cd foo.build" 4. Run some configuration script/file located in "foo", to generate

Re: UCFS does not work for nested functions?

2018-06-18 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 18 June 2018 at 19:31:39 UTC, Steven Schveighoffer wrote: In other words, if UFCS meant that module-level symbols took precedent over local symbols, then it's backwards in terms of which place usually wins. Generally it's the local symbols. Ah, you mean it would have to be that way

Re: UCFS does not work for nested functions?

2018-06-18 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 18 June 2018 at 17:58:11 UTC, Steven Schveighoffer wrote: On 6/18/18 1:25 PM, bauss wrote: On Monday, 18 June 2018 at 17:16:29 UTC, aliak wrote: On Monday, 18 June 2018 at 14:19:30 UTC, Steven Schveighoffer wrote: On 6/18/18 7:16 AM, Bastiaan Veelo wrote: On Sunday, 18 May 2014 at

Re: UCFS does not work for nested functions?

2018-06-18 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 18 May 2014 at 08:15:08 UTC, Steffen Wenz wrote: Hi, Just noticed that using UFCS does not work for nested functions, and was wondering whether that's intended, and what the rationale behind it is: I just had the same question. I can imagine that the context pointer of nested

File.put()

2018-06-08 Thread Bastiaan Veelo via Digitalmars-d-learn
Writing a single value to binary file can be done in (at least) two ways. Let `f` be a `File`: ``` f.rawWrite(()[0 .. 1]); ``` or ``` f.lockingBinaryWriter.put(value); ``` The former way is little talked about, the latter is not even documented. As far as I can see, the latter resolves to

Re: Line endings when redirecting output to file on windows.

2018-06-05 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 4 June 2018 at 15:31:04 UTC, Steven Schveighoffer wrote: Windows C library has this bizarro mode for FILE * called "text" mode, which is the default. In this mode, it scans all output, and anywhere it sees a '\n', it replaces it with "\r\n". Thanks, Steven.

Re: Line endings when redirecting output to file on windows.

2018-06-03 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 3 June 2018 at 15:42:48 UTC, rikki cattermole wrote: On 04/06/2018 3:24 AM, Bastiaan Veelo wrote: I need some help understanding where extra '\r' come from when output is redirected to file on Windows. First, this works correctly:  rdmd --eval="(\"hello\" ~

Line endings when redirecting output to file on windows.

2018-06-03 Thread Bastiaan Veelo via Digitalmars-d-learn
I need some help understanding where extra '\r' come from when output is redirected to file on Windows. First, this works correctly: rdmd --eval="(\"hello\" ~ newline).toFile(\"out.txt\");" As expected, out.txt contains "hello\r\n". I would expect the following to do the same, but it doesn't:

Re: Template instantiation fails on Linux, succeeds on Windows

2018-05-17 Thread Bastiaan Veelo via Digitalmars-d-learn
On Thursday, 17 May 2018 at 23:18:32 UTC, Basile B. wrote: On Thursday, 17 May 2018 at 22:07:46 UTC, Bastiaan Veelo wrote: Hi! The code in [1] compiles and runs flawlessly on Windows, but not on Linux (neither run.dlang nor Travis docker image). Any idea what can be done? Hello. Yes, add

Template instantiation fails on Linux, succeeds on Windows

2018-05-17 Thread Bastiaan Veelo via Digitalmars-d-learn
Hi! The code in [1] compiles and runs flawlessly on Windows, but not on Linux (neither run.dlang nor Travis docker image). Any idea what can be done? errors: Error: undefined identifier __va_list_tag onlineapp.d(282): Error: template instance `onlineapp.SetFactory!byte` error instantiating

Re: How to inform dub of generated source files?

2018-05-17 Thread Bastiaan Veelo via Digitalmars-d-learn
On Thursday, 17 May 2018 at 17:42:21 UTC, Bastiaan Veelo wrote: Isn't preGenerateCommands meant to cover this case? Appears to be a bug. Filed https://github.com/dlang/dub/issues/1474

How to inform dub of generated source files?

2018-05-17 Thread Bastiaan Veelo via Digitalmars-d-learn
Hi, Context: https://github.com/veelo/Pascal2D One of my source files is generated by executing `cd source && rdmd generate.d`, which creates the file `source/epparser.d`. (There is actually one step in between, calling `rdmd make.d`, which checks creation times, but that's not relevant

Re: Shouldn't D be added to this list?

2018-02-07 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 22:36:09 UTC, WhatMeWorry wrote: https://www.khronos.org/opengl/wiki/Language_bindings I was thinking that with derelictGL, D should be on this list? If so, I'm not sure how one would go about this? It is a wiki, anybody can add it, me thinks.

Re: BitArray shift left/right confusion.

2018-02-03 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 2 February 2018 at 00:33:03 UTC, Jakub Łabaj wrote: On the other hand, shifting operators are equally confusing for me, as they are for you - they really work in the other way around! I thought this is a very weird bug, but I found this pull request:

Re: `Alias this` to a mixed in property

2018-01-24 Thread Bastiaan Veelo via Digitalmars-d-learn
On Wednesday, 24 January 2018 at 14:21:42 UTC, ag0aep6g wrote: The spec says that you cannot make an overload set just by mixing in multiple functions/methods with the same name. Instead, you have to do it like this: mixin getter g; mixin setter!int s; alias p = g.p; alias p = s.p;

`Alias this` to a mixed in property

2018-01-24 Thread Bastiaan Veelo via Digitalmars-d-learn
Hi, `Alias this` to mixed in properties does not seem to work, see below. If you think it should, I'll file an issue. Otherwise: can this be made to work somehow? Interestingly, if you uncomment either the mixin getter or setter (row 36 or 37) and its corresponding use in `main`, then the

Re: Finding ElementType

2018-01-07 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 7 January 2018 at 13:50:23 UTC, Adam D. Ruppe wrote: On Sunday, 7 January 2018 at 12:40:22 UTC, Bastiaan Veelo wrote: 1) Should we have a reference in the docs for std.traits to std.range.primitive : ElementType? wouldn't hurt i guess 2) Should phobos contain a version without the

Finding ElementType

2018-01-07 Thread Bastiaan Veelo via Digitalmars-d-learn
The learn forum is great not only for asking questions, but also for learning from the questions by others: I just learned about the existence of std.range.primitives: ElementType, a function that I have looked for in phobos before, without finding it. I had expected this to be in std.traits

Re: Does dub support generating source files?

2018-01-06 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 6 January 2018 at 13:40:54 UTC, rikki cattermole wrote: On 06/01/2018 1:23 PM, Bastiaan Veelo wrote: I could script a custom preBuildCommand that checks modification dates and supplies the Pegged include path explicitly but that seems hackish and non-portable and typically

Re: Does dub support generating source files?

2018-01-06 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 6 January 2018 at 13:40:54 UTC, rikki cattermole wrote: On 06/01/2018 1:23 PM, Bastiaan Veelo wrote: Can dub do this or is this a thing for reggae? It must work on Windows though. Thanks! See: https://github.com/Abscissa/gen-package-version That seems to be a good tip,

Does dub support generating source files?

2018-01-06 Thread Bastiaan Veelo via Digitalmars-d-learn
Hi, One of my source files (epparser.d) should be generated by calling rdmd on another soure file (make.d) and therefore should depend on changes in make.d and an additional module (epgrammar.d). An include path to Pegged is required for compilation. epparser.d should be part of the main

Re: BitArray shift left/right confusion.

2017-12-28 Thread Bastiaan Veelo via Digitalmars-d-learn
On Wednesday, 27 December 2017 at 20:45:49 UTC, Biotronic wrote: BitArray is apparently a mess. Thanks for your confirmation, digging and reporting issues https://issues.dlang.org/show_bug.cgi?id=18133 and https://issues.dlang.org/show_bug.cgi?id=18134 (Turns out we both live in the same

BitArray shift left/right confusion.

2017-12-27 Thread Bastiaan Veelo via Digitalmars-d-learn
I suppose the following is not a bug, but confusing it is: ``` void main() { import std.stdio; import std.bitmanip; BitArray ba = [1, 1, 1, 1, 1, 1, 1, 1]; writeln(ba);// [1, 1, 1, 1, 1, 1, 1, 1] ba >>= 4; // right shift writeln(ba);// [1, 1,

Re: Ddoc and struct members

2017-12-14 Thread Bastiaan Veelo via Digitalmars-d-learn
On Thursday, 14 December 2017 at 03:17:10 UTC, rikki cattermole wrote: On 14/12/2017 3:16 AM, n00nb wrote: I don't understand if there is a way to generate documentation for all the members without putting a '///' over every member There isn't. It doesn’t need to take any vertical space

Re: ddox empty public methods/interfaces etc

2017-11-13 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 10 November 2017 at 10:12:32 UTC, RazvanN wrote: I don't want to open a new forum thread for this, but if you guys have more experience with ddox can you please explain me how does it work? I expected you can simply run ddox on a .d file and it will output the documentation in some

Re: ldc D compiler installation on windows 10

2017-08-07 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 6 August 2017 at 23:44:27 UTC, greatsam4sure wrote: Good day. I will appreciate it if anybody here can help me with the step by step way of installing ldc D compiler on windows. I have read online info but i just don't get it. let the process be in steps for easy

Re: VibeD - REST API and vibed.web.auth framework

2017-08-07 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 6 August 2017 at 16:47:14 UTC, holo wrote: Hello I'm trying to use auth framework with REST api ( http://vibed.org/api/vibe.web.auth/ ). Is it possible to use it with registerRestInterface? According to description under: http://vibed.org/api/vibe.web.auth/requiresAuth it should

Re: trait detecting anonymous union?

2017-05-23 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 23 May 2017 at 01:02:59 UTC, Vladimir Panteleev wrote: On Monday, 22 May 2017 at 21:03:42 UTC, Bastiaan Veelo wrote: Is there a way to detect at CT that S has overlapping data members, when an anonimous union is used as above? I have an implementation here:

Re: trait detecting anonymous union?

2017-05-23 Thread Bastiaan Veelo via Digitalmars-d-learn
On Monday, 22 May 2017 at 22:11:15 UTC, Stanislav Blinov wrote: On Monday, 22 May 2017 at 21:03:42 UTC, Bastiaan Veelo wrote: Is there a way to detect at CT that S has overlapping data members, when an anonimous union is used as above? There isn't a built-in one. The best I can muster at

trait detecting anonymous union?

2017-05-22 Thread Bastiaan Veelo via Digitalmars-d-learn
` void main() { import std.stdio; struct S { int i; union { int a; double b; } } S s; writeln(s); // S(10, #{overlap a,

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-13 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 13 May 2017 at 09:51:40 UTC, k-five wrote: On Saturday, 13 May 2017 at 09:05:17 UTC, Jonathan M Davis But obviously, to know what's actually happening with your code, you're going to have to profile and benchmark it - Can you please give a link or page or something to read about

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-13 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 13 May 2017 at 10:51:09 UTC, k-five wrote: Okay, and NOW I understood what you are trying to say. First of all I thought you got mad at me. And I became sad. My sincere apologies! Always assume the best in people :-) I am glad you asked for clarification. [...] Still I am a

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-13 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 13 May 2017 at 08:23:55 UTC, k-five wrote: On Friday, 12 May 2017 at 20:53:56 UTC, Bastiaan Veelo wrote: Is it safe to say that these 40 lines of D do the same as your 324 lines of C++ [1]? No. I cannot say that. Since this is not a full port of renrem in C++ to D. It was just

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-12 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 12 May 2017 at 15:24:52 UTC, k-five wrote: A full version that I just added to my gitgub: https://github.com/k-five/dren You may like getopt[1] for command line argument parsing. https://dlang.org/phobos/std_getopt.html

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-12 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 12 May 2017 at 15:24:52 UTC, k-five wrote: On Friday, 12 May 2017 at 11:10:01 UTC, k-five wrote: I was waiting for a stable version of C++17 ( standard library ) to add some features of fileSystem in C++17 to my program that wants to iterate through all files in a directory

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-12 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 12 May 2017 at 11:10:01 UTC, k-five wrote: I was waiting for a stable version of C++17 ( standard library ) to add some features of fileSystem in C++17 to my program that wants to iterate through all files in a directory recursively. I was thinking how could I do for implementing

Re: readf interferes with readln

2017-04-27 Thread Bastiaan Veelo via Digitalmars-d-learn
On Thursday, 27 April 2017 at 08:37:26 UTC, ketmar wrote: Bastiaan Veelo wrote: Hi, I am having trouble explaining the following to someone learning D. Can someone explain why readln has different behaviour when it is preceded by readf? Suppose we want to not end the program before the

  1   2   >