Re: Write file at compile time?

2017-04-04 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 3 April 2017 at 21:20:41 UTC, Inquie wrote: On Monday, 3 April 2017 at 19:34:36 UTC, Adam D. Ruppe wrote: [...] Because it the code doesn't compile one has to copy and paste the pragma output to a d file and compile it to find the errors. It is useful to help debug mixins. Since

Re: Covert a complex C header to D

2017-04-03 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 3 April 2017 at 11:18:21 UTC, Nicholas Wilson wrote: prefer template over string mixins where possible. This will make the code much more readable. My advise would be the opposite. templates put much more pressure on the compiler then string-mixins do. Also the code that

Re: Write file at compile time?

2017-04-03 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 3 April 2017 at 19:32:40 UTC, Stefan Koch wrote: On Monday, 3 April 2017 at 19:25:35 UTC, Inquie wrote: On Monday, 3 April 2017 at 19:06:01 UTC, Meta wrote: On Sunday, 2 April 2017 at 19:42:52 UTC, Inquie wrote: I would like to write the output of a manifest constant at compile

Re: Write file at compile time?

2017-04-03 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 3 April 2017 at 19:25:35 UTC, Inquie wrote: On Monday, 3 April 2017 at 19:06:01 UTC, Meta wrote: On Sunday, 2 April 2017 at 19:42:52 UTC, Inquie wrote: I would like to write the output of a manifest constant at compile time to a file instead of console using pragma(msg). Is this

Re: Building DMD

2017-03-31 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 31 March 2017 at 14:19:59 UTC, Inquie wrote: On Friday, 31 March 2017 at 08:20:51 UTC, Nicholas Wilson wrote: [...] Yes, I downloaded druntime from github and built it as I did phobos. The 64-bit make files have issues because paths are hard coded and things are not so simple as

Re: bug in foreach continue

2017-03-21 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 17 March 2017 at 19:05:20 UTC, H. S. Teoh wrote: There are actually (at least) TWO distinct phases of compilation that are conventionally labelled "compile time": 1) Template expansion / AST manipulation, and: 2) CTFE (compile-time function evaluation). [ ... ] Template

Re: Delay allocating class instance in stack.

2017-03-21 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 21 March 2017 at 08:08:24 UTC, ANtlord wrote: Hello! I read documentation about memory management and can't find description about delay allocation of instance. I have a method marked by @nogc. This method takes boolean variable. If this variable is true I want to construct object

Re: Error: out of memory

2017-03-19 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 18 March 2017 at 20:39:20 UTC, StarGrazer wrote: I have some CTFE's and meta programming that cause dmd to run out of memory ;/ I am generating simple classes, but a lot of them. dmd uses about 2GB before it quites. It also only uses about 12% of cpu. I have 16 GB total memory

Re: debug mixins

2017-03-14 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 15 March 2017 at 03:43:20 UTC, Inquie wrote: So, is it possible to debug string mixins? I ran visual D and tried to step in to a function that was generated by a mixin and it brought an open file dialog box asking me to load the source code where the function was located... of

Re: Recursive template instantiation

2017-03-13 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 13 March 2017 at 22:59:36 UTC, ag0aep6g wrote: On 03/13/2017 03:26 PM, Jack Applegame wrote: I'm pretty sure that this code should compile (https://dpaste.dzfl.pl/cf1e1ee6ef4b): struct A(T) { ~this() { char[T.sizeof] data; } } struct B(T) { A!T foo; } struct C

Re: scope(~this)

2017-03-12 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 12 March 2017 at 21:38:44 UTC, Inquie wrote: Is there any easy way to create a scope for termination of the object? [...] scope(exit)

Re: DMD win32.mak error

2017-03-11 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 11 March 2017 at 02:25:15 UTC, Paul D Anderson wrote: On Saturday, 11 March 2017 at 00:34:03 UTC, Paul D Anderson wrote: On Friday, 10 March 2017 at 22:04:23 UTC, Paul D Anderson wrote: While building DMD -- "make -fwin32.mak release" -- I received the following error message:

Re: How do I use CTFE to generate an immutable associative array at compile time?

