Re: Sending an immutable object to a thread

2015-07-24 Thread anonymous via Digitalmars-d-learn
On Friday, 24 July 2015 at 18:55:26 UTC, Frank Pagliughi wrote: So then, of course, I hope/wonder/assume that the pointer to the heap is sufficient to keep the heap memory alive, and that this would be OK from the GC perspective to do something like this: B* make_b_thing(int i) { cast(B*)

Re: Sending an immutable object to a thread

2015-07-24 Thread anonymous via Digitalmars-d-learn
On Friday, 24 July 2015 at 21:51:44 UTC, Frank Pagliughi wrote: So then: is there a pointer notation to which you can cast the B reference, which thus points to the heap, but retains type identity of the heap object? There's no straight forward way to do that. D has no types for the actual

casting away const and then mutating

2015-07-23 Thread anonymous via Digitalmars-d
On a GitHub pull request, Steven Schveighoffer (schveiguy), Jonathan M Davis (jmdavis), and I (aG0aep6G) have been discussing if or when it's ok to cast away const and then mutate the data: https://github.com/D-Programming-Language/phobos/pull/3501#issuecomment-124169544 I've been under the

Re: monitoring variable evaluation time

2015-07-20 Thread anonymous via Digitalmars-d-learn
On Monday, 20 July 2015 at 08:53:52 UTC, Clayton wrote: What could be the best-tool for monitoring the evaluation time of a variable . What I usually do is run the command :- - dmd -J. program.d Then I inspect the program.o file using vi for presence of compile-time constants and enums. I am

Re: String Metaprogramming

2015-07-18 Thread anonymous via Digitalmars-d-learn
On Saturday, 18 July 2015 at 16:18:30 UTC, Clayton wrote: Thanks , you were right . It seems there are some key words though which one has to use so that the code gets executed on compile-time .For example I had to change the second forloop to a foreach loop, `for` loops work just fine in

Re: Infinite range of nullable elements

2015-07-17 Thread anonymous via Digitalmars-d-learn
On Friday, 17 July 2015 at 07:42:09 UTC, Roland Hadinger wrote: Here's how I would implement the basic behaviour (could be extended to also forward bidirectional and random access functions): --- auto cushion(R)(R r) if (isInputRange!R) { static if (isInfinite!R) {

Re: rust

2015-07-17 Thread anonymous via Digitalmars-d
On Friday, 17 July 2015 at 13:42:33 UTC, roaming wrote: On Thursday, 16 July 2015 at 12:06:46 UTC, Kagamin wrote: http://rainers.github.io/visuald/visuald/StartPage.html https://code.visualstudio.com/Updates/ can you do multiple dll on win yet? Do you ask this because of the runtime ?

Re: Environment variable for application storage under OSX ?

2015-07-17 Thread anonymous via Digitalmars-d-learn
On Friday, 17 July 2015 at 07:54:43 UTC, FreeSlave wrote: On Friday, 17 July 2015 at 07:33:43 UTC, Anonymous wrote: On Friday, 17 July 2015 at 07:14:24 UTC, FreeSlave wrote: On Thursday, 16 July 2015 at 21:12:05 UTC, anonymous wrote: I have the following code, working under Win and Linux:

Re: Environment variable for application storage under OSX ?

2015-07-17 Thread Anonymous via Digitalmars-d-learn
On Friday, 17 July 2015 at 07:14:24 UTC, FreeSlave wrote: On Thursday, 16 July 2015 at 21:12:05 UTC, anonymous wrote: I have the following code, working under Win and Linux: --- import std.process: environment; immutable string p; static this() { version(Win32) p =

Re: Comparison of struct with Nullable member

2015-07-17 Thread anonymous via Digitalmars-d-learn
On Friday, 17 July 2015 at 12:18:56 UTC, TC wrote: Hello, I came around a strange behavior and I'm not sure if it is a bug or feature. import std.typecons : Nullable; struct Foo { string bar; Nullable!int baz; } auto a = Foo(bb); auto b = Foo(bb); assert(a == b); This ends

Environment variable for application storage under OSX ?

2015-07-16 Thread anonymous via Digitalmars-d-learn
I have the following code, working under Win and Linux: --- import std.process: environment; immutable string p; static this() { version(Win32) p = environment.get(APPDATA); version(linux) p = /home/ ~ environment.get(USER); version(OSX) p = ?; } --- what would be the OSX

Re: Understanding Safety of Function Pointers vs. Addresses of Functions

2015-07-14 Thread anonymous via Digitalmars-d-learn
On Tuesday, 14 July 2015 at 01:05:21 UTC, jmh530 wrote: Note: some of the above seemed to only work when I kept the std.math.cos, std.math.sin text in there. When I take it out, I get warnings about recursive aliases. Yeah, you can't do `alias cos = givemeabettername!cos;`. That would define

Re: Understanding Safety of Function Pointers vs. Addresses of Functions

2015-07-14 Thread anonymous via Digitalmars-d-learn
On Tuesday, 14 July 2015 at 14:02:46 UTC, jmh530 wrote: Thanks for posting that. I figured out the issue. Before you had recommended that I use alias cos = std.math.cos; I had kept that text in. When I removed it, everything worked just fine. I'm still not sure I grasp the subtleties of alias

Re: Understanding Safety of Function Pointers vs. Addresses of Functions

2015-07-12 Thread anonymous via Digitalmars-d-learn
On Sunday, 12 July 2015 at 21:07:34 UTC, jmh530 wrote: private template givemeabettername(alias fun) { T givemeabettername(T : U[], U)(T x) if (isArray!(T)) { return x.map!(a = fun(a)).array; You don't need the lambda, do you? - return x.map!fun.array; } } Very

Re: Understanding Safety of Function Pointers vs. Addresses of Functions

2015-07-12 Thread anonymous via Digitalmars-d-learn
On Sunday, 12 July 2015 at 16:34:17 UTC, jmh530 wrote: I've been playing around with this a little more. I wrote this function to encapsulate a simple operation on arrays. U array_fun(T, U)(T fp, U x) if (isFunctionPointer!(T) isArray!(U)) { return x.map!(a = fp(a)).array; }

Re: opApply compilation woes

2015-07-12 Thread anonymous via Digitalmars-d-learn
On Sunday, 12 July 2015 at 17:25:17 UTC, Gary Willoughby wrote: Why does the following code fail to compile if the `writeln(value);` line is present? The error message (formatted to be a little more readable): Error: function test2.__unittestL6_1.Foo.opApply (int delegate(ref string)

Re: Array operations with array of structs

2015-07-11 Thread anonymous via Digitalmars-d-learn
On Saturday, 11 July 2015 at 13:31:12 UTC, Peter wrote: The postblit can only not take @nogc due to the array duplication which is understandable. I think the postblit might be redundant anyway since the struct is built on a static array so there is no possibility of two different Vect3s

Re: Import module

2015-07-10 Thread anonymous via Digitalmars-d-learn
On Friday, 10 July 2015 at 03:11:25 UTC, Mike Parker wrote: On Friday, 10 July 2015 at 00:53:38 UTC, codenstuff wrote: The path is ${HOME}/d_apps/steering/steering/game_object.d [...] First, because you are importing sterring.game_object, then you can't pass -I/home/real/d_apps/steering to

Re: Import module

2015-07-10 Thread anonymous via Digitalmars-d-learn
On Friday, 10 July 2015 at 00:53:38 UTC, codenstuff wrote: On Friday, 10 July 2015 at 00:24:44 UTC, anonymous wrote: On Thursday, 9 July 2015 at 22:05:23 UTC, codenstuff wrote: I am trying to import module and compile. The compiler produces message map/map.d(9): Error: module game_object is

Re: Import module

2015-07-09 Thread anonymous via Digitalmars-d-learn
On Thursday, 9 July 2015 at 22:05:23 UTC, codenstuff wrote: I am trying to import module and compile. The compiler produces message map/map.d(9): Error: module game_object is in file 'steering/game_object.d' which cannot be read import path[0] = /usr/include/dmd/phobos import path[1] =

Re: LDC 0.15.2 beta2 is out!

2015-07-08 Thread anonymous via Digitalmars-d-announce
On Tuesday, 7 July 2015 at 06:10:33 UTC, Mathias Lang wrote: Congrats ! Though, I don't know if you'd notice, but those binary are not using from Travis-ci: https://github.com/rejectedsoftware/vibe.d/pull/1171#issuecomment-119005076 Which makes it sensitively harder to test it (and I'd like to

Re: Understanding Safety of Function Pointers vs. Addresses of Functions

2015-07-07 Thread anonymous via Digitalmars-d-learn
On Tuesday, 7 July 2015 at 19:54:19 UTC, jmh530 wrote: I'm not sure I understand the safety of function pointers vs. the addresses of functions. The code below illustrates the issue. I was under the impression that pointers are not allowed in safe code. No, pointers are fine. It's pointer

Re: Understanding Safety of Function Pointers vs. Addresses of Functions

2015-07-07 Thread anonymous via Digitalmars-d-learn
On Tuesday, 7 July 2015 at 20:32:49 UTC, jmh530 wrote: Thanks for the detailed answer. All I meant here is that if I have some T foo(T)(T x), then to take the address, sometimes I've needed to foo!int or foo!real, etc. Ah, sure. Templates don't have addresses. Function templates are not

Re: incorrect data when returning static array in place of dynamic

2015-07-06 Thread anonymous via Digitalmars-d-learn
On Monday, 6 July 2015 at 07:48:17 UTC, sigod wrote: Aren't compiler smart enough to prevent it? ``` ubyte[] test1() { auto b = sha1Of(); return b; // Error: escaping reference to local b } ubyte[] test2() { return sha1Of(); // works, but returns incorrect data } ```

Re: Array operations with array of structs

2015-07-06 Thread anonymous via Digitalmars-d-learn
On Monday, 6 July 2015 at 01:16:54 UTC, Peter wrote: Hi, I have a struct with arithmetic operations defined using opBinary but array operations with arrays of it don't work. struct Vector3 { public double[3] _p; ... Vector3 opBinary(string op)(in Vector3 rhs) const if (op ==

Re: Array operations with array of structs

2015-07-06 Thread anonymous via Digitalmars-d-learn
On Monday, 6 July 2015 at 03:02:59 UTC, Nicholas Wilson wrote: On Monday, 6 July 2015 at 01:16:54 UTC, Peter wrote: [...] unittest{ auto a = Vector3([2.0, 2.0, 0.0]); auto b = Vector3([1.0, 2.0, 1.0]); Vector3[] c = [a]; Vector3[] d = [b]; Vector3 e = a + b; // works

Re: Array operations with array of structs

2015-07-06 Thread anonymous via Digitalmars-d-learn
On Monday, 6 July 2015 at 12:15:22 UTC, Peter wrote: dmd 2.066.1, windows 7 64bit Tested it on Windows 7, using dmd 2.066.1: works for me. The exact code I tested (just commented those ... out): struct Vector3 { public double[3] _p; //... Vector3 opBinary(string op)(in

Re: Correctly implementing a bidirectional range on a linked list?

2015-07-06 Thread anonymous via Digitalmars-d-learn
On Monday, 6 July 2015 at 20:50:19 UTC, Gary Willoughby wrote: How do you correctly implement a bidirectional range on a linked list? I have a linked list implementation and I've added a range interface to it but after a while I've realized it not quite right. The problem is when I call the

Re: Correctly implementing a bidirectional range on a linked list?

2015-07-06 Thread anonymous via Digitalmars-d-learn
On Monday, 6 July 2015 at 21:58:31 UTC, anonymous wrote: To make your removal methods stable, it may be enough to not free the removed node. That is, don't do this: https://github.com/nomad-software/etcetera/blob/master/source/etcetera/collection Looks like I messed up the URL. Here's the

Re: lovely compiler error message - incompatible types

2015-07-02 Thread anonymous via Digitalmars-d-learn
On Thursday, 2 July 2015 at 17:33:29 UTC, Laeeth Isharc wrote: Any thoughts on what could be leading to the following: ./../../marketdata/source/pricebar.d(397): Error: incompatible types for ((bar.high) + (bar.low)): 'FixedDecimal!(int, 8)' and 'FixedDecimal!(int, 8)'

Re: time difference - beautify my code

2015-07-02 Thread anonymous via Digitalmars-d-learn
On Thursday, 2 July 2015 at 19:03:49 UTC, dd0s wrote: i got a date t described in seconds from 1.1.1970, I.e., you have a unix timestamp. and i want to check if the current time is further than 12 hours from the given time t. the following code works but it's super ugly =S please give me

Re: version: multiple conditions

2015-07-01 Thread anonymous via Digitalmars-d
On Monday, 15 June 2015 at 10:56:43 UTC, ketmar wrote: if only there is a way to define such enums from command line, akin to - version... +1. predefined versions can be easily set at CT as enum an used with static if() but with this feature is would make more sense.

Re: wrong struct alignment

2015-07-01 Thread anonymous via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 20:01:08 UTC, dd0s wrote: i have the following struct, and i expect it to have 30 bytes but sizeof tells me it has 32 bytes. dmd seems to still use 4byte alignment altough i specified to align 2bytes. struct netadr_t { align(2): inttype; // 0

Re: Same process to different results?

2015-07-01 Thread anonymous via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 17:13:03 UTC, Taylor Hillegeist wrote: string q = cast(string) (A.cycle.take(seg1len).array ~B.cycle.take(seg2len).array ~C.cycle.take(seg3len).array); q.writeln; I was wondering if it might be the cast? Yes, the cast is wrong. You're reinterpreting (not

Re: Map Purity

2015-06-30 Thread anonymous via Digitalmars-d-learn
On Sunday, 28 June 2015 at 16:28:20 UTC, jmh530 wrote: Thanks for the reply. Two follow ups: 1) Does labeling a template as pure matter if the compiler infers it anyway? 2) Does the compiler also infer anything for @safe/nothrow in templates? 1) It means you can't instantiate the template

Re: goroutines vs vibe.d tasks

2015-06-30 Thread anonymous via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 15:18:36 UTC, Jack Applegame wrote: Just creating a bunch (10k) of sleeping (for 100 msecs) goroutines/tasks. Compilers go: go version go1.4.2 linux/amd64 vibe.d: DMD64 D Compiler v2.067.1 linux/amd64, vibe.d 0.7.23 Code go: http://pastebin.com/2zBnGBpt

Re: Bug or feature?

2015-06-30 Thread anonymous via Digitalmars-d-learn
On Monday, 29 June 2015 at 12:04:46 UTC, Jonathan M Davis wrote: You haven't declared an immutable constructor, so you can't construct an immutable Foo. That's not what's happening. Constructing an immutable Foo works just fine.

Re: Analyze a D file for imports

2015-06-30 Thread anonymous via Digitalmars-d
On Tuesday, 30 June 2015 at 13:22:10 UTC, rsw0x wrote: Be aware of the challenges: Compiling source files separately is slower than passing them all at once to the compiler. this is only true for dmd As far as I understand, the slowdown comes from parsing common dependencies again and

Re: Analyze a D file for imports

2015-06-30 Thread anonymous via Digitalmars-d
On Tuesday, 30 June 2015 at 04:02:00 UTC, Maaaks wrote: I want to make a simple build utility that will rebuild only those files which changed since last build and those files that depend on them. Which is the easiest and yet reliable way to parse a D source and find all imports in it (and

Re: Analyze a D file for imports

2015-06-30 Thread anonymous via Digitalmars-d
On Tuesday, 30 June 2015 at 14:18:20 UTC, rsw0x wrote: you're skipping the part where they can be ran in parallel, dmd sees no benefit from this. Could you elaborate? Surely, one can run multiple instances of dmd in parallel, no? In my (possibly flawed) understanding, to get the quickest

Re: Analyze a D file for imports

2015-06-30 Thread anonymous via Digitalmars-d
On Tuesday, 30 June 2015 at 14:49:11 UTC, Atila Neves wrote: On Tuesday, 30 June 2015 at 13:21:18 UTC, anonymous wrote: [...] Here's a pull request to make rdmd do that: https://github.com/D-Programming-Language/tools/pull/170 [...] rdmd doesn't run on files that need updating; it always

Re: Why D doesn't have an equivalent to C#'s readonly?

2015-06-30 Thread anonymous via Digitalmars-d-learn
On Monday, 29 June 2015 at 22:11:16 UTC, sigod wrote: `new immutable(MyClass)()` is invalid code. It's perfectly fine, actually.

Re: Pure delegate not quite pure?

2015-06-28 Thread anonymous via Digitalmars-d-learn
On Sunday, 28 June 2015 at 09:19:16 UTC, Tofu Ninja wrote: module main; import std.stdio; void main(string[] args) { auto d = foo(); writeln(d()); // prints 25 } auto foo() { int x = 4; pure int delegate() d = delegate() { return x*x;

Re: how to string → uint* ?

2015-06-28 Thread anonymous via Digitalmars-d-learn
On Sunday, 28 June 2015 at 01:57:46 UTC, xky wrote: hello. :-) when i was using DerelictSFML2( http://code.dlang.org/packages/derelict-sfml2 ), i got this problem. CSFML doc had 'setUnicodeString':

std.json.JsonOptions

2015-06-24 Thread anonymous via Digitalmars-d
On Tuesday, 23 June 2015 at 22:45:10 UTC, Vladimir Panteleev wrote: A rename can be proposed by creating a subthread: reply to this post, but change the name to the fully-qualified name of the identifier you'd like to see renamed. Please include a rationale and a proposed new name in your

Re: Program exited with code -11

2015-06-23 Thread anonymous via Digitalmars-d-learn
On Tuesday, 23 June 2015 at 07:57:26 UTC, Charles Hawkins wrote: Sigh. I'm probably doing something stupid. I tried full paths: dmd -I+/home/charles/projects/d/mylib/source/mylib/ myprog.d What's that plus sign doing there? Looks wrong. /home/charles/projects/d/mylib/build/libmylib.a Same

Re: core.exception.InvalidMemoryOperationError@(0) on File Reading.

2015-06-22 Thread anonymous via Digitalmars-d-learn
On Monday, 22 June 2015 at 20:30:40 UTC, David DeWitt wrote: I am getting an core.exception.InvalidMemoryOperationError@(0) auto recs = f // Open for reading .byLineCopy(); .array; //Here is where is appears to be happening. I have

Re: How do I make my class iterable?

2015-06-22 Thread anonymous via Digitalmars-d-learn
On Monday, 22 June 2015 at 18:44:22 UTC, Assembly wrote: I'm using this, thanks for all. Can someone clarify how does opApply() works? I assume it's called every iteration and as opApply() has a loop does it means the number of iteration ran actually is the ones from foreach() is 2*n where n

Re: split up the changelog?

2015-06-20 Thread anonymous via Digitalmars-d
On Friday, 19 June 2015 at 21:28:11 UTC, anonymous wrote: For some reason the list stops at 2.023. I don't know if I messed something up, or if dmd is being silly. Will have to investigate. Filed issue 14717 - Ddoc macro recursion limit too low: https://issues.dlang.org/show_bug.cgi?id=14717

Re: split up the changelog?

2015-06-19 Thread anonymous via Digitalmars-d
On Friday, 19 June 2015 at 19:22:03 UTC, Steven Schveighoffer wrote: But, what about making the changelog menu an accordion expander, and then you have your version list right there on the left? Did that here: http://d-ag0aep6g.rhcloud.com/accordion/changelog/2.067.1.html I like it. I kept

split up the changelog?

2015-06-19 Thread anonymous via Digitalmars-d
The changelog.html file is at about 1MB. That makes for a noticeable load time. And with all the issue lists, it's also a pretty solid wall of text: Wait, is all this still for 2.067.0? Did I miss a version heading? I think I'm lost. Let's split it up by version! Pull request:

Re: Martin Nowak is officially MIA

2015-06-18 Thread anonymous via Digitalmars-d
On Thursday, 18 June 2015 at 13:40:43 UTC, Craig Dillabaugh wrote: As others have said this seems a bit harsh. I presume that by 'we' you mean that yourself and Walter arrived at this decision together? If you really felt the need to remove Martin from this position, the appropriate way

Re: Martin Nowak is officially MIA

2015-06-18 Thread anonymous via Digitalmars-d
On Thursday, 18 June 2015 at 14:43:15 UTC, Andrei Alexandrescu wrote: To wit, I wrote this to Martin and Walter on May 31st: Today is May 31st, so we're entering the last month of H1. I'd like to get an early start on updating the vision document, and before creating yet another rambling

Re: version: multiple conditions

2015-06-16 Thread anonymous via Digitalmars-d
On Tuesday, 16 June 2015 at 21:10:50 UTC, rsw0x wrote: On Tuesday, 16 June 2015 at 21:09:40 UTC, rsw0x wrote: On Tuesday, 16 June 2015 at 20:59:35 UTC, Walter Bright wrote: On 6/16/2015 1:46 PM, rsw0x wrote: You call it abuse, I call it developer freedom. #define BEGIN { #define END }

Re: Defining constant values in struct

2015-06-16 Thread anonymous via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 21:17:37 UTC, tcak wrote: As far as I known, when I define a string with enum and it is used at different parts of code, that string is repeated again and again in executable file instead of passing a pointer to string. So, using enum with string doesn't seem like a

Re: Casting MapResult

2015-06-15 Thread anonymous via Digitalmars-d-learn
On Monday, 15 June 2015 at 15:10:24 UTC, jmh530 wrote: float[] exp(float[] x) { auto y = x.map!(a = exp(a)); cast(float[]) y; return y; } But I get an error that I can't convert MapResult!(__lambda2, float[]) to float[]. So I suppose I have two questions: 1) am I

Re: DIP80: phobos additions

2015-06-15 Thread anonymous via Digitalmars-d
On Sunday, 14 June 2015 at 21:50:02 UTC, Ola Fosheim Grøstad wrote: On Sunday, 14 June 2015 at 21:31:53 UTC, anonymous wrote: 2. Then write similar code with hardware optimized BLAS and benchmark where the overhead between pure C/LLVM and BLAS calls balance out to even. may there are more

Re: __traits getMember is context sensetive?

2015-06-14 Thread anonymous via Digitalmars-d-learn
On Sunday, 14 June 2015 at 10:10:51 UTC, ketmar wrote: i.e. when it need a value in compile time. the interpreter is invoked, it evaluates (interprets) the given code (function or template instantiation), and then it returns result (or raises an error). One important thing I didn't see

Re: __traits getMember is context sensetive?

2015-06-14 Thread anonymous via Digitalmars-d-learn
On Sunday, 14 June 2015 at 10:41:24 UTC, JDemler wrote: So if i want to use parameters in a static context at compile time i have to pass them as template parameters? Yes, template parameters are fine.

Re: Qualified destructors / immutable objects

2015-06-14 Thread anonymous via Digitalmars-d-learn
To come back to destructors and immutable objects: Even without the default initialized variables issue it is possible to modify immutable data: struct S { int[] bar; ~this() { bar[0] = 123; } } void foo(immutable(int[]) i) { immutable(S) s = immutable S(i); } void main() {

Re: DIP80: phobos additions

2015-06-14 Thread anonymous via Digitalmars-d
1. Create generalised (only type template and my be flags) BLAS algorithms (probably slow) with CBLAS like API. See [1] (the Matmul benchmark) Julia Native is probably backed with Intel MKL or OpenBLAS. D version was optimized by Martin Nowak [2] and is still _much_ slower. 2. Allow users to

Re: Scaling rdmd up: build package at a time

2015-06-14 Thread anonymous via Digitalmars-d
On Saturday, 6 June 2015 at 20:27:12 UTC, anonymous wrote: The seemingly obvious thing to do: Pass the source files that need rebuilding and the object files of other modules to one dmd invocation. I implemented this. Preliminary pull request:

Re: Conditional Compilation Multiple Versions

2015-06-13 Thread anonymous via Digitalmars-d-learn
On Saturday, 13 June 2015 at 00:47:37 UTC, Mike Parker wrote: // config.d version(One) enum One = true; else enum One = false; version(Two) enum Two = true; else enum Two = false; // other.d import config; static if(One || Two) { ... } Taking it one step further: template Version(string

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread anonymous via Digitalmars-d-learn
On Saturday, 13 June 2015 at 15:21:19 UTC, Dennis Ritchie wrote: Hello, everyone! I like to work with arrays of strings like `string[] strArray`, but unfortunately, they are immutable. I do not like to work with arrays of strings such as `char[][] strArray`, because it is necessary to apply

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread anonymous via Digitalmars-d-learn
On Saturday, 13 June 2015 at 17:02:06 UTC, Dennis Ritchie wrote: On Saturday, 13 June 2015 at 16:20:46 UTC, anonymous wrote: [...] Yeah, that would be neat. But typing out .dup isn't that bad, and converting a `string[]` to a `char[][]` is simple: import std.conv: to; auto a =

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread anonymous via Digitalmars-d-learn
On Saturday, 13 June 2015 at 15:58:44 UTC, Dennis Ritchie wrote: On Saturday, 13 June 2015 at 15:45:34 UTC, anonymous wrote: Before jumping to a solution, please elaborate on the perceived problem. I have a feeling that there is none. Do you like to write? char[][] strArray = [foo.dup,

Re: char[][] to std::vectorstd::string - DIP or dmd-issue?

2015-06-13 Thread anonymous via Digitalmars-d-learn
On Saturday, 13 June 2015 at 16:09:58 UTC, Dennis Ritchie wrote: On Saturday, 13 June 2015 at 15:45:34 UTC, anonymous wrote: [...] Are you saying that `string[]` is simpler than `char[][]`? That's not true: `string` is an alias for `immutable(char)[]`, so `string[]` is the same as

Re: Qualified destructors / immutable objects

2015-06-13 Thread anonymous via Digitalmars-d-learn
Is there an existing issue on issue.dlang.org? If not can you report it https://issues.dlang.org/show_bug.cgi?id=10376

Re: Qualified destructors / immutable objects

2015-06-12 Thread anonymous via Digitalmars-d-learn
no need for ~this() to modify immutable data: class C { int a; this(int a) { this.a = a; } } struct S { C elem = new C(42); } void main() { import std.stdio; immutable(S) s1; // Error: cannot modify immutable expression

Re: Qualified destructors / immutable objects

2015-06-12 Thread anonymous via Digitalmars-d-learn
I cannot find a way to actually modify immutable memory with it... a.d: class C { int a; this(int a) { this.a = a; } } struct S { int x; C elem = new C(42); ~this() { import std.stdio; writeln(mutable ~this()); x = 1; elem.a = 123;

Re: Reading array of integers readln performance issues

2015-06-11 Thread anonymous via Digitalmars-d-learn
On Thursday, 11 June 2015 at 19:56:00 UTC, kerdemdemir wrote: Can I achieve something faster than code below? auto peopleMoney = stdin.readln().split().map!(a = to!int(a)).array(); if (peopleMoney.length == 20) writeln(:(); `std.array.split` is eager. It may be faster if you

Re: Is it possible to add items to the arrays and hashes at compile time?

2015-06-10 Thread anonymous via Digitalmars-d-learn
On Wednesday, 10 June 2015 at 17:00:34 UTC, Dennis Ritchie wrote: Isnt it possible to come up with the interpreter compile-time, which will determine the operating time of the program at runtime at compile time. Sounds like the halting problem. So, no, generally this is not possible.

Re: Asked on Reddit: Which of Rust, D, Go, Nim, and Crystal is the strongest and why?

2015-06-10 Thread anonymous via Digitalmars-d
On Wednesday, 10 June 2015 at 15:08:08 UTC, anonymous wrote: any community dumb enough to buy merchandise with a programming language's name on it is full of idiots. bye. p.s., Nim has the absolute worst community out of any of these languages.

Re: Asked on Reddit: Which of Rust, D, Go, Nim, and Crystal is the strongest and why?

2015-06-10 Thread anonymous via Digitalmars-d
On Wednesday, 10 June 2015 at 14:29:51 UTC, Thiez wrote: On Wednesday, 10 June 2015 at 09:23:54 UTC, Chris wrote: One big difference between the D community and other languages' communities is is that D people keep criticizing the language and see every little flaw in every little corner,

Re: Asked on Reddit: Which of Rust, D, Go, Nim, and Crystal is the strongest and why?

2015-06-10 Thread anonymous via Digitalmars-d
On Wednesday, 10 June 2015 at 15:13:41 UTC, Brian Rogoff wrote: On Wednesday, 10 June 2015 at 15:09:21 UTC, anonymous wrote: On Wednesday, 10 June 2015 at 15:08:08 UTC, anonymous wrote: any community dumb enough to buy merchandise with a programming language's name on it is full of idiots.

Re: Building the docs with own changes

2015-06-08 Thread anonymous via Digitalmars-d
On Monday, 8 June 2015 at 11:27:58 UTC, John Colvin wrote: Is there any non-insane way of changing some documentation in a module and checking that any links/xrefs you may have added actually work? The dlang.org makefile appears to happily erase uncommitted changes in ../druntime and

Re: Scaling rdmd up: build package at a time

2015-06-06 Thread anonymous via Digitalmars-d
On Saturday, 6 June 2015 at 19:44:15 UTC, Andrei Alexandrescu wrote: On 6/6/15 11:47 AM, Jacob Carlborg wrote: [...] I mean that rdmd should compile all files that has changed including its dependencies, no more, no less. It should compile all these files in one go. Yah, that's the

Re: Scaling rdmd up: build package at a time

2015-06-06 Thread anonymous via Digitalmars-d
On Saturday, 6 June 2015 at 21:24:05 UTC, Atila Neves wrote: I don't think I understand. Where would these object files come from unless you're doing per-module compilation, C-style? Huh, I somehow assumed dmd would spit out multiple object files when given multiple source files. Since that's

Re: Code behaves incorrectly if it is compiled in std.functional

2015-06-05 Thread anonymous via Digitalmars-d
On Friday, 5 June 2015 at 03:15:46 UTC, anonymous wrote: On Friday, 5 June 2015 at 02:38:39 UTC, ketmar wrote: here's dustmited source: Further reduced: void unaryFun()(auto int a) pure nothrow @safe @nogc {} alias Identity(F) = F; void main() { unaryFun!()(41); static void fun(int n)

Re: Getting Started

2015-06-05 Thread anonymous via Digitalmars-d
On Friday, 5 June 2015 at 20:18:59 UTC, tcak wrote: I am looking at the main page of dlang.org, and really there is no page to warm up a new comer to D language. Sure, there are book links, details of language as D Reference etc, but those are not suitable for a new starting guy.

Re: Getting Started

2015-06-05 Thread anonymous via Digitalmars-d
On Saturday, 6 June 2015 at 01:24:42 UTC, Israel wrote: Except my getting started page idea was supposed to cater to both new programmers and people who are just new to D... If you ever get around to realize it, that would be great. In the meantime, linking to Ali's tutorial and example pages

Re: Code behaves incorrectly if it is compiled in std.functional

2015-06-04 Thread anonymous via Digitalmars-d
On Friday, 5 June 2015 at 02:38:39 UTC, ketmar wrote: here's dustmited source: Further reduced: void unaryFun()(auto int a) pure nothrow @safe @nogc {} alias Identity(F) = F; void main() { unaryFun!()(41); static void fun(int n) pure nothrow @safe @nogc {} alias F = typeof(fun);

Re: Code behaves incorrectly if it is compiled in std.functional

2015-06-04 Thread anonymous via Digitalmars-d
On Friday, 5 June 2015 at 03:45:18 UTC, ketmar wrote: `auto int a`?! it shouldn't be accepted at all! Yeah, but it's the same with auto ref.

Re: forum.dlang.org, version 2 (BETA)

2015-06-04 Thread Mr. Anonymous via Digitalmars-d-announce
On Thursday, 4 June 2015 at 15:04:05 UTC, Vladimir Panteleev wrote: http://beta.forum.dlang.org/ Many major and minor improvements. Some major ones: - dlang.org theme, fully responsive and mobile-friendly - keyboard navigation in all views - automatically saved post drafts - get notified of

Re: This Week in D: DConf 2015 Wednesday Morning writeups!

2015-06-02 Thread anonymous via Digitalmars-d-announce
The link to harbored is broken ... On Tuesday, 2 June 2015 at 04:22:08 UTC, Adam D. Ruppe wrote: On Tuesday, 2 June 2015 at 04:17:47 UTC, John Colvin wrote: Actually, http://forum.dlang.org/post/sujyaurgyfumoiimi...@forum.dlang.org would be better cool fixed, remember to refresh as the file

Re: rvalue references

2015-06-02 Thread anonymous via Digitalmars-d
On Tuesday, 2 June 2015 at 16:02:56 UTC, Namespace wrote: Thanks to DIP 25 I think it's time to review this again. I would implement it (if no one else wants to do it), but there are still some unanswered questions: 1. Is 'auto ref' still the chosen syntax (I guess so)? 2. Should auto ref for

Re: ddox no longer part of dlang.org?

2015-05-29 Thread anonymous via Digitalmars-d
On Saturday, 30 May 2015 at 01:11:33 UTC, Steven Schveighoffer wrote: In Andrei's presentation last night, he mentioned that the new ddox documentation coincided with a surge in visits to dlang.org. However, I just noticed, the link to them is gone. How long has that been the case, and can

Re: Replacing nested loops foreach using map/each/etc

2015-05-25 Thread anonymous via Digitalmars-d-learn
On Monday, 25 May 2015 at 17:52:09 UTC, Dennis Ritchie wrote: But why is the solution breaks down when `s = 1` ? :) import std.stdio, std.algorithm, std.range; int c; const x = 12, y = 65, z = 50, s = 10; Which is it, now? 4 or 5 zeros? void solve(Range)(Range r) {

Re: ctfe and static arrays

2015-05-24 Thread anonymous via Digitalmars-d-learn
On Sunday, 24 May 2015 at 17:35:39 UTC, Jay Norwood wrote: I'm a bit confused by the documentation of the ctfe limitations wrt static arrays due to these seemingly conflicting statements, and the examples didn't seem to clear anything up. I was wondering if anyone has examples of clever

Re: ctfe and static arrays

2015-05-24 Thread anonymous via Digitalmars-d-learn
On Sunday, 24 May 2015 at 18:14:19 UTC, anonymous wrote: Static array has a special meaning. It does not mean static variable with an array type. Static arrays are those of the form Type[size]. That is, the size is known statically. PS: You may also see the term fixed-size array which means

Re: ctfe and static arrays

2015-05-24 Thread anonymous via Digitalmars-d-learn
On Sunday, 24 May 2015 at 20:53:03 UTC, Jay Norwood wrote: On Sunday, 24 May 2015 at 18:14:19 UTC, anonymous wrote: [...] 1) static int[5] x; -- x is a static variable with a static array type 2) static int[] x; -- static variable, dynamic array 3) int[5] x; -- non-static variable, static

Re: Python's features, which requires D

2015-05-23 Thread anonymous via Digitalmars-d-learn
On Saturday, 23 May 2015 at 20:25:18 UTC, Dennis Ritchie wrote: This does not work! enum n1 = 5; writeln(stdin.byLine .map!(line = line.split( ).map!(x = to!int(x))) ); - http://rextester.com/VGHZF81178 The code itself is ok. That site has broken newlines. You can see here that

Re: Python's features, which requires D

2015-05-23 Thread anonymous via Digitalmars-d-learn
On Saturday, 23 May 2015 at 21:08:19 UTC, Dennis Ritchie wrote: Perhaps that's not the site, and in Windows. That's what gives me in CMD: 456 4 4 8 99 456 [[456, 4, 4, 8, 99, 456]13 546 std.conv.ConvException@C:\D\dmd2\windows\bin\..\..\src\phobos\std\conv.d(2013): Unexpected end of input

Re: -vgc Info ok?

2015-05-19 Thread anonymous via Digitalmars-d-learn
On Monday, 18 May 2015 at 14:34:38 UTC, ketmar wrote: it can throw out of range error, which is `new`ed. Array access can also throw RangeError, but -vgc and @nogc don't mind that: void main() @nogc { int[] a; auto b = a[0]; }

Re: Const is already there. It cannot deduce it

2015-05-18 Thread anonymous via Digitalmars-d-learn
On Sunday, 17 May 2015 at 21:34:21 UTC, tcak wrote: [code] void test(D)( const D data ) if( is(D: shared(char[]) ) ) { } void main() { char[] text = new char[4]; text[0] = 'a'; text[1] = 'b'; text[2] = 'c'; text[3] = 'd'; auto t = cast( shared(const(char[]))

Re: Capturing Caller UDAs as CT Template Function Parameters

2015-05-18 Thread anonymous via Digitalmars-d-learn
On Monday, 18 May 2015 at 21:35:44 UTC, Per Nordlöw wrote: void yield(T)(ref T value) { mixin(alias caller = ~ caller ~ ;); } doesn't work across module boundaries not even for `__PRETTY_FUNCTION__`. Do we need need to fix the compiler, Walter?! ;) You have to import

Re: How to create a mutable array of strings?

2015-05-17 Thread anonymous via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:20:17 UTC, Dennis Ritchie wrote: On Sunday, 17 May 2015 at 09:18:15 UTC, Daniel Kozak wrote: auto s = cast(char[][])[foo, bar]; Thanks. This version I was completely satisfied. Remember that Daniel Kozak wrote if you are sure thats what you really need. I'm

Re: How to create a mutable array of strings?

2015-05-17 Thread anonymous via Digitalmars-d-learn
On Sunday, 17 May 2015 at 09:26:15 UTC, Dennis Ritchie wrote: And no crashes on Windows :) Yeah, on windows it's even worse. void main() { auto s = cast(char[][])[foo, bar]; s[1][1] = 't'; import std.stdio; writeln(bar); }

Re: ICE?

2015-05-17 Thread anonymous via Digitalmars-d-learn
On Sunday, 17 May 2015 at 10:09:11 UTC, Daniel Kozak wrote: On Sunday, 17 May 2015 at 09:25:33 UTC, Namespace wrote: [...] Error: e2ir: cannot cast malloc(length * 8u) of type void* to type char[] I would say this is not an ICE just normal error message. e2ir: shouldn't be there, though.

Re: What wrong?

2015-05-15 Thread anonymous via Digitalmars-d-learn
On Saturday, 2 May 2015 at 02:51:52 UTC, Fyodor Ustinov wrote: Simple code: http://pastebin.com/raw.php?i=7jVeMFXQ This code works compiled by DMD v2.066.1 and LDC2 (0.15.1) based on DMD v2.066.1 and LLVM 3.5.0. $ ./z TUQLUE 42 11 Compiled by DMD v2.067.1 the program crashes: $ ./aa TUQLUE

<    1   2   3   4   5   6   7   8   9   >