Re: Line numbers in backtraces (2017)

2017-11-02 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 2 November 2017 at 19:05:46 UTC, Tobias Pankrath wrote: Including Phobos? Your posted backtrace looks to me like templates instantiated within Phobos, so I think you'd need Phobos with debug symbols for those lines. --- int main(string[] argv) { return argv[1].length > 0; } ---

Re: Line numbers in backtraces (2017)

2017-11-01 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 1 November 2017 at 06:44:44 UTC, Tobias Pankrath wrote: On Tuesday, 31 October 2017 at 11:21:30 UTC, Moritz Maxeiner wrote: On Tuesday, 31 October 2017 at 11:04:57 UTC, Tobias Pankrath wrote: [...] ??:? pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)[],

Re: Line numbers in backtraces (2017)

2017-10-31 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 31 October 2017 at 11:04:57 UTC, Tobias Pankrath wrote: [...] ??:? pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)[], ulong, const(char[])) [0xab5c9566] ??:? pure @safe bool std.exception.enforce!(Exception, bool).enforce(bool, lazy const(char)[],

Re: Why do I have to cast arguments from int to byte?

2017-10-10 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 10 October 2017 at 19:55:36 UTC, Chirs Forest wrote: I keep having to make casts like the following and it's really rubbing me the wrong way: void foo(T)(T bar){...} byte bar = 9; [...] Why? Because of integer promotion [1], which is inherited from C. [1]

Re: scope(exit) and destructor prioity

2017-09-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 18 September 2017 at 20:55:21 UTC, Sasszem wrote: If I write "auto a = new De()", then it calls the scope first, no matter where I place it. Because with `new` a) your struct object is located on the heap (and referred to by pointer - `De*`) instead of the stack (which means no

Re: My friend can't install DMD 2.076.0 after he deleted contents of C:\D

2017-09-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 17 September 2017 at 05:33:12 UTC, rikki cattermole wrote: Skip Revo-Uninstaller, no idea why you'd ever use such trial software. Anyway what you want is CCleaner, standard software that all Windows installs should have on hand.

Re: OpIndex/OpIndexAssign strange order of execution

2017-09-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 18 September 2017 at 15:11:34 UTC, Moritz Maxeiner wrote: gets rewritten to --- t.opIndex("b").opIndexAssign(t["a"].value, "c"); --- Sorry, forgot one level of rewriting: --- t.opIndex("b").opIndexAssign(t.opIndex("a").value, "c"); ---

Re: OpIndex/OpIndexAssign strange order of execution

2017-09-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 17 September 2017 at 18:52:39 UTC, SrMordred wrote: struct Test{ [...] } Test t; As described in the spec [1] t["a"] = 100; gets rewritten to --- t.opIndexAssign(100, "a"); --- , while t["b"]["c"] = t["a"].value; gets rewritten to ---

Re: extern(C) enum

2017-09-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 18 September 2017 at 02:04:49 UTC, bitwise wrote: The following code will run fine on Windows, but crash on iOS due to the misaligned access: Interesting, does iOS crash such a process intentionally, or is it a side effect? char data[8]; int i = 0x; int* p =

Re: Assertion Error

2017-09-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 13 September 2017 at 15:12:57 UTC, Vino.B wrote: On Wednesday, 13 September 2017 at 11:03:38 UTC, Moritz Maxeiner wrote: On Wednesday, 13 September 2017 at 07:39:46 UTC, Vino.B wrote: Hi Max, [...] Program Code: [...] foreach (string Fs; parallel(SizeDirlst[0 .. $], 1)) {

Re: Assertion Error

2017-09-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 13 September 2017 at 07:39:46 UTC, Vino.B wrote: On Tuesday, 12 September 2017 at 21:01:26 UTC, Moritz Maxeiner wrote: On Tuesday, 12 September 2017 at 19:44:19 UTC, vino wrote: Hi All, I have a small piece of code which executes perfectly 8 out of 10 times, very rarely it

Re: Assertion Error

2017-09-12 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 12 September 2017 at 19:44:19 UTC, vino wrote: Hi All, I have a small piece of code which executes perfectly 8 out of 10 times, very rarely it throws an assertion error, so is there a way to find which line of code is causing this error. You should be getting the line number as

Re: Adding empty static this() causes exception

2017-09-12 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 12 September 2017 at 19:59:52 UTC, Joseph wrote: On Tuesday, 12 September 2017 at 10:08:11 UTC, Moritz Maxeiner wrote: On Tuesday, 12 September 2017 at 09:11:20 UTC, Joseph wrote: I have two nearly duplicate files I added a static this() to initialize some static members of an

Re: Adding empty static this() causes exception

2017-09-12 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 12 September 2017 at 09:11:20 UTC, Joseph wrote: I have two nearly duplicate files I added a static this() to initialize some static members of an interface. On one file when I add an empty static this() it crashes while the other one does not. The exception that happens is

Re: Ranges seem awkward to work with

2017-09-11 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 12 September 2017 at 01:13:29 UTC, Hasen Judy wrote: Is this is a common beginner issue? I remember using an earlier version of D some long time ago and I don't remember seeing this concept. D's ranges can take getting used to, so if you haven't already, these two articles are

Re: Address of data that is static, be it shared or tls or __gshared or immutable on o/s

2017-09-11 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 11 September 2017 at 22:38:21 UTC, Walter Bright wrote: If an address is taken to a TLS object, any relocations and adjustments are made at the time the pointer is generated, not when the pointer is dereferenced. Could you elaborate on that explanation more? The way I thought

Re: betterC and struct destructors

2017-09-11 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 11 September 2017 at 10:18:41 UTC, Oleg B wrote: Hello. I try using destructor in betterC code and it's work if outer function doesn't return value (void). Code in `scope (exit)` works as same (if func is void all is ok). In documentation I found

Re: Can attributes trigger functionality?

2017-09-05 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 6 September 2017 at 02:43:20 UTC, Psychological Cleanup wrote: I'm having to create a lot of boiler plate code that creates "events" and corresponding properties(getter and setter). I'm curious if I can simplify this without a string mixin. If I create my own attribute like

Re: Bug in D!!!

2017-09-03 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 4 September 2017 at 03:08:50 UTC, EntangledQuanta wrote: On Monday, 4 September 2017 at 01:50:48 UTC, Moritz Maxeiner wrote: On Sunday, 3 September 2017 at 23:25:47 UTC, EntangledQuanta wrote: On Sunday, 3 September 2017 at 11:48:38 UTC, Moritz Maxeiner wrote: On Sunday, 3 September

Re: Bug in D!!!

2017-09-03 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 3 September 2017 at 23:25:47 UTC, EntangledQuanta wrote: On Sunday, 3 September 2017 at 11:48:38 UTC, Moritz Maxeiner wrote: On Sunday, 3 September 2017 at 04:18:03 UTC, EntangledQuanta wrote: On Sunday, 3 September 2017 at 02:39:19 UTC, Moritz Maxeiner wrote: On Saturday, 2

Re: Bug in D!!!

2017-09-03 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 3 September 2017 at 04:18:03 UTC, EntangledQuanta wrote: On Sunday, 3 September 2017 at 02:39:19 UTC, Moritz Maxeiner wrote: On Saturday, 2 September 2017 at 23:12:35 UTC, EntangledQuanta wrote: [...] The contexts being independent of each other doesn't change that we would still

Re: Bug in D!!!

2017-09-02 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 2 September 2017 at 23:12:35 UTC, EntangledQuanta wrote: On Saturday, 2 September 2017 at 21:19:31 UTC, Moritz Maxeiner wrote: On Saturday, 2 September 2017 at 00:00:43 UTC, EntangledQuanta wrote: On Friday, 1 September 2017 at 23:25:04 UTC, Jesse Phillips wrote: I've love being

Re: nested module problem

2017-09-02 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 2 September 2017 at 23:02:18 UTC, Moritz Maxeiner wrote: On Saturday, 2 September 2017 at 21:56:15 UTC, Jean-Louis Leroy wrote: [...] Hmmm I see...I was thinking of spinning the runtime part of my openmethods library into its own module (like here

Re: nested module problem

2017-09-02 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 2 September 2017 at 21:56:15 UTC, Jean-Louis Leroy wrote: [...] Hmmm I see...I was thinking of spinning the runtime part of my openmethods library into its own module (like here https://github.com/jll63/openmethods.d/tree/split-runtime/source/openmethods) but it looks like a bad

Re: nested module problem

2017-09-02 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 2 September 2017 at 21:24:19 UTC, Jean-Louis Leroy wrote: On Saturday, 2 September 2017 at 20:48:22 UTC, Moritz Maxeiner wrote: So the compiler wants you to import it by the name it has inferred for you (The fix being either specifying the module name in foo/bar.d as `module

Re: Bug in D!!!

2017-09-02 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 2 September 2017 at 00:00:43 UTC, EntangledQuanta wrote: On Friday, 1 September 2017 at 23:25:04 UTC, Jesse Phillips wrote: I've love being able to inherit and override generic functions in C#. Unfortunately C# doesn't use templates and I hit so many other issues where Generics

Re: nested module problem

2017-09-02 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 2 September 2017 at 20:03:48 UTC, Jean-Louis Leroy wrote: So I have: jll@ORAC:~/dev/d/tests/modules$ tree . ├── foo │   └── bar.d └── foo.d foo.d contains: import foo.bar; bar.d is empty. This means bar.d's module name will be inferred by the compiler [1], which will ignore

Re: string to character code hex string

2017-09-02 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 2 September 2017 at 20:02:37 UTC, bitwise wrote: On Saturday, 2 September 2017 at 18:28:02 UTC, Moritz Maxeiner wrote: In UTF8: --- utfmangle.d --- void fun_ༀ() {} pragma(msg, fun_ༀ.mangleof); --- --- $ dmd -c utfmangle.d _D6mangle7fun_ༀFZv --- Only universal

Re: Using closure causes GC allocation

2017-09-02 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 2 September 2017 at 18:59:30 UTC, Vino.B wrote: On Saturday, 2 September 2017 at 18:32:55 UTC, Moritz Maxeiner wrote: On Saturday, 2 September 2017 at 18:08:19 UTC, vino.b wrote: On Saturday, 2 September 2017 at 18:02:06 UTC, Moritz Maxeiner wrote: On Saturday, 2 September 2017

Re: Using closure causes GC allocation

2017-09-02 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 2 September 2017 at 18:08:19 UTC, vino.b wrote: On Saturday, 2 September 2017 at 18:02:06 UTC, Moritz Maxeiner wrote: On Saturday, 2 September 2017 at 17:43:08 UTC, Vino.B wrote: [...] Line 25 happens because of `[a.name]`. You request a new array: the memory for this has to be

Re: string to character code hex string

2017-09-02 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 2 September 2017 at 18:07:51 UTC, bitwise wrote: On Saturday, 2 September 2017 at 17:45:30 UTC, Moritz Maxeiner wrote: If this (unnecessary waste) is of concern to you (and from the fact that you used ret.reserve I assume it is), then the easy fix is to use `sformat` instead of

Re: Using closure causes GC allocation

2017-09-02 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 2 September 2017 at 17:43:08 UTC, Vino.B wrote: Hi All, Request your help on how to solve the issue in the below code as when i execute the program with -vgc it state as below: NewTD.d(21): vgc: using closure causes GC allocation NewTD.d(25): vgc: array literal may cause GC

Re: string to character code hex string

2017-09-02 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 2 September 2017 at 16:23:57 UTC, bitwise wrote: On Saturday, 2 September 2017 at 15:53:25 UTC, bitwise wrote: [...] This seems to work well enough. string toAsciiHex(string str) { import std.array : appender; auto ret = appender!string(null); ret.reserve(str.length

Re: gcd with doubles

2017-09-01 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 1 September 2017 at 09:33:08 UTC, Alex wrote: On Sunday, 27 August 2017 at 23:13:24 UTC, Moritz Maxeiner wrote: On Sunday, 27 August 2017 at 19:47:59 UTC, Alex wrote: [...] To expand on the earlier workaround: You can also adapt a floating point to string algorithm in order to

Re: Output range with custom string type

2017-08-31 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 31 August 2017 at 07:06:26 UTC, Jacob Carlborg wrote: On 2017-08-29 19:35, Moritz Maxeiner wrote: void put(T t) {     if (!store)     {     // Allocate only once for "small" vectors     store = alloc.makeArray!T(8);     if (!store)

Re: Output range with custom string type

2017-08-29 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 29 August 2017 at 09:59:30 UTC, Jacob Carlborg wrote: [...] But if I keep the range internal, can't I just do the allocation inside the range and only use "formattedWrite"? Instead of using both formattedWrite and sformat and go through the data twice. Then of course the final

Re: Accessing outer class attribute from inner struct

2017-08-29 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 29 August 2017 at 07:59:40 UTC, Andre Pany wrote: On Monday, 28 August 2017 at 23:12:40 UTC, Moritz Maxeiner wrote: In both cases S doesn't inherently how about C, which means a solution using default initialization is not feasible, as S.init can't know about any particular

Re: C callbacks getting a value of 0! Bug in D?

2017-08-28 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 29 August 2017 at 02:47:34 UTC, Johnson Jones wrote: [...] Seems only long and ulong are issues. With respect to the currently major platforms you can reasonable expect software to run on, yes. Just don't try to use D on something with e.g. 32 bit C shorts unless you bind to it

Re: C callbacks getting a value of 0! Bug in D?

2017-08-28 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 29 August 2017 at 01:34:40 UTC, Johnson Jones wrote: [...] produces 4 on both x86 and x64. So, I'm not sure how you are getting 8. There are different 64bit data models [1] and it seems your platform uses LLP64, which uses 32bit longs. Am I correct in assuming you're on

Re: Accessing outer class attribute from inner struct

2017-08-28 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 28 August 2017 at 22:47:12 UTC, Andre Pany wrote: On Monday, 28 August 2017 at 22:28:18 UTC, Moritz Maxeiner wrote: On Monday, 28 August 2017 at 21:52:58 UTC, Andre Pany wrote: [...] To make my question short:) If ColumnsArray is a class I can access the attribute "reference" but

Re: C callbacks getting a value of 0! Bug in D?

2017-08-28 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 28 August 2017 at 22:21:18 UTC, Johnson Jones wrote: On Monday, 28 August 2017 at 21:35:27 UTC, Steven Schveighoffer wrote: On 8/27/17 10:17 PM, Johnson Jones wrote: [...] For C/C++ interaction, always use c_... types if they are available. The idea is both that they will be

Re: Accessing outer class attribute from inner struct

2017-08-28 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 28 August 2017 at 21:52:58 UTC, Andre Pany wrote: [...] To make my question short:) If ColumnsArray is a class I can access the attribute "reference" but not if it is a struct. I would rather prefer a struct, but with a struct it seems I cannot access "reference". How can I

Re: Output range with custom string type

2017-08-28 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 28 August 2017 at 14:27:19 UTC, Jacob Carlborg wrote: I'm working on some code that sanitizes and converts values of different types to strings. I thought it would be a good idea to wrap the sanitized string in a struct to have some type safety. Ideally it should not be possible to

Re: gcd with doubles

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 27 August 2017 at 19:47:59 UTC, Alex wrote: [..] Is there a workaround, maybe? To expand on the earlier workaround: You can also adapt a floating point to string algorithm in order to dynamically determine an upper bound on the number of after decimal point digits required. Below

Re: gcd with doubles

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 27 August 2017 at 19:47:59 UTC, Alex wrote: Hi, all. Can anybody explain to me why void main() { import std.numeric; assert(gcd(0.5,32) == 0.5); assert(gcd(0.2,32) == 0.2); } fails on the second assert? I'm aware, that calculating gcd on doubles is not so

Re: Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 27 August 2017 at 10:46:53 UTC, Andrew Chapman wrote: [...] Oh interesting. Does DUB support passing through the --enable-contracts flag to ldc? Also, if this is an ldc specific thing it's probably not a good idea i'd imagine, since in the future one may want to use a GDC, or

Re: Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 27 August 2017 at 10:46:53 UTC, Andrew Chapman wrote: On Sunday, 27 August 2017 at 10:37:50 UTC, Moritz Maxeiner wrote: [...] Oh interesting. Does DUB support passing through the --enable-contracts flag to ldc? Sure, using platform specific build settings [1] such as

Re: Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 27 August 2017 at 10:17:47 UTC, Andrew Chapman wrote: On Sunday, 27 August 2017 at 10:08:15 UTC, ag0aep6g wrote: On 08/27/2017 12:02 PM, Andrew Chapman wrote: However, I am finding that BOTH enforce and assert are compiled out by dmd and ldc in release mode. Is there a standard

Re: Appending data to array results in duplicate's.

2017-08-25 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 25 August 2017 at 16:45:16 UTC, Vino.B wrote: Hi, Request your help on the below issue, Issue : While appending data to a array the data is getting duplicated. Program: import std.file: dirEntries, isFile, SpanMode; import std.stdio: writeln, writefln; import std.algorithm:

Re: Long File path Exception:The system cannot find the path specified

2017-08-23 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 23 August 2017 at 13:04:28 UTC, Vino.B wrote: The line it complains is std.file.FileException@std\file.d(3713):even after enabling debug it points to the same Output: D:\DScript>rdmd -debug Test.d -r dryrun std.file.FileException@std\file.d(3713):

Re: Long File path Exception:The system cannot find the path specified

2017-08-23 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 23 August 2017 at 12:01:20 UTC, Vino.B wrote: On Wednesday, 23 August 2017 at 11:29:07 UTC, Moritz Maxeiner wrote: On which line do you get the Exception? Does it happen with shorter paths, as well? Assuming it happens with all paths: Just to be sure, is each of those

Re: Long File path Exception:The system cannot find the path specified

2017-08-23 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 23 August 2017 at 05:06:50 UTC, Vino.B wrote: Hi All, When i run the below code in windows i am getting "The system cannot find the path specified" even though the path exist , the length of the path is 516 as below, request your help. Path :

Re: ore.exception.RangeError

2017-08-23 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 23 August 2017 at 05:53:46 UTC, ag0aep6g wrote: On 08/23/2017 07:45 AM, Vino.B wrote: Execution : rdmd Summary.d - Not working rdmd Summary.d test - Working Program: void main (string[] args) { if(args.length != 2 ) writefln("Unknown operation: %s", args[1]); } When

Re: Parameter File reading

2017-08-23 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 23 August 2017 at 10:25:48 UTC, Vino.B wrote: Hi All, Can anyone provide me a example code on how to read a parameter file and use those parameter in the program. From, Vino.B For small tools I use JSON files via asdf[1]. As an example you can look at the tunneled settings

Re: Different Output after each execution

2017-08-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 18 August 2017 at 15:46:13 UTC, Vino.B wrote: On Friday, 18 August 2017 at 11:24:24 UTC, Moritz Maxeiner wrote: On Friday, 18 August 2017 at 10:50:28 UTC, Moritz Maxeiner wrote: On Friday, 18 August 2017 at 10:06:04 UTC, Vino wrote: On Friday, 18 August 2017 at 08:34:39 UTC, ikod

Re: Different Output after each execution

2017-08-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 18 August 2017 at 10:50:28 UTC, Moritz Maxeiner wrote: On Friday, 18 August 2017 at 10:06:04 UTC, Vino wrote: On Friday, 18 August 2017 at 08:34:39 UTC, ikod wrote: On Friday, 18 August 2017 at 08:00:26 UTC, Vino.B wrote: Hi All, I have written a small program to just list the

Re: Different Output after each execution

2017-08-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 18 August 2017 at 10:06:04 UTC, Vino wrote: On Friday, 18 August 2017 at 08:34:39 UTC, ikod wrote: On Friday, 18 August 2017 at 08:00:26 UTC, Vino.B wrote: Hi All, I have written a small program to just list the directories, but when i run the program each time i am getting

Re: if (auto x = cast(C) x)

2017-08-09 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 21:54:46 UTC, Q. Schroll wrote: For a class/interface type `A` and a class `C` inheriting from `A` one can do A a = getA(); if (auto c = cast(C) a) { .. use c .. } to get a `C` view on `a` if it happens to be a `C`-instance. Sometimes one cannot find a

Re: Get Dll functions at compile time

2017-08-09 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 02:11:13 UTC, Johnson Jones wrote: I like to create code that automates much of the manual labor that we, as programmers, are generally forced to do. D generally makes much of this work automatable. For example, I have created the following code which makes

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

2017-08-08 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 09:31:49 UTC, data pulverizer wrote: On Tuesday, 8 August 2017 at 09:21:54 UTC, Moritz Maxeiner wrote: On Tuesday, 8 August 2017 at 09:17:02 UTC, data pulverizer wrote: Hi, I would like to know how to specify dmd or ldc compiler and version in a json dub file.

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

2017-08-08 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 09:17:02 UTC, data pulverizer wrote: Hi, I would like to know how to specify dmd or ldc compiler and version in a json dub file. Thanks in advance. You can't [1]. You can specify the compiler to use only on the dub command line via `--compiler=`. [1]

Re: Create class on stack

2017-08-08 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 05:37:41 UTC, ANtlord wrote: On Sunday, 6 August 2017 at 15:47:43 UTC, Moritz Maxeiner wrote: If you use this option, do be aware that this feature has been > scheduled for future deprecation [1]. It's likely going to continue working for quite a while (years),

Re: gtk interface responsiveness

2017-08-07 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 7 August 2017 at 22:02:21 UTC, Johnson Jones wrote: I have an icon that I toggle which clicked. It seems that I can't toggle it any faster than about a second. The handler is being called each click but it seems the gui is not updated more than about 1fps in that case? Although,

Re: x64 build time 3x slower?

2017-08-07 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 7 August 2017 at 22:19:57 UTC, Johnson Jones wrote: Why would that be. Program take about 4 seconds to compile and 12 for x64. There is fundamentally no difference between the two versions. I do link in gtk x86 and gtk x64 depending on version, and that's it as far as I can tell.

Re: Create class on stack

2017-08-07 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 7 August 2017 at 22:02:07 UTC, Mike wrote: On Monday, 7 August 2017 at 13:42:33 UTC, Moritz Maxeiner wrote: You can still create a (scope) class on the stack, escape a reference to it using `move` and use it afterwards, all within the rules of @safe, so I'm not convinced that the

Re: Create class on stack

2017-08-07 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 7 August 2017 at 10:42:03 UTC, Jacob Carlborg wrote: On 2017-08-06 17:47, Moritz Maxeiner wrote: If you use this option, do be aware that this feature has been scheduled for future deprecation [1]. It's likely going to continue working for quite a while (years), though. It's

Re: Create class on stack

2017-08-07 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 7 August 2017 at 13:40:18 UTC, Moritz Maxeiner wrote: Thanks, I wasn't aware of this. I tried fooling around scope classes and DIP1000 for a bit and was surprised that this is allowed: --- import core.stdc.stdio : printf; import std.algorithm : move; class A { int i;

Re: Create class on stack

2017-08-07 Thread Moritz Maxeiner via Digitalmars-d-learn
On Monday, 7 August 2017 at 10:50:21 UTC, Mike wrote: On Sunday, 6 August 2017 at 15:47:43 UTC, Moritz Maxeiner wrote: If you use this option, do be aware that this feature has been scheduled for future deprecation [1]. It's likely going to continue working for quite a while (years), though.

Re: Create class on stack

2017-08-06 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 6 August 2017 at 15:24:55 UTC, Jacob Carlborg wrote: On 2017-08-05 19:08, Johnson Jones wrote: using gtk, it has a type called value. One has to use it to get the value of stuff but it is a class. Once it is used, one doesn't need it. Ideally I'd like to treat it as a struct since

Re: Create class on stack

2017-08-06 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 6 August 2017 at 02:19:19 UTC, FoxyBrown wrote: [...] I don't think you understand what I'm saying. If I use this method to create a "reference" type on the stack rather than the heap, is the only issue worrying about not having that variable be used outside that scope(i.e., have

Re: Create class on stack

2017-08-05 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 6 August 2017 at 01:18:50 UTC, Johnson Jones wrote: On Saturday, 5 August 2017 at 23:09:09 UTC, Moritz Maxeiner wrote: On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote: using gtk, it has a type called value. One has to use it to get the value of stuff but it is a

Re: Create class on stack

2017-08-05 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote: using gtk, it has a type called value. One has to use it to get the value of stuff but it is a class. Once it is used, one doesn't need it. Ideally I'd like to treat it as a struct since I'm using it in a delegate I would like

Re: Adding deprecated to an enum member

2017-08-01 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 1 August 2017 at 01:12:28 UTC, Jeremy DeHaan wrote: I got an error today because I added deprecated to an enum member. Is there a way to achieve this, or am I out of luck? If it isn't doable, should it be? Here's what I want: [...] It's a bug [1]. [1]

Re: this r-value optimizations

2017-08-01 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 1 August 2017 at 22:47:24 UTC, Nordlöw wrote: Given the `struct S` with lots of data fields, I've written the following functional way of initializing only a subset of the members in an instance of `S`: struct S { [...] } Now the question becomes: will the S-copying inside

Re: Struct Postblit Void Initialization

2017-07-30 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 30 July 2017 at 19:22:07 UTC, Jiyan wrote: Hey, just wanted to know whether something like this would be possible sowmehow: struct S { int m; int n; this(this) { m = void; n = n; } } So not the whole struct is moved everytime f.e. a function is called, but only n has to be

Re: D move semantics

2017-07-30 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 30 July 2017 at 16:12:41 UTC, piotrekg2 wrote: What is the idiomatic D code equivalent to this c++ code? There's no direct equivalent of all your code to D using only druntime+phobos AFAIK. class Block { [...] }; Since you don't seem to be using reference type semantics or

Re: GC

2017-07-30 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 30 July 2017 at 09:12:53 UTC, piotrekg2 wrote: I would like to learn more about GC in D. [...] It would be great if you could point me out to articles on this subject. The primary locations to get information are the language specification [1] and the druntime documentation [2]. I

Re: Problem with dtor behavior

2017-07-28 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 28 July 2017 at 11:39:56 UTC, SrMordred wrote: On Thursday, 27 July 2017 at 20:28:47 UTC, Moritz Maxeiner wrote: On Thursday, 27 July 2017 at 19:19:27 UTC, SrMordred wrote: //D-CODE struct MyStruct{ int id; this(int id){ writeln("ctor"); } ~this(){

Re: Problem with dtor behavior

2017-07-27 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 27 July 2017 at 19:19:27 UTC, SrMordred wrote: //D-CODE struct MyStruct{ int id; this(int id){ writeln("ctor"); } ~this(){ writeln("dtor"); } } MyStruct* obj; void push(T)(auto ref T value){ obj[0] = value; } void main() { obj =

Re: Prevent destroy() from calling base deconstructor of a derived class?

2017-07-25 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 25 July 2017 at 17:50:18 UTC, Dragonson wrote: I need to call only the deconstructor of the derived class I have an instance of, not every deconstructor in the inheritance chain. Putting `override` before the destructor doesn't compile so I'm not sure how to achieve this? Call

Re: Creating a new type, to get strong-ish type checking and restrict usage to certain operations, using struct perhaps

2017-07-22 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 22 July 2017 at 06:08:59 UTC, Cecil Ward wrote: On Saturday, 22 July 2017 at 03:18:29 UTC, Cecil Ward wrote: [...] I saw David Nadlinger's units package. I'd like to know how the strong typing works. By wrapping in structs and overloading operators [1][2][3][4]. [1]

Re: Creating a new type, to get strong-ish type checking and restrict usage to certain operations, using struct perhaps

2017-07-22 Thread Moritz Maxeiner via Digitalmars-d-learn
On Saturday, 22 July 2017 at 03:18:29 UTC, Cecil Ward wrote: I guess part of my question, which I didn't really highlight well enough, is the issue of strong typing. [...] Going back to the original example of packed bcd stored in a uint64_t say, first thing is that I want to ban illegal

Re: Creating a new type, to get strong-ish type checking and restrict usage to certain operations, using struct perhaps

2017-07-21 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 21 July 2017 at 18:49:21 UTC, Cecil Ward wrote: I was think about how to create a new type that holds packed bcd values, of a choice of widths, that must fit into a uint32_t or a uint64_t (not really long multi-byte objects). I am not at all sure how to do it. I thought about using

Re: Adding flags to dub build

2017-07-18 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 20:12:13 UTC, Jean-Louis Leroy wrote: On Tuesday, 18 July 2017 at 20:00:48 UTC, Guillaume Piolat wrote: On Tuesday, 18 July 2017 at 19:49:35 UTC, Jean-Louis Leroy wrote: Hi, I want to add a few flags while building with dub. I tried:

Re: WTF is going on! Corrupt value that is never assigned

2017-07-14 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 23:30:39 UTC, Moritz Maxeiner wrote: Okay, I'll setup a Windows VM when I have time and check it out (unless someone solves it beforehand). I have been unable to reproduce your reported behaviour with dmd 2.074.1 (same as Adam).

Re: Exception handling

2017-07-14 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 14 July 2017 at 23:09:23 UTC, Stefan Koch wrote: On Friday, 14 July 2017 at 23:02:24 UTC, Moritz Maxeiner wrote: On Friday, 14 July 2017 at 21:20:29 UTC, Jonathan M Davis wrote: Basically, the compiler _never_ looks at the bodies of other functions when determining which attributes

Re: Exception handling

2017-07-14 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 14 July 2017 at 21:20:29 UTC, Jonathan M Davis wrote: On Friday, July 14, 2017 9:06:52 PM MDT Moritz Maxeiner via Digitalmars-d- learn wrote: On Friday, 14 July 2017 at 20:22:21 UTC, Ali Çehreli wrote: > Although it's obvious to us that there are only those two > exce

Re: Exception handling

2017-07-14 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 14 July 2017 at 20:22:21 UTC, Ali Çehreli wrote: On 07/14/2017 12:36 PM, ANtlord wrote: > Hello! I've tried to use nothrow keyword and I couldn't get a state of > function satisfied the keyword. I have one more method that can throw an > exception; it is called inside nothrow method.

Re: How to get value of type at CT given only an alias

2017-07-14 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 14 July 2017 at 18:06:49 UTC, Steven Schveighoffer wrote: .init is the default value. I'm not sure you can get the default value of a non-default initializer, My attempts using init didn't work. e.g.: void foo(alias T)() { pragma(msg, T.init); } struct S { int y = 5;

Re: WTF is going on! Corrupt value that is never assigned

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 22:53:45 UTC, FoxyBrown wrote: On Thursday, 13 July 2017 at 20:35:19 UTC, Moritz Maxeiner wrote: On Thursday, 13 July 2017 at 18:22:34 UTC, FoxyBrown wrote: The following code is pretty screwed up, even though it doesn't look like it. I have a buf, a simple malloc

Re: Read from terminal when enter is pressed, but do other stuff in the mean time...

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 15:52:57 UTC, Dustmight wrote: How do I read in input from the terminal without sitting there waiting for it? I've got code I want to run while there's no input, and then code I want to act on input when it comes in. How do I do both these things? As Stefan

Re: WTF is going on! Corrupt value that is never assigned

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 18:22:34 UTC, FoxyBrown wrote: The following code is pretty screwed up, even though it doesn't look like it. I have a buf, a simple malloc which hold the results of a win32 call. I am then trying to copy over the data in buf to a D struct. But when copying the

Re: Bad file descriptor in File destructor

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 10:56:20 UTC, unDEFER wrote: Seems I have found. I must do: try{ File file; try { file = File(path); } catch (Exception exp) { return; } //Some actions with file } catch (ErrnoException) { return; } Well, yes, you

Re: Bad file descriptor in File destructor

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 11:15:56 UTC, Moritz Maxeiner wrote: --- ubyte[File.sizeof] _file; ref File file() { return *(cast(File*) &_file[0]); } [create File instance and assign to file] scope (exit) destroy(file); --- Forgot to add the try catch: --- ubyte[File.sizeof] _file; ref File

Re: Bad file descriptor in File destructor

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 10:28:30 UTC, unDEFER wrote: On Thursday, 13 July 2017 at 08:53:24 UTC, Moritz Maxeiner wrote: Where does that `File` come from? If it's std.stdio.File, that one is a struct with internal reference counting, so it shouldn't crash in the above. Could you provide a

Re: Bad file descriptor in File destructor

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 13 July 2017 at 08:38:52 UTC, unDEFER wrote: Hello! I have the code like this: File file; try { file = File(path); } catch (Exception exp) { return; } ... try { } Where does that `File` come from? If it's std.stdio.File, that one

Re: Why do array literals default to object.Object[]?

2017-07-13 Thread Moritz Maxeiner via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 05:24:49 UTC, Brandon Buck wrote: On Wednesday, 12 July 2017 at 02:06:41 UTC, Steven Schveighoffer wrote: I'm sure there's a bug filed somewhere on this... Is this bug worthy? I can search for one and comment and/or create one if I can't find one. It's at

Re: Application settings

2017-07-07 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 7 July 2017 at 19:40:35 UTC, FoxyBrown wrote: What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save when necessary(possibly be efficient at it, but probably doesn't matter). Simply json an array and save and load it,

Re: "shared" woes: shared instances of anonymous classes

2017-07-07 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 7 July 2017 at 09:14:56 UTC, Arafel wrote: [...] Is there any way to create a shared instance of an anonymous class? [...] If somebody knows how this works / is supposed to work, I'd be thankful! [1]: https://dpaste.dzfl.pl/ce2ba93111a0 Yes, but it's round about: you have to

Re: Bulk allocation and partial deallocation for tree data structures.

2017-07-03 Thread Moritz Maxeiner via Digitalmars-d-learn
On Tuesday, 4 July 2017 at 03:13:14 UTC, Filip Bystricky wrote: Oh and I forgot to mention: another use-case for this would be for arrays. For manually managed arrays like std.container.array, it would make it possible to transfer ownership of individual objects from the array back to the

  1   2   >