2017-02-22 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 17:05:17 UTC, H. S. Teoh wrote: On Wed, Feb 22, 2017 at 04:08:45PM +, Stefan Koch via Digitalmars-d-learn wrote: [...] I'm not sure it's that simple. Just because AA's become CTFEable doesn't mean they will automatically be convertible to object code

Re: How do I use CTFE to generate an immutable associative array at compile time?

2017-02-22 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 15:27:22 UTC, H. S. Teoh wrote: (In fact, now I'm wondering if we could just hack dmd to emit the equivalent of this code as a lowering, whenever the user tries to declare a compile-time initialized AA.) All the problems disappear if the AA's are compiler

Re: How do I use CTFE to generate an immutable associative array at compile time?

2017-02-21 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 21 February 2017 at 21:53:23 UTC, Chad Joan wrote: Hello all, I'm trying to make this work: [...] You cannot create AA's at ctfe and carry them over to runtime use. You'd have to use a costum dictionary-type. I think the vibe.d project has one you could use.

Re: Why is for() less efficient than foreach?

2017-02-10 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 10 February 2017 at 12:39:50 UTC, Bastiaan Veelo wrote: Benchmarking for() against foreach(): / enum size_t maxarray = 500_000; double[maxarray] a, b, c, d; void main() { import std.stdio; import std.datetime; import std.random; for (int n = 0; n <

Re: Why do static arrays affect executable size?

2017-02-10 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 10 February 2017 at 11:21:48 UTC, Bastiaan Veelo wrote: // enum int maxarray = 0; enum int maxarray = 2_000_000; double[maxarray] a, b, c, d; void main() {} Compiled using "dub build --arch=x86_64 --build=release" on Windows (DMD32 D Compiler v2.073.0), the exe size is 302_592

Re: Problems compiling sqlite-d

2017-01-28 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 29 January 2017 at 04:13:17 UTC, Nestor wrote: On Sunday, 29 January 2017 at 03:11:34 UTC, Stefan Koch wrote: On Sunday, 29 January 2017 at 02:59:12 UTC, Nestor wrote: On Sunday, 29 January 2017 at 02:55:04 UTC, Adam D. Ruppe wrote: [...] In the case of Windows, where libraries

Re: Problems compiling sqlite-d

2017-01-28 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 29 January 2017 at 02:59:12 UTC, Nestor wrote: On Sunday, 29 January 2017 at 02:55:04 UTC, Adam D. Ruppe wrote: On Sunday, 29 January 2017 at 00:36:34 UTC, Nestor wrote: Well, native implementations are useful at least for building self-contained applications. Sometimes true, but

Re: Problems compiling sqlite-d

2017-01-28 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 29 January 2017 at 01:47:44 UTC, Nestor wrote: On Saturday, 28 January 2017 at 21:09:25 UTC, Stefan Koch wrote: On Saturday, 28 January 2017 at 12:09:35 UTC, Nestor wrote: On Friday, 27 January 2017 at 12:55:55 UTC, Stefan Koch wrote: [...] Thanks. It did compile using dub,

Re: Problems compiling sqlite-d

2017-01-28 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 28 January 2017 at 12:09:35 UTC, Nestor wrote: On Friday, 27 January 2017 at 12:55:55 UTC, Stefan Koch wrote: [...] Thanks. It did compile using dub, though I had a couple of issues with dub, by the way. [...] I think you have to remove the app.d that comes with sqlite-d

Re: Problems compiling sqlite-d

2017-01-28 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 28 January 2017 at 19:01:48 UTC, Adam D. Ruppe wrote: On Friday, 27 January 2017 at 12:01:30 UTC, Nestor wrote: Is there any other native D implementation of sqlite reader? My sqlite.d and database.d from here can do it too: https://github.com/adamdruppe/arsd Just download those

Re: Partial arrays reclaimed?

2017-01-27 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 27 January 2017 at 23:22:17 UTC, Nick Sabalausky wrote: Suppose an array is being used like a FIFO: --- T[] slice; // Add: slice ~= T(); // Remove: slice = slice[1..$]; --- Assuming of course there's no other references to the memory, as

Re: Problems compiling sqlite-d

2017-01-27 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 27 January 2017 at 12:21:29 UTC, Nestor wrote: On Friday, 27 January 2017 at 12:06:33 UTC, Stefan Koch wrote: On Friday, 27 January 2017 at 12:04:06 UTC, Stefan Koch wrote: I take it you build without dub ? Have you specified source/sqlite.d on your compile commandline ? That

Re: Problems compiling sqlite-d

2017-01-27 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 27 January 2017 at 12:04:06 UTC, Stefan Koch wrote: I take it you build without dub ? Have you specified source/sqlite.d on your compile commandline ? That was supposed to say. sqlite-d/source/sqlited.d Please feel free to post here or contact me directly regarding the usage of

Re: Problems compiling sqlite-d

2017-01-27 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 27 January 2017 at 12:01:30 UTC, Nestor wrote: Hi, I was trying to use https://github.com/UplinkCoder/sqlite-d Unfortunately even something as simple as this doesn´t compile (at least on Windows): import std.stdio, sqlited; void main(string[] args) { string filename =

Re: D idom for removing array elements

2017-01-26 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 26 January 2017 at 23:10:02 UTC, albert-j wrote: On Thursday, 26 January 2017 at 13:21:38 UTC, Dukc wrote: import std.stdio, std.algorithm, std.range, std.array; int[] a = [1, 2, 3, 4, 5, 6, 7, 4]; int[] b = [3, 4, 6]; auto sortedB = sort(b.dup); auto c = a . filter!(i =>

Re: Bug in documentation or misunderstanding it?

2017-01-26 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 26 January 2017 at 17:38:59 UTC, Suliman wrote: I read docs and can't understand what's wrong. Or I am do not understand it, or there is come mistake. [...] You have to import typecons.

Re: D idom for removing array elements

2017-01-26 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 26 January 2017 at 11:44:27 UTC, Nicholas Wilson wrote: On Thursday, 26 January 2017 at 08:22:09 UTC, albert-j wrote: What is the D idiom for removing array elements that are present in another array? Is this the right/fastest way? int[] a = [1, 2, 3, 4, 5, 6, 7, 4]; int[] b =

Re: Min, max of enum

2017-01-25 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 26 January 2017 at 05:58:26 UTC, Profile Anaysis wrote: Since we do not have attributes for enums, I use _ in front of the names for meta values. [...] This can be done with Ctfe mixins and __traits, look at __traits(allMembers)

Re: Can compiler profile itself?

2017-01-25 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 24 January 2017 at 23:25:12 UTC, Profile Anaysis wrote: I am trying to compile some code and it takes around 6 seconds. Even if I change one line in one module, it takes the same time. There are about 20 different d modules. [...] yes the compiler can be used to profile itself.

Re: alias and UFCS

2017-01-24 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 24 January 2017 at 16:41:12 UTC, ixid wrote: On Tuesday, 24 January 2017 at 16:27:50 UTC, ixid wrote: On Tuesday, 24 January 2017 at 15:57:48 UTC, Las wrote: On Tuesday, 24 January 2017 at 13:11:41 UTC, ixid wrote: [...] Submit a bug report then. I will if it turns out the

Re: Why is [0] @safer than array.ptr?

2017-01-24 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 24 January 2017 at 11:28:17 UTC, Atila Neves wrote: void main() { foo; } void foo() @safe { int[] array; auto ptr = array.ptr; } foo.d(7): Deprecation: array.ptr cannot be used in @safe code, use [0] instead [0] is incredibly ugly and feels like an unnecessary

Re: General performance tips

2017-01-23 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 23 January 2017 at 11:11:21 UTC, albert-j wrote: I have translated some simulation code from Java into D (a few classes, mostly manipulation of double arrays in small methods). D version runs 10-30% slower than Java (ldc2, dub release build). Profiling did not show any obvious

Re: switch statement with variable branches

2017-01-19 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 19 January 2017 at 01:22:56 UTC, Yuxuan Shui wrote: Somehow I can't use ubyte variables behind 'case', but ulong works fine. Why is that? void main() { alias TestType = ulong; // won't compile if = ubyte import std.stdio; TestType a,b,c; readf("%s

Re: DMD Refuses to Compile Multiple Source Files

2017-01-17 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 03:11:08 UTC, Samwise wrote: On Wednesday, 18 January 2017 at 02:48:45 UTC, James Buren wrote: Import the source file containing the external function instead of writing that prototype. It should compile then. This seems like a workaround more than a permanent

Re: Auto recursive function

2017-01-11 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 11 January 2017 at 19:23:10 UTC, Razvan Nitu wrote: Hi, I am currently trying to create a function makeMultidimensionalArray which allocates memory for a multidimensional array. It is very similar with [1], the difference being that it is uninitialized. Here is the code: [...]

Re: Mixin in Inline Assembly

2017-01-08 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 9 January 2017 at 02:31:42 UTC, Chris M. wrote: Right now I'm working on a project where I'm implementing a VM in D. I'm on the rotate instructions, and realized I could *almost* abstract the ror and rol instructions with the following function private void rot(string ins)(int

Re: DIP-1000 and return

2017-01-01 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 1 January 2017 at 17:41:46 UTC, Nordlöw wrote: The code auto asStatic(T, size_t length)(T[length] arr) { return arr; } @safe pure nothrow @nogc unittest { auto x = [1, 2, 3].asStatic; static assert(is(typeof(x) == int[x.length])); static assert(is(typeof([1, 2,

Re: delegate passed in annotation struct cannot be invoked.

2016-12-29 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 29 December 2016 at 21:19:18 UTC, Alexandru Ermicioi wrote: On Thursday, 29 December 2016 at 21:07:00 UTC, Stefan Koch wrote: It's a delegate and not function. Therefore it will get a frame-ptr regardless, without checking if it is needed or not, or if there is a frame to point

Re: delegate passed in annotation struct cannot be invoked.

2016-12-29 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 29 December 2016 at 20:55:43 UTC, Alexandru Ermicioi wrote: Given code below: import std.stdio; struct Annotation { public int delegate(int) dg; } void main() { import std.traits; __traits(getAttributes, Cls)[0].dg(20).writeln; } @Annotation(delegate

Re: Unittest hangs on completion

2016-12-29 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 29 December 2016 at 20:27:21 UTC, David Zhang wrote: Hi, I've noticed recently, that whenever I unittest, it program hangs either at the very end, or right before they start. When using vanilla unit tests, the program appears to hang after the "All unit tests have been

Re: CTFE difference between dmd and ldc2

2016-12-27 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 27 December 2016 at 17:50:15 UTC, Joseph Rushton Wakeling wrote: Hello all, [ ... ] Can anyone advise what could be going wrong here? This looks like a nasty CTFE bug to me :-( Thanks & best wishes, -- Joe I doubt that this is a CTFE bug since there should be little

Re: Is there anything other than nullable to work with optional types?

2016-12-25 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 25 December 2016 at 19:22:10 UTC, aliak wrote: Hey, So, been using the programming language swift for a while now, the optional types[1] they support makes working with maybe-type (ala haskell) values extremely pleasant. [...] Well there is one easy way to do this. pass a

Re: Recursive-descent parsing

2016-12-24 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 24 December 2016 at 12:42:31 UTC, Andrew Edwards wrote: The authors of "The Art of Java" present, as a first coding example, a recursive-descent parser to demonstrate Java's ability to facilitate low level programming commonly performed in C and C++. I took the opportunity to

Re: How to initialize a associative array?

2016-12-24 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 24 December 2016 at 00:55:01 UTC, Yuxuan Shui wrote: I tried this: immutable int[char] xx = ['Q':0, 'B':1, 'N':2, 'R':3, 'P':4]; And got a "non-constant expression" error (with or without 'immutable'). What's the correct way? You cannot initialize an AA at compile-time.

Re: reading from file

2016-12-16 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 16 December 2016 at 06:47:15 UTC, KaattuPoochi wrote: On Tuesday, 13 December 2016 at 21:13:26 UTC, Ali wrote: And extending Ali's solution you can actually get the data in to a two dimentional array at compile time and have it in static memory with a small adjustment: static

Re: Accessing members through pointers to structs (also, CTFE associative arrays)

2016-12-15 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 15 December 2016 at 19:30:08 UTC, Ali Çehreli wrote: Yeah, I think the compiler is confused because the function is called in a non-const context during the initialization of an immutable object. I would open an issue: https://issues.dlang.org/enter_bug.cgi?product=D Ali

Re: faster "stringification"

2016-12-10 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 11 December 2016 at 02:09:41 UTC, Orut wrote: D nub here. I have a Python script that I'd like to implement in D. For certain parts, the D equivalent was slower than Python's. For example, Python code: #dummy code s = ["abc", "fjkd", "L", "qwa", "r", "uw", "tiro", "bc", "sg",

Re: function is not callable using argument types ()

2016-12-10 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 10 December 2016 at 08:41:56 UTC, Suliman wrote: import std.stdio; import std.concurrency; void main() { void sp(int i) { receive((int i) { writeln("i: ", i); }); } auto r = new Generator!int( { foreach(i; 1

Re: staticIota is easy

2016-12-10 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 10 December 2016 at 01:48:24 UTC, Ali Çehreli wrote: On 12/09/2016 05:34 PM, Stefan Koch wrote: On Friday, 9 December 2016 at 18:52:59 UTC, Ali Çehreli wrote: I thought I needed something like staticIota in a unittest to effect static foreach over a number range and I found one in

Re: staticIota is easy

2016-12-09 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 9 December 2016 at 18:52:59 UTC, Ali Çehreli wrote: I thought I needed something like staticIota in a unittest to effect static foreach over a number range and I found one in druntime's implementation: https://github.com/dlang/druntime/blob/master/src/core/internal/traits.d#L106

Re: Cannot implicitly convert expression () of type char [1024] to IOREQ *

2016-11-30 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 30 November 2016 at 10:20:35 UTC, Anders S wrote: int [1] argv; /* list of arguments */ Is that supposed to be a VLAIS ? That will not port to D. It would be helpful If you could share the code and state the intent.

Re: Creating array of structs being used in C interface

2016-11-27 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 27 November 2016 at 15:23:33 UTC, Timoses wrote: On Sunday, 27 November 2016 at 14:27:54 UTC, Adam D. Ruppe wrote: That's because int is zero initialized by default and thus doesn't need anything more than a call to zero memory function, and double isn't (it is NaN), so it gets an

Re: Template specialization question

2016-11-24 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 24 November 2016 at 17:47:04 UTC, Steven Schveighoffer wrote: void foo(T)(T t){writeln("a");} void foo(T...)(T t){writeln("b");} foo(1); Compiles? If so, which prints out? I was surprised by the answer. I can't find docs for it. Is the behavior intended? -Steve That is

Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 22:03:14 UTC, Satoshi wrote: or I have simple class class View { this(Rectangle frame) {...} this(float, float, float, float) { ... } this(Point, Size) { ... } } then struct Point, Size and Rectangle (Point, Size) now I need to write 2 overloads for View class

Re: Char representation

2016-11-22 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 13:29:47 UTC, RazvanN wrote: Given the following code: char[5] a = ['a', 'b', 'c', 'd', 'e']; alias Range = char[]; writeln(is(ElementType!Range == char)); One would expect that the program will print true. In fact, it prints false and I noticed that if

Re: Enumerate CTFE bug...

2016-11-21 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 21 November 2016 at 13:22:57 UTC, Paolo Invernizzi wrote: I'm not sure if it's the same as #15064 bug: import std.array, std.range, std.algorithm; immutable static foo = ["a", "b", "c"]; auto bar(R)(R r) { string s = r[1]; return s; } immutable static res =

Re: Memory allocation failed. Why?

2016-11-20 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 21 November 2016 at 06:45:04 UTC, ag0aep6g wrote: On 11/21/2016 07:36 AM, Stefan Koch wrote: On Monday, 21 November 2016 at 03:58:00 UTC, MGW wrote: On Sunday, 20 November 2016 at 18:58:04 UTC, Basile B. wrote: On Sunday, 20 November 2016 at 17:47:50 UTC, MGW wrote: [...] [...]

Re: Memory allocation failed. Why?

2016-11-20 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 21 November 2016 at 03:58:00 UTC, MGW wrote: On Sunday, 20 November 2016 at 18:58:04 UTC, Basile B. wrote: On Sunday, 20 November 2016 at 17:47:50 UTC, MGW wrote: import core.sys.windows.windows: MessageBoxA; void test() { for(int i; i != 10; i++) { ubyte[]

Re: the best language I have ever met(?)

2016-11-18 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 18 November 2016 at 21:28:44 UTC, ketmar wrote: On Friday, 18 November 2016 at 20:31:57 UTC, Igor Shirkalin wrote: After 2 hours of brain breaking (as D newbie) I have come to: uint_array.map!(v=>"%x".format(v)).join(", ") Why 2 hours? Because I have started with 'joiner' function

Re: Why some function are class-less?

2016-11-17 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:54:23 UTC, Suliman wrote: On Thursday, 17 November 2016 at 17:45:31 UTC, Stefan Koch wrote: On Thursday, 17 November 2016 at 17:42:44 UTC, Suliman wrote: On Thursday, 17 November 2016 at 16:46:37 UTC, Steven Schveighoffer wrote: On 11/17/16 11:28 AM,

Re: Why is three safety levels need in D?

2016-11-17 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:47:21 UTC, Nordlöw wrote: On Thursday, 17 November 2016 at 17:33:33 UTC, Stefan Koch wrote: Memory is inherently unsafe. But it can be treated in a safe way. A language that does not allow you to express a middle ground will have a lot of unsafe code that

Re: Why some function are class-less?

2016-11-17 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:42:44 UTC, Suliman wrote: On Thursday, 17 November 2016 at 16:46:37 UTC, Steven Schveighoffer wrote: On 11/17/16 11:28 AM, Suliman wrote: [...] D does not require classes to write functions. All a class member function is anyway is a function with an

Re: Why is three safety levels need in D?

2016-11-17 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:29:20 UTC, Nordlöw wrote: On Thursday, 17 November 2016 at 17:27:01 UTC, Stefan Koch wrote: It allows encapsulating unsafe operations in safely-callable wrappers. So is this a limitation in Rust? If so, could you give a more concrete D code example that

Re: Why is three safety levels need in D?

2016-11-17 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:18:27 UTC, Nordlöw wrote: Why does D need both `@safe`, `@trusted` and `@system` when Rust seems to get by with only safe (default) and `unsafe`? https://dlang.org/spec/memory-safe-d.html http://dlang.org/safed.html It allows encapsulating unsafe

Re: Assistance with DUB

2016-11-17 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 1 November 2016 at 22:01:23 UTC, Alfred Newman wrote: Greetings, I need some help with dub libraries. [...] test.d assumes that sqlite.d is given on the same compile command-line. This is the case when sqlite-d is build as a stand-alone app. If you want to integrate it I advise

Re: Getting usages of template

2016-11-17 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 17 November 2016 at 09:40:45 UTC, Carlin St Pierre wrote: Is it possible to get the list of usages of a template during compile time? For example: class Foo { void bar(T)(T t) { } } void main() { Foo foo = new Foo; foo.bar(1); // int

Re: The return of std.algorithm.find

2016-11-15 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 15 November 2016 at 09:50:40 UTC, RazvanN wrote: On Tuesday, 15 November 2016 at 09:43:27 UTC, RazvanN wrote: The find function which receives an input haystack and a needle returns the haystack advanced to the first occurrence of the needle. For normal ranges this is fine, but for

Re: Benchmarking Time Unit

2016-11-01 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 1 November 2016 at 22:55:36 UTC, Nordlöw wrote: On Tuesday, 1 November 2016 at 20:54:34 UTC, Steven Schveighoffer wrote: MonoTime has about 5-10 % fluctuations on my laptop. Is this as good as it gets? This is not clear. What is this a percentage of? It percentage of execution

Re: Reflection: Order of fields guaranteed?

2016-10-21 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 21 October 2016 at 01:34:44 UTC, Nick Sabalausky wrote: When using reflection to obtain the fields of a class/struct, is there any guarantee that the order is the same as the order the fields are defined? Yes they should always come in lexical order.

Re: overriding alias symbols

2016-10-12 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 12 October 2016 at 22:14:32 UTC, Superstar64 wrote: I'm trying to use mixin templetes to provide generic default implementations. Something like this: --- abstract class MyAbstractClass { void myAbstractMethod(); } mixin template defaultImplentation(alias Method, T...) {

Re: std.net.curl and libcurl.so

2016-09-22 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 22 September 2016 at 23:19:27 UTC, Joseph Rushton Wakeling wrote: The segfault would suggest to me that either the loading of the library fails or that there's some resource phobos expects to find which it can't access. Can anyone advise what could be going on here? -- Joe

Re: thisExePath purity

2016-09-19 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 20 September 2016 at 00:01:58 UTC, crimaniak wrote: Hi! Is there situations when output of thisExePath() can be different during runtime? If yes, what the reason? If no, is this possible to mark it as pure in phobos? https://dlang.org/library/std/file/this_exe_path.html No way

Re: seg fault, now what?

2016-09-17 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 17 September 2016 at 21:12:08 UTC, Ryan wrote: Is there an alternative to reporting bugs via bugzilla? I tried to open an account, but they recommend not using your main e-mail address because it will be posted to the web for all the spammers to find. But I don't have another

Re: Fast multidimensional Arrays

2016-08-29 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 29 August 2016 at 09:53:12 UTC, Steinhagelvoll wrote: Hello, I'm trying to find a fast way to use multi dimensional arrays. For this I implemented a matrix multiplication and compared the times for different ways. As a reference I used a Fortran90 implementation. [...] Any

Re: FP magic in std.math.pow

2016-07-31 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 31 July 2016 at 22:38:59 UTC, Seb wrote: Consider this short program: void main() { alias S = float; S s1 = 0x1.24c92ep+5; S s2 = -0x1.1c71c8p+0; [...] It's an anoying feature. The reason this is not implemented in dmd is that pow does not map to a simple cpu

Re: Transform/Compile to C/CPP as a target

2016-07-25 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 23 July 2016 at 12:27:24 UTC, ParticlePeter wrote: Is there any kind of project or workflow that converts D (subset) to C/CPP ? The short answer is no, not for any recent version of D.

Re: Is there a way to "see" source code generated by templates after a compile?

2016-07-18 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 18 July 2016 at 17:35:29 UTC, Stefan Koch wrote: I did it for function templates just now. It will the instantiated bodys to std-out. Okay here is the frist really hacky draft patch In dtemplate.d line 6691 right at the end of semantic3 insert the following code : if

Re: Is there a way to "see" source code generated by templates after a compile?

2016-07-18 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 17 July 2016 at 16:30:38 UTC, Stefan Koch wrote: On Sunday, 17 July 2016 at 14:54:34 UTC, zabruk70 wrote: On Sunday, 17 July 2016 at 11:14:39 UTC, Stefan Koch wrote: If you want to see template expansions you have to wait a little longer. Wow! Is this really possible?! So long

Re: Is there a way to "see" source code generated by templates after a compile?

2016-07-17 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 17 July 2016 at 14:54:34 UTC, zabruk70 wrote: On Sunday, 17 July 2016 at 11:14:39 UTC, Stefan Koch wrote: If you want to see template expansions you have to wait a little longer. Wow! Is this really possible?! So long time several peoples asked this... I am reasonably sure that

Re: Is there a way to "see" source code generated by templates after a compile?

2016-07-17 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 17 July 2016 at 05:57:52 UTC, WhatMeWorry wrote: I don't suppose there's a way to "see" source code generated by templates after a compile but before execution? Or does the compiler generate it to a lower level on the fly; thus losing the source code? I'm assuming no because

Re: String compare in words?

2016-05-29 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 29 May 2016 at 20:51:19 UTC, Seb wrote: On Sunday, 29 May 2016 at 20:40:52 UTC, qznc wrote: [...] Isn't that something that the compiler should optimize for you when you do an equality comparison? Is it really faster than ldc (with all optimzations turned on)? It can be faster

Re: Game Development Using D

2016-05-21 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 21 May 2016 at 15:53:18 UTC, David wrote: Hi, I want to try to create a game using D. I'm a complete newbie though (other than having C/C++ experience). Where would I start? Does D have an openGL binding? I am assuming I'll need to leverage a good amount C APIs? Any list of

Re: Is there a 128-bit integer in D?

2016-05-21 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 21 May 2016 at 09:43:38 UTC, Saurabh Das wrote: I see that 'cent' and 'ucent' are reserved for future use but not yet implemented. Does anyone have a working implementation of these types? Alternatively, is there an any effort towards implementation of arbitrary-sized integers

Re: constructed variadic call

2016-05-02 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 2 May 2016 at 18:22:52 UTC, Erik Smith wrote: Is there way to construct an "argument pack" from a non-static array (like the switch below)? I need to transport a variadic call through a void*. switch (a.length) { case 1: foo(a[1]); break; case 2: foo(a[1], a[2]); break; case

Re: Method doesn't compile when defined in a mixin, but is fine without?

2016-05-02 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 1 May 2016 at 14:01:51 UTC, pineapple wrote: On Sunday, 1 May 2016 at 13:46:14 UTC, ag0aep6g wrote: On 01.05.2016 15:32, pineapple wrote: static string vectorpropertymixin(string name, string SDL_getter, string SDL_setter){ [...] mixin(vectorpropertymixin( "minsize",

Re: C header file: tagged enumerations

2016-04-26 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 26 April 2016 at 22:57:36 UTC, Jesse Phillips wrote: Windows tends to have these in their header files, what is the best way to translate them to D? [...] eunm win32msi = mixin(_WIN32_MSI); static if (win32msi >= 500) .

Re: D programming video tutorial

2015-12-18 Thread Stefan Koch via Digitalmars-d-learn
I have a few videos on about D on YT. But those are ... well suboptimal. I will probably talk a bit about SDC... when time permits

Re: View Expanded Templates?

2015-12-18 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 18 December 2015 at 18:25:03 UTC, Taylor Hillegeist wrote: Is it possible to view the expanded form of templates or perhaps view the post-ctfe pre-compiled d code? I couldn't find any information on this topic but I think it would be useful. sometimes I use templates/mixins to write

Re: Trouble in converting C code to D

2015-04-12 Thread Stefan Koch via Digitalmars-d-learn
Do have you extern(C) everywhere ?

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 6 March 2015 at 10:16:32 UTC, zhmt wrote: There should be a function called DataAvilable. Simply read the data if this function returns true Thanks you! But the DataAvilable just return a bool value, so I dont know the available data size, I cant call the read method simply.

Re: how to read some in vibe.d tcpconnection?

2015-03-06 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 6 March 2015 at 10:10:35 UTC, zhmt wrote: Take a look at empty and leastSize. https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/core/stream.d#L33 @Rikki Cattermole Thanks for your reply, but it is not what I want, and I cant implement my goal with them. in

Re: Cannot use the same template arguments on function as the ones on struct

2015-02-11 Thread Stefan Koch via Digitalmars-d-learn
DMD cannot overload templated and non-templated functions an empty template argument is needed

Re: Cache Building of Pegged-Generated Parsers in a DUB Project

2014-11-26 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 26 November 2014 at 10:26:05 UTC, Nordlöw wrote: I want to cache parsers generated by Pegged grammars in a DUB project by writing the generated parser strings to files. Is it possible to add this build logic somewhere in DUB or do I have to resort to SCons for this?

Re: Preferred program config file format and parsing library?

2014-08-02 Thread Stefan Koch via Digitalmars-d-learn
On Saturday, 2 August 2014 at 12:42:00 UTC, Gary Willoughby wrote: What is the preferred format people here use for program config files? Json, Xml, ini, etc? Also what libraries exist to parse the preferred format? for me json is nice because it is virtually everywhere. for most casese

Re: Building SDC from source

2014-08-02 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 27 July 2014 at 15:15:05 UTC, Stefan Koch wrote: On Sunday, 27 July 2014 at 15:00:26 UTC, Dicebot wrote: On Sunday, 27 July 2014 at 14:44:29 UTC, Joseph Rushton Wakeling via Digitalmars-d-learn wrote: Adding a dlang.conf file in /etc/ld.so.conf.d/ which adds the /opt/dmd/lib64 path

Re: Building SDC from source

2014-07-27 Thread Stefan Koch via Digitalmars-d-learn
do you use gdc ? then you have to use -lgphobos2

Re: Building SDC from source

2014-07-27 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 27 July 2014 at 12:12:08 UTC, Stefan Koch wrote: do you use gdc ? then you have to use -lgphobos2 scratch that I wasn't looking :) sdc itself should not use phobos at all as far as I can tell. libsdrt should be selfcontaint.

Re: Building SDC from source

2014-07-27 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 27 July 2014 at 12:16:05 UTC, Stefan Koch wrote: On Sunday, 27 July 2014 at 12:12:08 UTC, Stefan Koch wrote: do you use gdc ? then you have to use -lgphobos2 scratch that I wasn't looking :) sdc itself should not use phobos at all as far as I can tell. libsdrt should be

<    1   2   3   4   >